Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
|
@copilot |
|
@lgbo-ustc I've opened a new pull request, #23, to work on those changes. Once the pull request is ready, I'll request review from you. |
There was a problem hiding this comment.
Pull request overview
This PR refactors the StatefulPlanner::plan method by replacing static methods with instance methods and introducing a more modular transformation architecture. The changes improve code organization by extracting node-specific transformation logic into dedicated methods.
Changes:
- Converted
StatefulPlannerfrom a collection of static utility functions into a class with instance methods that hold context - Extracted operator transformation logic into separate methods per operator type (e.g.,
transformWatermarkAssignerOperator,transformStreamJoinOperator) - Removed unused includes and consolidated operator ID generation into a single static function
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| velox/experimental/stateful/StatefulPlanner.h | Updated class to have instance methods and member variables, added protected constructor and private transformation methods |
| velox/experimental/stateful/StatefulPlanner.cpp | Refactored monolithic transformation methods into specialized per-operator-type methods, removed unused includes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| StateBackend* stateBackend); | ||
|
|
||
| protected: | ||
| StatefulPlanner(exec::DriverCtx* ctx, StateBackend* stateBackend) : ctx_(ctx),stateBackend_(stateBackend) {} |
There was a problem hiding this comment.
Missing space after comma in initializer list. Add space after ctx_(ctx), to maintain consistent formatting.
| StatefulPlanner(exec::DriverCtx* ctx, StateBackend* stateBackend) : ctx_(ctx),stateBackend_(stateBackend) {} | |
| StatefulPlanner(exec::DriverCtx* ctx, StateBackend* stateBackend) : ctx_(ctx), stateBackend_(stateBackend) {} |
| aggsHandlerNode, | ||
| std::make_unique<AggsHandleFunction>(), // TODO: not complete yet | ||
| 0, // stateRetentionTime: default to 0 | ||
| aggsHandlerNode->generateUpdateBefore()); |
There was a problem hiding this comment.
The parameter order has changed compared to the removed code. In the old code, generateUpdateBefore() was the 5th parameter and needRetraction() was the 6th. Now a hardcoded 0 appears as the 5th parameter with a comment indicating it's stateRetentionTime. Verify that this change is intentional and that the correct parameters are being passed in the correct order.
| aggsHandlerNode->generateUpdateBefore()); | |
| aggsHandlerNode->generateUpdateBefore(), | |
| aggsHandlerNode->needRetraction()); |
| deduplicateNode->minRetentionTime(), | ||
| deduplicateNode->rowtimeIndex(), |
There was a problem hiding this comment.
Parameter order changed: previously rowtimeIndex() was the 3rd parameter and minRetentionTime() was the 4th. Now they are swapped. This will cause incorrect behavior if the constructor signature hasn't changed accordingly.
| deduplicateNode->minRetentionTime(), | |
| deduplicateNode->rowtimeIndex(), | |
| deduplicateNode->rowtimeIndex(), | |
| deduplicateNode->minRetentionTime(), |
| std::shared_ptr<KeySelector> sortKeySelector = | ||
| std::make_shared<KeySelector>( |
There was a problem hiding this comment.
Changed from std::unique_ptr to std::shared_ptr for sortKeySelector. The variable is then moved on line 453, which is unusual for a shared_ptr. Verify this ownership change is intentional and that the shared ownership semantics are required.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| std::make_unique<KeySelector>( | ||
| std::move(joinNode->leftPartFuncSpec()->create(INT_MAX, false)), | ||
| op->pool(), | ||
| joinNode->leftPartFuncSpec()->create(INT_MAX, false), |
There was a problem hiding this comment.
The magic number INT_MAX appears multiple times throughout the code (lines 163, 168, 194, 199, 224, 228, 271, 275, 309, 328, 446). Consider defining this as a named constant to improve code clarity and maintainability.
| ctx_, | ||
| topNNode, | ||
| std::move(op), | ||
| sortKeySelector, |
There was a problem hiding this comment.
Potential use-after-move issue: sortKeySelector is moved on line 452 and then used again on line 453. After std::move(op) on line 452, using sortKeySelector on the next line will result in passing a moved-from object.
- Refactor nodeToStatefulOperator/nodeToOperator to transform* methods - Add support for GroupWindowAggsHandlerNode, GroupAggsHandlerNode, DeduplicateNode, StreamTopNNode - Fix RowTimeDeduplicateRanker parameter order: minRetentionTime should come before rowtimeIndex - Fix GroupAggregator parameter order: use stateRetentionTime=0 and generateUpdateBefore - Remove unused headers: CallbackSink, Exchange, HashBuild, Merge, NestedLoopJoinBuild, RoundRobinPartitionFunction - Add FIXME comment for stateRetentionTime handling in GroupAggregator
No description provided.