Skip to content

Commit

Permalink
expression: implement vectorized evaluation for builtinCeilRealSig (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
tsthght authored and sre-bot committed Sep 25, 2019
1 parent b25b703 commit 65d6597
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions expression/builtin_math_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,24 @@ func (b *builtinPowSig) vectorized() bool {
return true
}

func (b *builtinCeilRealSig) vecEvalReal(input *chunk.Chunk, result *chunk.Column) error {
if err := b.args[0].VecEvalReal(b.ctx, input, result); err != nil {
return err
}
f64s := result.Float64s()
for i := 0; i < len(f64s); i++ {
if result.IsNull(i) {
continue
}
f64s[i] = math.Ceil(f64s[i])
}
return nil
}

func (b *builtinCeilRealSig) vectorized() bool {
return true
}

func (b *builtinRoundRealSig) vecEvalReal(input *chunk.Chunk, result *chunk.Column) error {
if err := b.args[0].VecEvalReal(b.ctx, input, result); err != nil {
return err
Expand Down
3 changes: 3 additions & 0 deletions expression/builtin_math_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ var vecBuiltinMathCases = map[string][]vecExprBenchCase{
ast.Pow: {
{retEvalType: types.ETReal, childrenTypes: []types.EvalType{types.ETReal, types.ETReal}, geners: []dataGenerator{&rangeRealGener{0, 10, 0.5}, &rangeRealGener{0, 100, 0.5}}},
},
ast.Ceil: {
{retEvalType: types.ETReal, childrenTypes: []types.EvalType{types.ETReal}, geners: nil},
},
ast.Truncate: {
{retEvalType: types.ETReal, childrenTypes: []types.EvalType{types.ETReal, types.ETInt}, geners: []dataGenerator{nil, &rangeInt64Gener{-10, 10}}},
},
Expand Down

0 comments on commit 65d6597

Please sign in to comment.