Skip to content

Commit

Permalink
fix builtinJSONObjectSig
Browse files Browse the repository at this point in the history
  • Loading branch information
js00070 committed Oct 14, 2019
1 parent d8d56d6 commit 714b892
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions expression/builtin_json_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package expression
import (
"github.com/pingcap/errors"
"github.com/pingcap/parser/ast"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/types/json"
"github.com/pingcap/tidb/util/chunk"
)
Expand Down Expand Up @@ -108,11 +109,38 @@ func (b *builtinJSONObjectSig) vecEvalJSON(input *chunk.Chunk, result *chunk.Col
jsons[i] = make(map[string]interface{}, len(b.args)>>1)
}

argBuffers := make([]*chunk.Column, len(b.args))
var err error
for i := 0; i < len(b.args); i++ {
if i&1 == 0 {
argBuffers[i], err = b.bufAllocator.get(types.ETString, nr)
if err != nil {
return err
}
if err := b.args[i].VecEvalString(b.ctx, input, argBuffers[i]); err != nil {
return err
}
} else {
argBuffers[i], err = b.bufAllocator.get(types.ETJson, nr)
if err != nil {
return err
}
if err := b.args[i].VecEvalJSON(b.ctx, input, argBuffers[i]); err != nil {
return err
}
}
}
defer func() {
for i := 0; i < len(argBuffers); i++ {
b.bufAllocator.put(argBuffers[i])
}
}()

result.ReserveJSON(nr)
for i := 0; i < len(b.args); i++ {
if i&1 == 1 {
keyCol := input.Column(i - 1)
valueCol := input.Column(i)
keyCol := argBuffers[i-1]
valueCol := argBuffers[i]

var key string
var value json.BinaryJSON
Expand Down

0 comments on commit 714b892

Please sign in to comment.