-
Notifications
You must be signed in to change notification settings - Fork 595
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: chunk get together when random rechunk #3205
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2413,7 +2413,7 @@ final class Stream[+F[_], +O] private[fs2] (private[fs2] val underlying: Pull[F, | |
Pull.output(acc) >> go(hd, size, tl) | ||
else { | ||
val (out, rem) = acc.splitAt(size - 1) | ||
Pull.output(out) >> go(rem ++ hd, -1, tl) | ||
Pull.output(out) >> go(rem, -1, Pull.output(hd) >> tl) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. I should change it to |
||
} | ||
case None => | ||
Pull.output(acc) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1031,6 +1031,13 @@ class StreamSuite extends Fs2Suite { | |
assertEquals(countChunks(source), 2) | ||
} | ||
|
||
test("rechunkRandomly sometimes emits everything in a single chunk") { | ||
val fiveChunks = Stream(1) ++ Stream(2) ++ Stream(3) ++ Stream(4) ++ Stream(5) | ||
|
||
val source = fiveChunks.rechunkRandomlyWithSeed(0.1, 2.0)(5).chunks.toList | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also the way There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that's true. Now the range is [minFactor, maxFactor). |
||
assert(source.forall(_.size <= 2), "Some Chunks have larger size than maxFactor") | ||
diesalbla marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
group("Stream[F, Either[Throwable, O]]") { | ||
test(".evalMap(_.pure.rethrow).mask <-> .rethrow.mask") { | ||
forAllF { (stream: Stream[Pure, Int]) => | ||
|
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 think this is another error. The
size
should ideally be the desired size of the next output chunk, but that is the one being emited inacc
. Instead should be -1, so that the next iteration recomputes a new size based on the first chunk oftl
.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.
Yes! I realize it now.