Skip to content

Commit

Permalink
expression: implement vectorized evaluation for `builtinStringIsNullS…
Browse files Browse the repository at this point in the history
…ig` (#12128)
  • Loading branch information
b41sh authored and qw4990 committed Sep 12, 2019
1 parent 98b3aeb commit 7d53f0f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
27 changes: 27 additions & 0 deletions expression/builtin_string_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,30 @@ func (b *builtinRepeatSig) vecEvalString(input *chunk.Chunk, result *chunk.Colum
func (b *builtinRepeatSig) vectorized() bool {
return true
}

func (b *builtinStringIsNullSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) error {
n := input.NumRows()
buf, err := b.bufAllocator.get(types.ETString, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf)
if err := b.args[0].VecEvalString(b.ctx, input, buf); err != nil {
return err
}

result.ResizeInt64(n, false)
i64s := result.Int64s()
for i := 0; i < n; i++ {
if buf.IsNull(i) {
i64s[i] = 1
} else {
i64s[i] = 0
}
}
return nil
}

func (b *builtinStringIsNullSig) vectorized() bool {
return true
}
4 changes: 4 additions & 0 deletions expression/builtin_string_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ var vecBuiltinStringCases = map[string][]vecExprBenchCase{
ast.Lower: {
{types.ETString, []types.EvalType{types.ETString}, nil},
},
ast.IsNull: {
{types.ETInt, []types.EvalType{types.ETString}, []dataGenerator{&randLenStrGener{10, 20}}},
{types.ETInt, []types.EvalType{types.ETString}, []dataGenerator{&defaultGener{0.2, types.ETString}}},
},
}

func (s *testEvaluatorSuite) TestVectorizedBuiltinStringEvalOneVec(c *C) {
Expand Down

0 comments on commit 7d53f0f

Please sign in to comment.