expression: implement vectorized evaluation for 'builtinGTIntSig' (#13074)

This commit is contained in:
tsthght
2019-11-02 21:43:34 +08:00
committed by pingcap-github-bot
parent 5b161df353
commit 089895a574
2 changed files with 58 additions and 6 deletions

View File

@ -275,11 +275,35 @@ func (b *builtinNEIntSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) e
}
func (b *builtinGTIntSig) vectorized() bool {
return false
return true
}
func (b *builtinGTIntSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) error {
return errors.Errorf("not implemented")
n := input.NumRows()
var err error
var buf0, buf1 *chunk.Column
buf0, err = b.bufAllocator.get(types.ETInt, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf0)
if err := b.args[0].VecEvalInt(b.ctx, input, buf0); err != nil {
return err
}
buf1, err = b.bufAllocator.get(types.ETInt, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf1)
if err := b.args[1].VecEvalInt(b.ctx, input, buf1); err != nil {
return err
}
result.ResizeInt64(n, false)
vecCompareInt(mysql.HasUnsignedFlag(b.args[0].GetType().Flag), mysql.HasUnsignedFlag(b.args[1].GetType().Flag), buf0, buf1, result)
result.MergeNulls(buf0, buf1)
vecResOfGT(result.Int64s())
return nil
}
func (b *builtinCoalesceDurationSig) vectorized() bool {
@ -432,6 +456,17 @@ func vecResOfLT(res []int64) {
}
}
func vecResOfGT(res []int64) {
n := len(res)
for i := 0; i < n; i++ {
if res[i] > 0 {
res[i] = 1
} else {
res[i] = 0
}
}
}
//vecCompareInt is vectorized CompareInt()
func vecCompareInt(isUnsigned0, isUnsigned1 bool, largs, rargs, result *chunk.Column) {
switch {

View File

@ -46,10 +46,27 @@ var vecBuiltinCompareCases = map[string][]vecExprBenchCase{
},
ast.Coalesce: {},
ast.NullEQ: {},
ast.GT: {},
ast.EQ: {},
ast.GE: {},
ast.Date: {},
ast.GT: {
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt, types.ETInt}},
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt, types.ETInt},
childrenFieldTypes: []*types.FieldType{{Tp: mysql.TypeLonglong, Flag: mysql.UnsignedFlag},
{Tp: mysql.TypeLonglong, Flag: mysql.UnsignedFlag},
},
},
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt, types.ETInt},
childrenFieldTypes: []*types.FieldType{{Tp: mysql.TypeLonglong},
{Tp: mysql.TypeLonglong, Flag: mysql.UnsignedFlag},
},
},
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt, types.ETInt},
childrenFieldTypes: []*types.FieldType{{Tp: mysql.TypeLonglong, Flag: mysql.UnsignedFlag},
{Tp: mysql.TypeLonglong},
},
},
},
ast.EQ: {},
ast.GE: {},
ast.Date: {},
ast.Greatest: {
{retEvalType: types.ETDecimal, childrenTypes: []types.EvalType{types.ETDecimal, types.ETDecimal, types.ETDecimal}},
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt, types.ETInt, types.ETInt}},