Suggestion: buffer(int size) as the bulk operation
aleksey.shipilev at oracle.com
Thu Sep 13 03:45:58 PDT 2012
Is there a merit for including semi-eager buffering stage in streams?
This will arguably help in some of the corner cases when the stream
generator, or even the ops have the temporal/spatial locality benefits.
Normally we can force users to have eager terminators to compute
everything at once. buffer() acts like a middle ground here, providing
the means to balance the laziness vs. locality benefits.
We have both the benefits of staying within lazy operations, and having
the opportunity to process the operations in bulk, without consuming all
BTW, this suggestion really shines if we can then have limited push
traversal in the framework. That means, forEach which would dump not the
entire stream contents, but only the next $limit elements. In this
example we can then do limited forEach(10) pushes to buffer, and the let
buffer provide us "lazy" pulls, doing bulk forEach(10) each time it
More information about the lambda-dev