Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expression: support member of function #39880

Merged
merged 8 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
vectorized support
  • Loading branch information
xiongjiwei committed Dec 14, 2022
commit c934fada82eb187ee6e98e6432c8d24389e1ffc6
2 changes: 1 addition & 1 deletion executor/showtest/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,7 @@ func TestShowBuiltin(t *testing.T) {
res := tk.MustQuery("show builtins;")
require.NotNil(t, res)
rows := res.Rows()
const builtinFuncNum = 284
const builtinFuncNum = 285
require.Equal(t, builtinFuncNum, len(rows))
require.Equal(t, rows[0][0].(string), "abs")
require.Equal(t, rows[builtinFuncNum-1][0].(string), "yearweek")
Expand Down
53 changes: 53 additions & 0 deletions expression/builtin_json_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,59 @@ func (b *builtinJSONArraySig) vecEvalJSON(input *chunk.Chunk, result *chunk.Colu
return nil
}

func (b *builtinJSONMemberOfSig) vectorized() bool {
return true
}

func (b *builtinJSONMemberOfSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) error {
nr := input.NumRows()

targetCol, err := b.bufAllocator.get()
if err != nil {
return err
}
defer b.bufAllocator.put(targetCol)

if err := b.args[0].VecEvalJSON(b.ctx, input, targetCol); err != nil {
return err
}

objCol, err := b.bufAllocator.get()
if err != nil {
return err
}
defer b.bufAllocator.put(objCol)

if err := b.args[1].VecEvalJSON(b.ctx, input, objCol); err != nil {
return err
}

result.ResizeInt64(nr, false)
resI64s := result.Int64s()

result.MergeNulls(targetCol, objCol)
for i := 0; i < nr; i++ {
if result.IsNull(i) {
continue
}
obj := objCol.GetJSON(i)
target := targetCol.GetJSON(i)
if obj.TypeCode != types.JSONTypeCodeArray {
resI64s[i] = boolToInt64(types.CompareBinaryJSON(obj, target) == 0)
} else {
elemCount := obj.GetElemCount()
for j := 0; j < elemCount; j++ {
if types.CompareBinaryJSON(obj.ArrayGetElem(j), target) == 0 {
resI64s[i] = 1
break
}
}
}
}

return nil
}

func (b *builtinJSONContainsSig) vectorized() bool {
return true
}
Expand Down