-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Refactor PlanFragmenter to make the logic more clear #11912
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
Refactor PlanFragmenter to make the logic more clear #11912
Conversation
Codecov Report
@@ Coverage Diff @@
## master #11912 +/- ##
============================================
- Coverage 61.50% 61.45% -0.06%
Complexity 1147 1147
============================================
Files 2378 2378
Lines 128844 128845 +1
Branches 19925 19924 -1
============================================
- Hits 79242 79178 -64
- Misses 43858 43945 +87
+ Partials 5744 5722 -22
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 26 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
| // Split the ExchangeNode to a MailboxReceiveNode and a MailboxSendNode, where MailboxReceiveNode is the leave node | ||
| // of the current PlanFragment, and MailboxSendNode is the root node of the next PlanFragment. | ||
| int receiverPlanFragmentId = context._currentPlanFragmentId; | ||
| int senderPlanFragmentId = context._nextPlanFragmentId.getAndIncrement(); |
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.
nit: visitor pattern is single threaded so i dont think we need to have atomic integer here.
this "getAndIncrement" is still confusing --> if we are handling one context per visit upon hitting an exchange then this is the only variable that's cross all fragments: IIUC, the only reason this works is b/c the nextPlanFragmentId is passed by reference so it is not really contain within the context?
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.
Modified to MutableInt to avoid confusion.
IMO this is the correct way to handle this recursion. Basically we share _nextPlanFragmentId across all PlanFragments to ensure uniqueness of PlanFragment ID. Added a comment to explain this
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.
yes i think that's correct. i was wondering if we can make it even more straightforward.
- IMO the "context" is pre-fragment
- but the global next ID is per planFragmenter --> we can create a global next ID tracker inside the planFragmenter instead (ditch the static INSTANCE approach)
WDYT?
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.
Good point, refactored again
| final Map<Integer, PlanFragment> _planFragmentIdToRootNodeMap; | ||
| final Map<Integer, List<Integer>> _planFragmentIdToChildrenMap; | ||
|
|
||
| public Context() { |
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.
why do we need this public constructor? no one is using it right?
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.
It is used in PinotLogicalQueryPlanner to create the initial Context
Creates a new
Contextfor eachPlanFragmenterto avoid the convoluted logic.