Skip to content

Commit

Permalink
expression: implement vectorized evaluation for builtinLeastIntSig (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
tangwz committed Sep 19, 2019
1 parent f9724db commit 1fee457
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions expression/builtin_compare_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,38 @@ func (b *builtinLeastDecimalSig) vecEvalDecimal(input *chunk.Chunk, result *chun
func (b *builtinLeastDecimalSig) vectorized() bool {
return true
}

func (b *builtinLeastIntSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) error {
n := input.NumRows()
buf, err := b.bufAllocator.get(types.ETInt, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf)
if err := b.args[0].VecEvalInt(b.ctx, input, result); err != nil {
return err
}

i64s := result.Int64s()
for j := 1; j < len(b.args); j++ {
if err := b.args[j].VecEvalInt(b.ctx, input, buf); err != nil {
return err
}

result.MergeNulls(buf)
for i := 0; i < n; i++ {
if result.IsNull(i) {
continue
}
v := buf.GetInt64(i)
if v < i64s[i] {
i64s[i] = v
}
}
}
return nil
}

func (b *builtinLeastIntSig) vectorized() bool {
return true
}
1 change: 1 addition & 0 deletions expression/builtin_compare_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var vecBuiltinCompareCases = map[string][]vecExprBenchCase{
},
ast.Least: {
{types.ETDecimal, []types.EvalType{types.ETDecimal, types.ETDecimal, types.ETDecimal}, nil},
{types.ETInt, []types.EvalType{types.ETInt, types.ETInt, types.ETInt}, nil},
},
}

Expand Down

0 comments on commit 1fee457

Please sign in to comment.