Skip to content

Commit

Permalink
Merge branch 'prev_commit_err' of github.com:jackysp/tidb into prev_c…
Browse files Browse the repository at this point in the history
…ommit_err
  • Loading branch information
jackysp committed Sep 16, 2019
2 parents eb0567f + ab1aa12 commit 0e0422b
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 @@ -40,3 +40,25 @@ func (b *builtinLog10Sig) vecEvalReal(input *chunk.Chunk, result *chunk.Column)
func (b *builtinLog10Sig) vectorized() bool {
return true
}

func (b *builtinSqrtSig) 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
}
if f64s[i] < 0 {
result.SetNull(i, true)
} else {
f64s[i] = math.Sqrt(f64s[i])
}
}
return nil
}

func (b *builtinSqrtSig) 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 @@ -25,6 +25,9 @@ var vecBuiltinMathCases = map[string][]vecExprBenchCase{
ast.Log10: {
{types.ETReal, []types.EvalType{types.ETReal}, nil},
},
ast.Sqrt: {
{types.ETReal, []types.EvalType{types.ETReal}, nil},
},
}

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

0 comments on commit 0e0422b

Please sign in to comment.