-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
support pushing bitwise operators and LogicXor down to kv #1846
Conversation
…h_bit_ops_down Conflicts: plan/expr_to_pb.go �:q!
I split eval.go into five small files to classify different type of operators. |
ca90c6a
to
fddb483
Compare
if expr.GetTp() == tipb.ExprType_BitNeg { | ||
var result types.Datum | ||
if len(expr.Children) != 1 { | ||
err := ErrInvalid.Gen("need 2 operands but got %d", len(expr.Children)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need 1 operand ...
|
||
func (e *Evaluator) evalIn(expr *tipb.Expr) (types.Datum, error) { | ||
if len(expr.Children) != 2 { | ||
return types.Datum{}, ErrInvalid.Gen("IN need 2 operand, got %d", len(expr.Children)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
operand -> operands
return | ||
} | ||
|
||
// if any is not integer, we round the operands and then use uint64 to calculate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If either...
dde3894
to
561ad6d
Compare
@@ -395,3 +395,207 @@ func ComputeIntDiv(a, b Datum) (d Datum, err error) { | |||
d.SetInt64(iVal) | |||
return d, nil | |||
} | |||
|
|||
// decimal2RoundUint convert a MyDecimal to a uint64 after rounding. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a uint64 -> an uint64
return | ||
} | ||
|
||
// if either is not integer, we round the operands and then use uint64 to calculate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change all if to If
return d, nil | ||
} | ||
|
||
// ComputeLeftShift computes the result of a >> b. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a useless blank in a >> b
if expr.GetTp() == tipb.ExprType_BitNeg { | ||
var result types.Datum | ||
if len(expr.Children) != 1 { | ||
err := ErrInvalid.Gen("need 1 operands but got %d", len(expr.Children)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 operand not operands
rest LGTM |
return e.evalNot(expr) | ||
case tipb.ExprType_In: | ||
return e.evalIn(expr) | ||
// data type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/data/Data or remove .
The same as line57, line62, line65, line69 and the same as some comments in plan_test.go
PTAL |
I'll rewrite this PR after another PRs have been merged. |
…h_bit_ops_down Conflicts: distsql/xeval/eval.go distsql/xeval/eval_compare_ops.go distsql/xeval/eval_logic_ops.go plan/expr_to_pb.go `:q! �:q!
0597580
to
a547d0d
Compare
PTAL @hanfei1991 @coocood @shenli @zimulala @tiancaiamao |
if expr.GetTp() == tipb.ExprType_BitNeg { | ||
var result types.Datum | ||
if len(expr.Children) != 1 { | ||
err := ErrInvalid.Gen("need 1 operand but got %d", len(expr.Children)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add operator name in the error message.
@hanfei1991 PTAL |
3a1d2de
to
5f8ee14
Compare
LGTM |
@coocood PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM
} | ||
return types.ComputeBitNeg(a) | ||
} | ||
var result types.Datum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to the beginning and remove line 24.
return | ||
} | ||
// If either is not integer, we round the operands and then use uint64 to calculate. | ||
x, err := a.ToDecimal() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a function to replace the following code block, then we could save a lot of works in ComputeXXX.
…h_bit_ops_down Conflicts: distsql/xeval/eval.go plan/expr_to_pb.go �:q!
PTAL @shenli |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM
return d, errors.Trace(err) | ||
} | ||
|
||
y, err := b.ToDecimal() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use convertNonInt2RoundUint64 instead.
return d, errors.Trace(err) | ||
} | ||
|
||
uintX, err := decimal2RoundUint(x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convertNonInt2RoundUint64
@shenli PTAL |
LGTM |
This commit
PTAL @hanfei1991 @coocood @shenli @zimulala @tiancaiamao