Skip to content

Commit

Permalink
expression: implement vectorized evaluation for builtinPI and make …
Browse files Browse the repository at this point in the history
…testing framework support functions without input arguments (pingcap#12620)
  • Loading branch information
qw4990 authored and sre-bot committed Oct 11, 2019
1 parent 5e85812 commit cf06460
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions expression/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,9 @@ func genVecBuiltinFuncBenchCase(ctx sessionctx.Context, funcName string, testCas
fillColumn(eType, input, i, testCase)
cols[i] = &Column{Index: i, RetType: fts[i]}
}
if len(cols) == 0 {
input.SetNumVirtualRows(1024)
}

var err error
if funcName == ast.Cast {
Expand Down
10 changes: 8 additions & 2 deletions expression/builtin_math_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,11 +665,17 @@ func (b *builtinCRC32Sig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) e
}

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

func (b *builtinPISig) vecEvalReal(input *chunk.Chunk, result *chunk.Column) error {
return errors.Errorf("not implemented")
n := input.NumRows()
result.ResizeFloat64(n, false)
f64s := result.Float64s()
for i := range f64s {
f64s[i] = math.Pi
}
return nil
}

func (b *builtinRandSig) vectorized() bool {
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 @@ -99,6 +99,9 @@ var vecBuiltinMathCases = map[string][]vecExprBenchCase{
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt}, childrenFieldTypes: []*types.FieldType{{Tp: mysql.TypeInt24}}, geners: nil},
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDecimal}, geners: nil},
},
ast.PI: {
{retEvalType: types.ETReal},
},
ast.Truncate: {
{retEvalType: types.ETReal, childrenTypes: []types.EvalType{types.ETReal, types.ETInt}, geners: []dataGenerator{nil, &rangeInt64Gener{-10, 10}}},
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt, types.ETInt}, geners: []dataGenerator{nil, &rangeInt64Gener{-10, 10}}},
Expand Down

0 comments on commit cf06460

Please sign in to comment.