-
Notifications
You must be signed in to change notification settings - Fork 5
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
🐛 Fix sequential stream consuming source eager #98
🐛 Fix sequential stream consuming source eager #98
Conversation
Reviewer's Guide by SourceryThis PR fixes issues with sequential stream consuming source eagerly by modifying the stream operations to work lazily with generators and infinite sequences. The changes primarily involve refactoring stream operations to use iterators instead of lists, and adding proper support for generator-based streams. Updated class diagram for BaseStreamclassDiagram
class BaseStream {
- _source: Iterable
+ concat(*streams: BaseStream[K]) BaseStream[K]
+ distinct() BaseStream[K]
+ drop_while(predicate: Callable[[K], bool]) BaseStream[K]
+ flat_map(mapper: Callable[[K], Iterable[_V]]) BaseStream[_V]
+ limit(max_size: int) BaseStream[K]
+ map(mapper: Callable[[K], _V]) BaseStream[_V]
+ skip(n: int) BaseStream[K]
+ take_while(predicate: Callable[[K], bool]) BaseStream[K]
+ any_match(predicate: Callable[[K], bool]) bool
+ count() int
+ min() Optional
+ max() Optional
}
note for BaseStream "Refactored to use iterators instead of lists for lazy evaluation"
Updated class diagram for SequentialStreamclassDiagram
class SequentialStream {
+ find_any() Optional
+ flat_map(mapper: Callable[[Any], BaseStream])
+ for_each(action: Callable)
+ map(mapper: Callable[[Any], Any])
+ peek(action: Callable)
+ reduce(predicate: Callable, identity, depends_on_state: bool)
}
note for SequentialStream "Updated flat_map to use flat_map function for lazy evaluation"
Updated class diagram for ParallelStreamclassDiagram
class ParallelStream {
+ find_any() Optional
+ flat_map(mapper: Callable[[Any], BaseStream])
}
note for ParallelStream "Updated flat_map to use mapper for lazy evaluation"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
We've reviewed this pull request using the Sourcery rules engine. If you would also like our AI-powered code review then let us know.
…generators-in-sequential-streams' into bugfix/#94/support-for-infinite-generators-in-sequential-streams
Summary by Sourcery
Fix the eager consumption issue in sequential streams by implementing lazy evaluation and enhance stream operations for better efficiency and correctness. Add comprehensive tests to validate stream behaviors, especially with generators.
Bug Fixes:
Enhancements:
concat
method to execute all queued operations before concatenation, ensuring proper stream handling.distinct
,drop_while
,limit
,skip
,take_while
, andany_match
methods to handle streams more efficiently and correctly.Tests: