expression: implement vectorized evaluation for builtinCRC32Sig (#13126)

This commit is contained in:
Zhongyang Wu
2019-11-04 23:43:39 -05:00
committed by pingcap-github-bot
parent 354d8723ca
commit 648bed40d3
2 changed files with 23 additions and 2 deletions

View File

@ -15,6 +15,7 @@ package expression
import (
"fmt"
"hash/crc32"
"math"
"strconv"
@ -658,11 +659,28 @@ func (b *builtinRoundWithFracIntSig) vectorized() bool {
return true
}
func (b *builtinCRC32Sig) vectorized() bool {
return false
return true
}
func (b *builtinCRC32Sig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) error {
return errors.Errorf("not implemented")
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()
result.MergeNulls(buf)
for i := range i64s {
if !buf.IsNull(i) {
i64s[i] = int64(crc32.ChecksumIEEE(buf.GetBytes(i)))
}
}
return nil
}
func (b *builtinPISig) vectorized() bool {

View File

@ -110,6 +110,9 @@ var vecBuiltinMathCases = map[string][]vecExprBenchCase{
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt, types.ETInt}, geners: []dataGenerator{nil, &rangeInt64Gener{-10, 10}}},
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt, types.ETInt}, childrenFieldTypes: []*types.FieldType{{Tp: mysql.TypeInt24, Flag: mysql.UnsignedFlag}}, geners: []dataGenerator{nil, &rangeInt64Gener{-10, 10}}},
},
ast.CRC32: {
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString}},
},
}
func (s *testEvaluatorSuite) TestVectorizedBuiltinMathEvalOneVec(c *C) {