Skip to content

Commit

Permalink
expression: implement vectorization for builtinGreatestRealSig (#12399)
Browse files Browse the repository at this point in the history
  • Loading branch information
PiotrNewt authored and sre-bot committed Sep 26, 2019
1 parent fbcee67 commit dab72fb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
31 changes: 29 additions & 2 deletions expression/builtin_compare_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,11 +602,38 @@ func (b *builtinEQRealSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column)
}

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

func (b *builtinGreatestRealSig) vecEvalReal(input *chunk.Chunk, result *chunk.Column) error {
return errors.Errorf("not implemented")
n := input.NumRows()
buf, err := b.bufAllocator.get(types.ETReal, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf)
if err := b.args[0].VecEvalReal(b.ctx, input, result); err != nil {
return err
}

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

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

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

0 comments on commit dab72fb

Please sign in to comment.