-
Couldn't load subscription status.
- Fork 1.4k
Support leftovers in Sinks #3722
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
|
This is coming along really nicely. Thank you for picking this up @simpadjo. With your help we will restore happiness to ZSink land ;-) |
|
Deleted
|
|
TODO:
|
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.
Awesome work @simpadjo. Thank you for working on 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.
Last comments! Good to merge afterwards 💪🏻
| { | ||
| case Left(e) => ZIO.fail(e) | ||
| case Right(z) => restart.as(Chunk.single(z)) | ||
| case (Left(e), _) => ZIO.fail(e) |
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 is a weak spot. We have no contract that says that a transducer cannot be called after failing (and we shouldn't have such a contract). That means we're dropping leftovers inputs after failing.
How about placing these leftovers in a Ref that will be read on every push?
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.
I don't disagree with you, although I can't come up with a testcase so far.
Seems that once you called stream.transduce(t) you can't see beyond the first error.
| case (None, Some(z1)) => ZIO.succeedNow(RightDone(z1)) | ||
| case (None, None) => ZIO.succeedNow(BothRunning) | ||
| case (Some((z, l)), Some((z1, l1))) => { | ||
| val minLeftover = if (l.length > l1.length) l1 else l |
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.
What's your reasoning behind using the minimum? I can see arguments for both choices, just wondering what you're thinking.
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.
Consider (s1.zipPar(s2)).zip(s3). We have two lineages of consumers: s1.zip(s3) and s2.zip(s3).
Returning the maximum means that one of the lineages consumes some elements twice.
Which is the most surprising behavior IMO.
We have consumers that ignore some of the input but no consumer processes an element twice (w/o explicitly being asked for).
Btw, what are the arguments for the opposite?
|
Thank you @simpadjo for your work on this 🎉 |
#3711
Problems:
Transducer >>> Sink : Sinkcomposition is impossible nowIZSink#contramapgoneAchievements:
ZSink.head.flatmap(_ => Zsink.count)works!