expression: implement vectorized evaluation for builtinUnaryNot series functions (#12461)
This commit is contained in:
@ -135,11 +135,35 @@ func (b *builtinRealIsNullSig) vecEvalInt(input *chunk.Chunk, result *chunk.Colu
|
||||
}
|
||||
|
||||
func (b *builtinUnaryNotRealSig) vectorized() bool {
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *builtinUnaryNotRealSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) error {
|
||||
return errors.Errorf("not implemented")
|
||||
n := input.NumRows()
|
||||
buf, err := b.bufAllocator.get(types.ETReal, n)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer b.bufAllocator.put(buf)
|
||||
if err := b.args[0].VecEvalReal(b.ctx, input, buf); err != nil {
|
||||
return err
|
||||
}
|
||||
f64s := buf.Float64s()
|
||||
|
||||
result.ResizeInt64(n, false)
|
||||
result.MergeNulls(buf)
|
||||
i64s := result.Int64s()
|
||||
for i := 0; i < n; i++ {
|
||||
if result.IsNull(i) {
|
||||
continue
|
||||
}
|
||||
if f64s[i] == 0 {
|
||||
i64s[i] = 1
|
||||
} else {
|
||||
i64s[i] = 0
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *builtinLogicAndSig) vectorized() bool {
|
||||
@ -262,19 +286,59 @@ func (b *builtinUnaryMinusIntSig) vecEvalInt(input *chunk.Chunk, result *chunk.C
|
||||
}
|
||||
|
||||
func (b *builtinUnaryNotDecimalSig) vectorized() bool {
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *builtinUnaryNotDecimalSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) error {
|
||||
return errors.Errorf("not implemented")
|
||||
n := input.NumRows()
|
||||
buf, err := b.bufAllocator.get(types.ETDecimal, n)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer b.bufAllocator.put(buf)
|
||||
if err := b.args[0].VecEvalDecimal(b.ctx, input, buf); err != nil {
|
||||
return err
|
||||
}
|
||||
decs := buf.Decimals()
|
||||
|
||||
result.ResizeInt64(n, false)
|
||||
result.MergeNulls(buf)
|
||||
i64s := result.Int64s()
|
||||
for i := 0; i < n; i++ {
|
||||
if result.IsNull(i) {
|
||||
continue
|
||||
}
|
||||
if decs[i].IsZero() {
|
||||
i64s[i] = 1
|
||||
} else {
|
||||
i64s[i] = 0
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *builtinUnaryNotIntSig) vectorized() bool {
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *builtinUnaryNotIntSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) error {
|
||||
return errors.Errorf("not implemented")
|
||||
n := input.NumRows()
|
||||
if err := b.args[0].VecEvalInt(b.ctx, input, result); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
i64s := result.Int64s()
|
||||
for i := 0; i < n; i++ {
|
||||
if result.IsNull(i) {
|
||||
continue
|
||||
}
|
||||
if i64s[i] == 0 {
|
||||
i64s[i] = 1
|
||||
} else {
|
||||
i64s[i] = 0
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *builtinDecimalIsNullSig) vectorized() bool {
|
||||
|
||||
@ -34,7 +34,11 @@ var vecBuiltinOpCases = map[string][]vecExprBenchCase{
|
||||
ast.LogicAnd: {
|
||||
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt, types.ETInt}, geners: makeBinaryLogicOpDataGeners()},
|
||||
},
|
||||
ast.UnaryNot: {},
|
||||
ast.UnaryNot: {
|
||||
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETReal}},
|
||||
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDecimal}},
|
||||
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt}},
|
||||
},
|
||||
ast.UnaryMinus: {},
|
||||
ast.IsNull: {},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user