Skip to content

Commit

Permalink
Revert "expression: implement vectorized evaluation for `builtinCastS…
Browse files Browse the repository at this point in the history
…tringAsRealSig` (#13445)" (#13543)
  • Loading branch information
breezewish authored and qw4990 committed Nov 18, 2019
1 parent 381e745 commit 839ea6f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 58 deletions.
13 changes: 0 additions & 13 deletions expression/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,19 +406,6 @@ func (g *numStrGener) gen() interface{} {
return fmt.Sprintf("%v", g.rangeInt64Gener.gen())
}

// realStrGener is used to generate real number strings.
type realStrGener struct {
rangeRealGener
}

func (g *realStrGener) gen() interface{} {
val := g.rangeRealGener.gen()
if val == nil {
return nil
}
return fmt.Sprintf("%v", val)
}

// ipv6StrGener is used to generate ipv6 strings.
type ipv6StrGener struct {
}
Expand Down
40 changes: 2 additions & 38 deletions expression/builtin_cast_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -1240,47 +1240,11 @@ func (b *builtinCastJSONAsDecimalSig) vecEvalDecimal(input *chunk.Chunk, result
}

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

func (b *builtinCastStringAsRealSig) vecEvalReal(input *chunk.Chunk, result *chunk.Column) error {
if IsBinaryLiteral(b.args[0]) {
// This block is skipped by `castAsRealFunctionClass.getFunction()`
return b.args[0].VecEvalReal(b.ctx, input, result)
}

n := input.NumRows()
bufStrings, err := b.bufAllocator.get(types.ETString, n)
if err != nil {
return err
}
defer b.bufAllocator.put(bufStrings)
if err := b.args[0].VecEvalString(b.ctx, input, bufStrings); err != nil {
return err
}

result.ResizeFloat64(n, false)
result.MergeNulls(bufStrings)
f64s := result.Float64s()
sc := b.ctx.GetSessionVars().StmtCtx
for i := 0; i < n; i++ {
if result.IsNull(i) {
continue
}
val := bufStrings.GetString(i)
res, err := types.StrToFloat(sc, val)
if err != nil {
return err
}
if b.inUnion && mysql.HasUnsignedFlag(b.tp.Flag) && res < 0 {
res = 0
}
if res, err = types.ProduceFloatWithSpecifiedTp(res, b.tp, sc); err != nil {
return err
}
f64s[i] = res
}
return nil
return errors.Errorf("not implemented")
}

func (b *builtinCastStringAsDecimalSig) vectorized() bool {
Expand Down
7 changes: 0 additions & 7 deletions expression/builtin_cast_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (

. "github.com/pingcap/check"
"github.com/pingcap/parser/ast"
"github.com/pingcap/parser/mysql"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/types/json"
)
Expand All @@ -39,12 +38,6 @@ var vecBuiltinCastCases = map[string][]vecExprBenchCase{
{retEvalType: types.ETReal, childrenTypes: []types.EvalType{types.ETJson}},
{retEvalType: types.ETReal, childrenTypes: []types.EvalType{types.ETDecimal}},
{retEvalType: types.ETReal, childrenTypes: []types.EvalType{types.ETDatetime}},
{retEvalType: types.ETReal, childrenTypes: []types.EvalType{types.ETString},
geners: []dataGenerator{&realStrGener{rangeRealGener{begin: -100000.0, end: 100000.0, nullRation: 0.5}}},
},
{retEvalType: types.ETReal, childrenTypes: []types.EvalType{types.ETString},
constants: []*Constant{{Value: types.NewBinaryLiteralDatum([]byte("TiDB")), RetType: types.NewFieldType(mysql.TypeVarString)}},
},
{retEvalType: types.ETDuration, childrenTypes: []types.EvalType{types.ETDatetime},
geners: []dataGenerator{&dateTimeGenerWithFsp{
defaultGener: defaultGener{nullRation: 0.2, eType: types.ETDatetime},
Expand Down

0 comments on commit 839ea6f

Please sign in to comment.