-
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: add mutable and immutable ft implementation #51916
Conversation
Signed-off-by: AilinKid <[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/test-infra repository. |
Signed-off-by: AilinKid <[email protected]>
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #51916 +/- ##
=================================================
- Coverage 70.7202% 54.8500% -15.8703%
=================================================
Files 1477 1590 +113
Lines 438443 612543 +174100
=================================================
+ Hits 310068 335980 +25912
- Misses 108950 253266 +144316
- Partials 19425 23297 +3872
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Signed-off-by: AilinKid <[email protected]>
Signed-off-by: AilinKid <[email protected]>
Signed-off-by: AilinKid <[email protected]>
Signed-off-by: AilinKid <[email protected]>
/test check-dev2 |
@AilinKid: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
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/test-infra repository. |
/ok-to-test |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: hawkingrei The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
/retest |
After discussion with the team, the current TiDB implementation is bottlenecked with the mutable reference-related problem, like the current *ft pointer stored in multiple operators(kind of sharing), one changed, and the other is unaware of, thus causing some data and field type miss matching panic at runtime. Even after this exploration, the multi-reference to the same mutable reference(or from x-casted) also existed, so nothing meaningful. We don't deal with too many language-related problems, here is related to mutable implementation in Golang, being safe is only guaranteed with ref-count. Otherwise, caution with coding is the responsibility that the owner should take. If you want to explore a perfect solution to mutable ref(ban multi-mut ref), this pull request is not enough; otherwise, from the encapsulation prospect of mutable and immutable usage of the protected core structure, this PR is adequate. So it's a choice problem. |
What problem does this PR solve?
Issue Number: ref #51664
Problem Summary:
What changed and how does it work?
Introduce mutable interface{immutable interface{basic structure}} embedded level
From an inheritance perspective: it goes down like the below:
Holding a mutable pointer, you can get access to all SET methods, and implicit upcast as immutable allows it to get access to all GET methods (just like write lock is a superset of read lock, while with all functionality the latter has)[upcast is no loss, implicit]
Holding an immutable pointer, you can only get access to all GET methods. The only way you can change a thing is to make a mutableRef from the current immutable pointer, we do this with golang.(type) declaration inside, because the basic structure has implemented both of them. [downcast is no loss, explicit]. mutableCopy is another way to make a brand-new copy of itself with mutability.
what's the difference between the interface embedding and structure embedding, the former can use golang.(type) to do no-loss downcast and upcast, while the latter can hardly do that, even with structure pointer embedding, when you hold an internal structure pointer(say immutable here), if you want to convert it into a mutable one(son type), the only way you can do that is to create a new mutable structure again and wrap current parent pointer, actually it costs unsafe.size(8) comparatively to create a mutable structure with pointer-type element inside. It even costs more if additional elements are defined in your mutable structure.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.