Skip to content
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

Implement ZTransducer.foldUntil using ZTransducer.fold #3885

Merged
merged 1 commit into from Jun 27, 2020

Conversation

iravid
Copy link
Member

@iravid iravid commented Jun 26, 2020

The previous implementation used foldWeighted, which prevented
transducers based on it (like collectAllN) from emitting immediately
when N elements were accumulated.

Resolves #3860.

The previous implementation used foldWeighted, which prevented
transducers based on it (like collectAllN) from emitting immediately
when N elements were accumulated.
@iravid
Copy link
Member Author

iravid commented Jun 26, 2020

@simpadjo appreciate your review here

@iravid iravid requested a review from adamgfraser June 26, 2020 20:11
Copy link
Contributor

@simpadjo simpadjo left a comment

Choose a reason for hiding this comment

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

Looks good! I like the current implementation more.
For the reference, I complained about it as well #3559 :)
Just a small comment wrt the test.

@@ -74,6 +74,11 @@ object ZTransducerSpec extends ZIOBaseSpec {
},
testM("doesn't emit empty trailing chunks") {
assertM(run(ZTransducer.collectAllN[Int](3), List(Chunk(1, 2, 3))))(equalTo(Chunk(List(1, 2, 3))))
},
testM("emits chunks when exactly N elements received") {
Copy link
Contributor

Choose a reason for hiding this comment

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

The test could be blackboxified: something like
(ZStream(1,2,3,4) ++ ZStream.fromEffect(ZIO.never)).transduce(t).take(1)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! I actually prefer to test the transducer directly in this case as it is a bit of an edge case.

@iravid iravid merged commit 215076e into zio:master Jun 27, 2020
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.

ZStream.groupedWithin doesn't groups batch when got exact items count
3 participants