Let's say I have an input Flux containing many (billions of strings) like this:
- apple
- application
- bible
- book
There are billions of such strings, they won't fit into memory, that's why I want to use the reactive approach.
The stream is sorted. Now what I want is to create a flux of ordered groups of strings by the first 3 characters:
- app: apple, application
- bib: bible
- boo: book
This Flux ends up on an HTTP response which means that all "app" items must be outputted before "bib" items begin.
Without using Flux I could use the ordered property and collect the items into a prepared bucket (amount of strings per bucket will fit into memory) as they come - whenever the prefix changes, I will flush the bucket and start collecting new prefix. The big advantage of the stream being ordered is that I know that once I encounter new prefix, the old one will never come again.
But using Flux I don't know how to do this. The .groupBy() will return Flux of Flux but I don't think this will work when trying to serialize this to the HTTP response output stream.