Skip to content

Commit

Permalink
expression: implement vectorized evaluation for builtinDurationIsNull…
Browse files Browse the repository at this point in the history
…Sig (#12523)
  • Loading branch information
tangwz authored and sre-bot committed Oct 8, 2019
1 parent 4d92371 commit efd51d7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
24 changes: 22 additions & 2 deletions expression/builtin_op_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,29 @@ func (b *builtinIntIsTrueSig) vecEvalInt(input *chunk.Chunk, result *chunk.Colum
}

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

func (b *builtinDurationIsNullSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) error {
return errors.Errorf("not implemented")
numRows := input.NumRows()
buf, err := b.bufAllocator.get(types.ETDuration, numRows)
if err != nil {
return err
}
defer b.bufAllocator.put(buf)

if err := b.args[0].VecEvalDuration(b.ctx, input, buf); err != nil {
return err
}

result.ResizeInt64(numRows, false)
i64s := result.Int64s()
for i := 0; i < numRows; i++ {
if buf.IsNull(i) {
i64s[i] = 1
} else {
i64s[i] = 0
}
}
return nil
}
4 changes: 3 additions & 1 deletion expression/builtin_op_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ var vecBuiltinOpCases = map[string][]vecExprBenchCase{
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt}},
},
ast.UnaryMinus: {},
ast.IsNull: {},
ast.IsNull: {
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDuration}},
},
}

// givenValsGener returns the items sequentially from the slice given at
Expand Down

0 comments on commit efd51d7

Please sign in to comment.