Skip to content

rechunkRandomly sometimes emits everything in a single chunk #3195

@Jasper-M

Description

@Jasper-M

I have five 1-element chunks and a maxFactor of 2.0, but with certain seeds rechunkRandomly emits all elements in a single chunk. The number of chunks in the input stream doesn't matter. If you have 10000 1-element chunks, you end up with a single 10000-element chunk.

val fiveChunks = Stream(1) ++ Stream(2) ++ Stream(3) ++ Stream(4) ++ Stream(5)

fiveChunks.rechunkRandomlyWithSeed(0.1, 2.0)(5).chunks.toList == List(Chunk(1,2,3,4,5))

https://scastie.scala-lang.org/TqE3oVzwQ2asDEdW8rf3uA

Other example of a wrong result:

scala> (Stream(1,1) ++ Stream(2,2) ++ Stream(3,3) ++ Stream(4,4) ++ Stream(5,5)).rechunkRandomlyWithSeed(0.1, 2.0)(9).chunks.toList
val res16: List[fs2.Chunk[Int]] = List(Chunk(1), Chunk(1, 2, 2, 3, 3, 4, 4, 5, 5))

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions