-
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 core pkg de-coupling and make it well organized #52714
Labels
Comments
This was referenced Apr 18, 2024
13 tasks
13 tasks
13 tasks
13 tasks
13 tasks
3AceShowHand
pushed a commit
to 3AceShowHand/tidb
that referenced
this issue
May 7, 2024
3AceShowHand
pushed a commit
to 3AceShowHand/tidb
that referenced
this issue
May 7, 2024
13 tasks
13 tasks
13 tasks
13 tasks
13 tasks
13 tasks
hawkingrei
pushed a commit
to hawkingrei/tidb
that referenced
this issue
Aug 8, 2024
hawkingrei
pushed a commit
to hawkingrei/tidb
that referenced
this issue
Aug 8, 2024
This was referenced Aug 12, 2024
13 tasks
This was referenced Aug 15, 2024
13 tasks
13 tasks
Closed
13 tasks
Merged
13 tasks
13 tasks
13 tasks
13 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Enhancement
Refactoring
The current
plan/core
pkg is quite huge not as slim as we expected. The hybrid placement of logicalOp, physicalOp, property, task, logical-rewrite, build-phase, binder, cost, exhaustion, etc makes the hierarchy complicated. The boundary of them is also not as clear as we desired. I concluded that there is some reason for this phenomenon.One is if Golang's structure wants to implement member functions with itself as a receiver, including the interface implementation, which can only be defined in the same pkg where the structure is defined. (here clearly the pkg is
core
) stackoverflow refLogicalSort
is defined in core pkg somewhere. If you want to implement (p *LogicalSort) buildKeyInfo for the sake of interface implementation or just member function of them, this implementation can only be done in the samecore
pkg, because Golang only allows local type as a receiver. Given buildKeyInfo is logical-rewrite-related code, it should be put into another part/component/pkg of core logic for clarity, that calls for the interface simplification or elimination of self-receiver's function.Numerous utility and facility functions related to the core logic are defined and used in the
core
package. These include trace, hashcode, cost mode, selectivity, task, enumeration, and more. Moving or adding a new feature outside thecore
package may result in many internal structures or functions being exported out as well.The biggest block is the import cycle problem. Say we create a new pkg called core2 and we want to add a new feature inside. The new feature couldn't work well without the current core context support, so by some means (exported original
core
structure or interface, using function pointer or something), we got a dependency fromcore2
->core
. However, this feature must also be called fromcore
, causecore
is a current unified portal for the entire optimization phase, so we got a dependency fromcore
->core2
. As a result, hops, golang's import cycle is formed. The final solution to the problem is Back to integrate them all. Eventually, the core pkg becomes larger and larger.current core pkg should be arranged as:
Tips about resolving import cycle
A
depends onX
, andB
depends onX
, while currentX
is defined in file ofA
orB
.X
logic out as util usageA
depends on pkgB
's function, and pkgB
systematically depends onA
. eg:executor
depends onplanner
is reasonable, while ifplanner
dependsexecutor
's function for some tricky handling. This is not will designed.executor
pkg's init function, init(){ planner.Fxxx = Fxx in executor}Process
The text was updated successfully, but these errors were encountered: