-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
planner: integrate hashEqual interface into LogicalPlan and expression.Expression. #55652
planner: integrate hashEqual interface into LogicalPlan and expression.Expression. #55652
Conversation
Signed-off-by: arenatlx <[email protected]>
Hi @AilinKid. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
// *************************** start implementation of Plan interface *************************** | ||
// *************************** start implementation of HashEquals interface **************************** | ||
|
||
func (p *LogicalProjection) Hash64(h mutil.Hasher) { |
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.
just a future example
Signed-off-by: arenatlx <[email protected]>
Signed-off-by: arenatlx <[email protected]>
Signed-off-by: arenatlx <[email protected]>
Signed-off-by: arenatlx <[email protected]>
Signed-off-by: arenatlx <[email protected]>
Signed-off-by: arenatlx <[email protected]>
Signed-off-by: arenatlx <[email protected]>
Signed-off-by: arenatlx <[email protected]>
Signed-off-by: arenatlx <[email protected]>
Signed-off-by: arenatlx <[email protected]>
Signed-off-by: arenatlx <[email protected]>
} | ||
// todo: LogicalSchemaProducer should implement HashEquals interface, otherwise, its self elements | ||
// like schema and names are lost. | ||
if !p.LogicalSchemaProducer.Equals(&proj.BaseLogicalPlan) { |
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.
Have you ever implemented the equals function of LogicalSchemaProducer ?
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.
currently not, this is is just a example and reminder for next few pull requests.
Signed-off-by: arenatlx <[email protected]>
Signed-off-by: AilinKid <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #55652 +/- ##
================================================
+ Coverage 72.9612% 74.5166% +1.5554%
================================================
Files 1581 1585 +4
Lines 442690 444031 +1341
================================================
+ Hits 322992 330877 +7885
+ Misses 99873 92859 -7014
- Partials 19825 20295 +470
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Signed-off-by: arenatlx <[email protected]>
Signed-off-by: arenatlx <[email protected]>
if !p.LogicalSchemaProducer.Equals(&proj.BaseLogicalPlan) { | ||
return false | ||
} | ||
//for i, one := range p.Exprs { |
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.
Can we remove it?
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.
no, next pull request will introduce hashEqual to expression.Expression, which will enable the comment line here.
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.
OK
Signed-off-by: arenatlx <[email protected]>
Signed-off-by: arenatlx <[email protected]>
Makefile
Outdated
@@ -372,6 +372,7 @@ bench-daily: | |||
go test github.com/pingcap/tidb/pkg/util/codec -run TestBenchDaily -bench Ignore --outfile bench_daily.json | |||
go test github.com/pingcap/tidb/pkg/distsql -run TestBenchDaily -bench Ignore --outfile bench_daily.json | |||
go test github.com/pingcap/tidb/pkg/statistics -run TestBenchDaily -bench Ignore --outfile bench_daily.json | |||
go test github.com/pingcap/tidb/pkg/planner/cascades/base -run TestBenchDaily -bench Ignore --outfile bench_daily.json |
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.
Maybe we need to remove this bench test
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.
make sense, done
Signed-off-by: arenatlx <[email protected]>
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.
LGTM
Signed-off-by: arenatlx <[email protected]>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: elsa0520, hawkingrei The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
What problem does this PR solve?
Issue Number: ref #51664
Problem Summary:
What changed and how does it work?
in the #55570 we introduced a new kind of HashEqual interface, for simplest hash uint64 digest from some primitive types.
And this kind of interface should be implemented by logicalPlan and expression.Expression to quick hash themselves and to compare the same type structure if they are equivalent.
The first thing came into my mind is that, we should let comprehensive LogicalPlan interface and expression.Expression go include this small trait, why i find it will cause too much change for interface's original implementation. Because it's a generic interface, when it is integrated in: it will make this two to be generic
which will cause all the place that referred to this two big interface to be redefined as xxx[any] as well. it's not that clean work. So we think about a way to define two new interface as:
the logical expression that will be used in memo, we will referred them as LogicalOperator, which kept all the elements that LogicalExpression has while requiring HashEquals implementations on it. With that we don't need to do much change about current implementation function, only adding these two addition functional is enough.
Finally, after discussion, we derive a solution like below, getting rid of generic and use any instead.
And we did a benchmark for this, the any usage seem adequate: https://github.com/pingcap/tidb/pull/55652/files#diff-ef9b611a397bd5133fb3b00e5fca906beee78179821ee20a308e22110ead85aeR93
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.