Skip to content

Commit

Permalink
expression: Optimize builtinArithmeticModRealSig and builtinGreatestD…
Browse files Browse the repository at this point in the history
…ecimalSig using MergeNull method (#22418)

* optimize with mergenulls

* optimize with mergenulls

* remove unnecessary import

Co-authored-by: ti-srebot <[email protected]>
  • Loading branch information
Tjianke and ti-srebot authored Feb 22, 2021
1 parent 49f3e29 commit 50607db
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
5 changes: 1 addition & 4 deletions expression/builtin_arithmetic_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,11 @@ func (b *builtinArithmeticModRealSig) vecEvalReal(input *chunk.Chunk, result *ch
if err := b.args[0].VecEvalReal(b.ctx, input, result); err != nil {
return err
}
result.MergeNulls(buf)
x := result.Float64s()
y := buf.Float64s()
for i := 0; i < n; i++ {
if buf.IsNull(i) {
result.SetNull(i, true)
continue
}
if y[i] == 0 {
Expand All @@ -529,9 +529,6 @@ func (b *builtinArithmeticModRealSig) vecEvalReal(input *chunk.Chunk, result *ch
result.SetNull(i, true)
continue
}
if result.IsNull(i) {
continue
}

x[i] = math.Mod(x[i], y[i])
}
Expand Down
4 changes: 1 addition & 3 deletions expression/builtin_compare_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ func (b *builtinGreatestDecimalSig) vecEvalDecimal(input *chunk.Chunk, result *c
if err := b.args[j].VecEvalDecimal(b.ctx, input, buf); err != nil {
return err
}
result.MergeNulls(buf)
for i := 0; i < n; i++ {
if result.IsNull(i) {
continue
} else if buf.IsNull(i) {
result.SetNull(i, true)
continue
}
v := buf.GetDecimal(i)
if v.Compare(&d64s[i]) > 0 {
Expand Down

0 comments on commit 50607db

Please sign in to comment.