Skip to content

Conversation

@seigert
Copy link
Contributor

@seigert seigert commented Oct 17, 2022

I've added Stream.ToPull.unconsMin and changed logic of both Stream.ToPull.unconsN and Stream.chunkMin to use it.

Main motivation: if you working with some 'frames' of size N, sometimes you also can process chunks of M * N size in a batch, right now it is possible only via (afaik) .chunkMin(N).scan(Chunk.empty)(..).unchunk. New operation allows this directly on pull.

Also I've removed an assertion of n > 0 on unconsLimit as all other similar methods (unconsN, chunkMin, chunkM) to do not fail and return empty output instead.


On a side note, usage of both repeatPull and unconsFlatMap in chunk* operators and other methods is confusing at best. Especially as 'unconsFlatMap' to not use the operations defined in ToPull.

For example, current implementation of unconsLimit will fail on negative n while chunkLimit will produce infinite stream of empty chunks.

@seigert seigert force-pushed the stream_pull_unchunkMin branch from 0f13e6c to 897e306 Compare October 17, 2022 16:55
@mpilquist mpilquist merged commit 0a0d363 into typelevel:main Oct 18, 2022
@mpilquist
Copy link
Member

Looks great!

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.

2 participants