-
Notifications
You must be signed in to change notification settings - Fork 294
refactor: Use associate type for swordfish operator state #4921
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
Conversation
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.
Greptile Summary
This PR implements a comprehensive refactoring of the Daft execution engine's operator state management system, transitioning from trait object-based state handling to associated types. The changes affect three key operator categories: IntermediateOperator
, BlockingSink
, and StreamingSink
, along with their respective nodes and result types.
The refactoring eliminates the need for trait objects like Box<dyn IntermediateOpState>
, Box<dyn BlockingSinkState>
, and Box<dyn StreamingSinkState>
, replacing them with associated State
types on each trait. For example, the IntermediateOperator
trait now includes type State: Send + Sync + Unpin
and methods accept Self::State
directly instead of boxed trait objects. Each operator implementation defines its concrete state type - stateless operators like FilterOperator
use type State = ()
, while stateful operators like GroupedAggregateSink
use type State = GroupedAggregateState
.
The changes update method signatures across all affected traits: execute()
, sink()
, finalize()
, and introduce new make_state()
methods that return DaftResult<Self::State>
. Node structures like IntermediateNode
, BlockingSinkNode
, and StreamingSinkNode
become generic over their operator types, enabling compile-time type checking. Result types are updated to use associated type syntax, such as IntermediateOpExecuteResult<Op>
now referencing <Op as IntermediateOperator>::State
.
This architectural change integrates with Daft's execution framework by maintaining the same operational semantics while providing a more type-safe foundation. The refactoring preserves all existing functionality in operators like filtering, projection, aggregation, joins, and window operations, but eliminates runtime downcasting patterns that were previously required with as_any_mut().downcast_mut()
operations.
Confidence score: 4/5
- This PR represents a significant but well-structured architectural refactoring that improves type safety without changing core functionality
- Score reflects the comprehensive nature of changes across many critical execution engine files, requiring careful validation
- Pay close attention to the generic type bounds and associated type implementations across all operator traits
32 files reviewed, 1 comment
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4921 +/- ##
==========================================
- Coverage 79.33% 79.33% -0.01%
==========================================
Files 898 898
Lines 125742 125498 -244
==========================================
- Hits 99762 99562 -200
+ Misses 25980 25936 -44
🚀 New features to boost your workflow:
|
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.
This PR makes me unreasonably happy
) ## Changes Made Fixes issue here https://github.com/Eventual-Inc/Daft/actions/runs/16889682307/job/47846055281 merge conflict between #4935 and #4921 ## Checklist - [ ] Documented in API Docs (if applicable) - [ ] Documented in User Guide (if applicable) - [ ] If adding a new documentation page, doc is added to `docs/mkdocs.yml` navigation - [ ] Documentation builds and is formatted properly (tag @/ccmao1130 for docs review)
Changes Made
Use associated type for operator states, removes need to box and downcast.
Related Issues
Checklist
docs/mkdocs.yml
navigation