expression: implement vectorized evaluation for 'builtinCastJSONAsStringSig' (#12542)

This commit is contained in:
tsthght
2019-10-08 16:34:41 +08:00
committed by Yuanjia Zhang
parent 2865b81244
commit ebaa8a7204
2 changed files with 21 additions and 2 deletions

View File

@ -456,11 +456,29 @@ func (b *builtinCastJSONAsJSONSig) vecEvalJSON(input *chunk.Chunk, result *chunk
}
func (b *builtinCastJSONAsStringSig) vectorized() bool {
return false
return true
}
func (b *builtinCastJSONAsStringSig) vecEvalString(input *chunk.Chunk, result *chunk.Column) error {
return errors.Errorf("not implemented")
n := input.NumRows()
buf, err := b.bufAllocator.get(types.ETJson, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf)
if err := b.args[0].VecEvalJSON(b.ctx, input, buf); err != nil {
return err
}
result.ReserveString(n)
for i := 0; i < n; i++ {
if buf.IsNull(i) {
result.AppendNull()
continue
}
result.AppendString(buf.GetJSON(i).String())
}
return nil
}
func (b *builtinCastDurationAsRealSig) vectorized() bool {

View File

@ -37,6 +37,7 @@ var vecBuiltinCastCases = map[string][]vecExprBenchCase{
},
{retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETInt}},
{retEvalType: types.ETDecimal, childrenTypes: []types.EvalType{types.ETDatetime}},
{retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETJson}},
{retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETDecimal}},
},
}