Skip to content

Refine StatefulPlanner.plan#22

Merged
lgbo-ustc merged 7 commits intogluten-0530from
task_build
Jan 30, 2026
Merged

Refine StatefulPlanner.plan#22
lgbo-ustc merged 7 commits intogluten-0530from
task_build

Conversation

@lgbo-ustc
Copy link

No description provided.

lgbo-ustc and others added 3 commits January 28, 2026 09:51
Co-authored-by: Cursor <cursoragent@cursor.com>
@lgbo-ustc lgbo-ustc marked this pull request as ready for review January 30, 2026 02:03
@lgbo-ustc
Copy link
Author

@copilot

Copy link

Copilot AI commented Jan 30, 2026

@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.

Copilot AI mentioned this pull request Jan 30, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 StatefulPlanner from 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) {}
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after comma in initializer list. Add space after ctx_(ctx), to maintain consistent formatting.

Suggested change
StatefulPlanner(exec::DriverCtx* ctx, StateBackend* stateBackend) : ctx_(ctx),stateBackend_(stateBackend) {}
StatefulPlanner(exec::DriverCtx* ctx, StateBackend* stateBackend) : ctx_(ctx), stateBackend_(stateBackend) {}

Copilot uses AI. Check for mistakes.
aggsHandlerNode,
std::make_unique<AggsHandleFunction>(), // TODO: not complete yet
0, // stateRetentionTime: default to 0
aggsHandlerNode->generateUpdateBefore());
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
aggsHandlerNode->generateUpdateBefore());
aggsHandlerNode->generateUpdateBefore(),
aggsHandlerNode->needRetraction());

Copilot uses AI. Check for mistakes.
Comment on lines +437 to +438
deduplicateNode->minRetentionTime(),
deduplicateNode->rowtimeIndex(),
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
deduplicateNode->minRetentionTime(),
deduplicateNode->rowtimeIndex(),
deduplicateNode->rowtimeIndex(),
deduplicateNode->minRetentionTime(),

Copilot uses AI. Check for mistakes.
Comment on lines +444 to +445
std::shared_ptr<KeySelector> sortKeySelector =
std::make_shared<KeySelector>(
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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),
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
ctx_,
topNNode,
std::move(op),
sortKeySelector,
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
- 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
@lgbo-ustc lgbo-ustc merged commit adcb064 into gluten-0530 Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants