Skip to content

Commit

Permalink
expression: implement vectorized evaluation for 'builtinBitXorSig' (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
k-ye authored and qw4990 committed Oct 18, 2019
1 parent 0aaa277 commit 8011454
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
22 changes: 20 additions & 2 deletions expression/builtin_op_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,29 @@ func (b *builtinLogicAndSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column
}

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

func (b *builtinBitXorSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) error {
return errors.Errorf("not implemented")
if err := b.args[0].VecEvalInt(b.ctx, input, result); err != nil {
return err
}
numRows := input.NumRows()
buf, err := b.bufAllocator.get(types.ETInt, numRows)
if err != nil {
return err
}
defer b.bufAllocator.put(buf)
if err := b.args[1].VecEvalInt(b.ctx, input, buf); err != nil {
return err
}
arg0s := result.Int64s()
arg1s := buf.Int64s()
result.MergeNulls(buf)
for i := 0; i < numRows; i++ {
arg0s[i] ^= arg1s[i]
}
return nil
}

func (b *builtinLogicXorSig) vectorized() bool {
Expand Down
5 changes: 4 additions & 1 deletion expression/builtin_op_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ var vecBuiltinOpCases = map[string][]vecExprBenchCase{
ast.LogicXor: {
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt, types.ETInt}, geners: makeBinaryLogicOpDataGeners()},
},
ast.Xor: {},
ast.Xor: {
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt, types.ETInt}, geners: makeBinaryLogicOpDataGeners()},
},
ast.LogicAnd: {
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt, types.ETInt}, geners: makeBinaryLogicOpDataGeners()},
},
Expand Down Expand Up @@ -97,6 +99,7 @@ func makeGivenValsOrDefaultGener(vals []interface{}, eType types.EvalType) *give
}

func makeBinaryLogicOpDataGeners() []dataGenerator {
// TODO: rename this to makeBinaryOpDataGenerator, since the BIT ops are also using it?
pairs := [][]interface{}{
{nil, nil},
{0, nil},
Expand Down

0 comments on commit 8011454

Please sign in to comment.