fix: chunk get together when random rechunk#3205
fix: chunk get together when random rechunk#3205yyy1000 wants to merge 5 commits intotypelevel:mainfrom
Conversation
| 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.
Is Pull.output(hd) >> tl equivalent to s?
There was a problem hiding this comment.
Yes. I should change it to s. :) Thanks for that.
| @@ -2413,7 +2413,7 @@ final class Stream[+F[_], +O] private[fs2] (private[fs2] val underlying: Pull[F, | |||
| Pull.output(acc) >> go(hd, size, tl) | |||
There was a problem hiding this comment.
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 in acc. Instead should be -1, so that the next iteration recomputes a new size based on the first chunk of tl.
There was a problem hiding this comment.
Yes! I realize it now.
|
Uh, it seems that it will lead the time to be longer and fail the pipeline. :( |
| 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.
Also the way factor and nextSize are implemented now, I don't think factor can ever reach maxFactor. So for this example nextSize can only be 0 or 1.
There was a problem hiding this comment.
Yeah, that's true. Now the range is [minFactor, maxFactor).
|
I can replicate the CI failures locally, can you replicate them as well? Not sure what's wrong, could it be getting into some sort of loop or something? Details |
Thanks! I replicated it locally but didn't discover the details. I should check it carefully. :) |
This wants to fix #3195
Consider the case: if (size < acc.size)
The code will continue to append the 'hd' to 'rem', which may be larger than the 'size', to the next 'go' method.
And this will lead to the 'tl' being consumed totally without restricting the size of 'Chunk'.
:)