Skip to content

Commit

Permalink
expression: implement vectorized evaluation for `builtinRealIsFalseSi…
Browse files Browse the repository at this point in the history
…g` (#12527)
  • Loading branch information
liuhao2050 authored and qw4990 committed Oct 8, 2019
1 parent bf10a7a commit be6163c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
24 changes: 22 additions & 2 deletions expression/builtin_op_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,31 @@ func (b *builtinBitAndSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column)
}

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

func (b *builtinRealIsFalseSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) error {
return errors.Errorf("not implemented")
numRows := input.NumRows()
buf, err := b.bufAllocator.get(types.ETReal, numRows)
if err != nil {
return err
}
defer b.bufAllocator.put(buf)
if err := b.args[0].VecEvalReal(b.ctx, input, buf); err != nil {
return err
}

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

func (b *builtinUnaryMinusIntSig) vectorized() bool {
Expand Down
1 change: 1 addition & 0 deletions expression/builtin_op_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var vecBuiltinOpCases = map[string][]vecExprBenchCase{
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDecimal}, geners: []dataGenerator{&defaultGener{0.2, types.ETDecimal}}},
},
ast.IsFalsity: {
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETReal}},
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDecimal}},
},
ast.LogicOr: {
Expand Down

0 comments on commit be6163c

Please sign in to comment.