Skip to content

Commit

Permalink
expression: implement vectorized evaluation for builtinTanSig (#12238)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklightChen authored and sre-bot committed Sep 18, 2019
1 parent 29a1961 commit 6c0ec62
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 @@ -177,6 +177,24 @@ func (b *builtinCosSig) vectorized() bool {
return true
}

func (b *builtinTanSig) 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.Tan(f64s[i])
}
return nil
}

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

func (b *builtinAbsDecSig) vecEvalDecimal(input *chunk.Chunk, result *chunk.Column) error {
if err := b.args[0].VecEvalDecimal(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 @@ -43,6 +43,9 @@ var vecBuiltinMathCases = map[string][]vecExprBenchCase{
ast.Cos: {
{types.ETReal, []types.EvalType{types.ETReal}, nil},
},
ast.Tan: {
{types.ETReal, []types.EvalType{types.ETReal}, nil},
},
ast.Abs: {
{types.ETDecimal, []types.EvalType{types.ETDecimal}, nil},
},
Expand Down

0 comments on commit 6c0ec62

Please sign in to comment.