Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
sre-bot authored Nov 14, 2019
2 parents 01f88ed + 65389a1 commit 0048bdb
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
31 changes: 29 additions & 2 deletions expression/builtin_string_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -912,11 +912,38 @@ func (b *builtinRTrimSig) vecEvalString(input *chunk.Chunk, result *chunk.Column
}

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

func (b *builtinStrcmpSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) error {
return errors.Errorf("not implemented")
n := input.NumRows()
leftBuf, err := b.bufAllocator.get(types.ETString, n)
if err != nil {
return err
}
defer b.bufAllocator.put(leftBuf)
if err := b.args[0].VecEvalString(b.ctx, input, leftBuf); err != nil {
return err
}
rightBuf, err := b.bufAllocator.get(types.ETString, n)
if err != nil {
return err
}
defer b.bufAllocator.put(rightBuf)
if err := b.args[1].VecEvalString(b.ctx, input, rightBuf); err != nil {
return err
}
result.ResizeInt64(n, false)
result.MergeNulls(leftBuf, rightBuf)
i64s := result.Int64s()
for i := 0; i < n; i++ {
// if left or right is null, then set to null and return 0(which is the default value)
if result.IsNull(i) {
continue
}
i64s[i] = int64(types.CompareString(leftBuf.GetString(i), rightBuf.GetString(i)))
}
return nil
}

func (b *builtinLocateBinary2ArgsSig) vectorized() bool {
Expand Down
15 changes: 15 additions & 0 deletions expression/builtin_string_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,21 @@ var vecBuiltinStringCases = map[string][]vecExprBenchCase{
},
},
},
ast.Strcmp: {
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETString}},
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETString}, geners: []dataGenerator{
&selectStringGener{
candidates: []string{
"test",
},
},
&selectStringGener{
candidates: []string{
"test",
},
},
}},
},
}

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

0 comments on commit 0048bdb

Please sign in to comment.