Skip to content

Commit

Permalink
expression: implement vectorized evaluation for builtinHexIntArgSig (
Browse files Browse the repository at this point in the history
  • Loading branch information
js00070 authored and XiaTianliang committed Dec 21, 2019
1 parent be6df4d commit 8fb1093
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
22 changes: 20 additions & 2 deletions expression/builtin_string_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -1808,11 +1808,29 @@ func (b *builtinSubstringBinary3ArgsSig) vecEvalString(input *chunk.Chunk, resul
}

func (b *builtinHexIntArgSig) vectorized() bool {
return false
return true
}

func (b *builtinHexIntArgSig) vecEvalString(input *chunk.Chunk, result *chunk.Column) error {
return errors.Errorf("not implemented")
n := input.NumRows()
buf, err := b.bufAllocator.get(types.ETInt, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf)
if err := b.args[0].VecEvalInt(b.ctx, input, buf); err != nil {
return err
}
result.ReserveString(n)
i64s := buf.Int64s()
for i := 0; i < n; i++ {
if buf.IsNull(i) {
result.AppendNull()
continue
}
result.AppendString(strings.ToUpper(fmt.Sprintf("%x", uint64(i64s[i]))))
}
return nil
}

func (b *builtinFieldIntSig) vectorized() bool {
Expand Down
1 change: 1 addition & 0 deletions expression/builtin_string_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ var vecBuiltinStringCases = map[string][]vecExprBenchCase{
},
ast.Hex: {
{retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{&randHexStrGener{10, 100}}},
{retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETInt}},
},
ast.Unhex: {
{retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{&randHexStrGener{10, 100}}},
Expand Down

0 comments on commit 8fb1093

Please sign in to comment.