Skip to content

Commit

Permalink
expression: implement vectorized evaluation for builtinRoundDecSig (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
FateTHarlaown authored and sre-bot committed Sep 17, 2019
1 parent c5cad51 commit 5f6b22c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
22 changes: 22 additions & 0 deletions expression/builtin_math_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,25 @@ func (b *builtinAbsDecSig) vecEvalDecimal(input *chunk.Chunk, result *chunk.Colu
func (b *builtinAbsDecSig) vectorized() bool {
return true
}

func (b *builtinRoundDecSig) vecEvalDecimal(input *chunk.Chunk, result *chunk.Column) error {
if err := b.args[0].VecEvalDecimal(b.ctx, input, result); err != nil {
return err
}
d64s := result.Decimals()
buf := new(types.MyDecimal)
for i := 0; i < len(d64s); i++ {
if result.IsNull(i) {
continue
}
if err := d64s[i].Round(buf, 0, types.ModeHalfEven); err != nil {
return err
}
d64s[i] = *buf
}
return nil
}

func (b *builtinRoundDecSig) vectorized() bool {
return true
}
3 changes: 3 additions & 0 deletions expression/builtin_math_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ var vecBuiltinMathCases = map[string][]vecExprBenchCase{
ast.Abs: {
{types.ETDecimal, []types.EvalType{types.ETDecimal}, nil},
},
ast.Round: {
{types.ETDecimal, []types.EvalType{types.ETDecimal}, nil},
},
}

func (s *testEvaluatorSuite) TestVectorizedBuiltinMathEvalOneVec(c *C) {
Expand Down

0 comments on commit 5f6b22c

Please sign in to comment.