stream.parallel().limit() on large streams
Millies, Sebastian
Sebastian.Millies at softwareag.com
Tue Oct 8 01:12:28 PDT 2013
BTW, does it make any difference where the call to unordered() is placed in the chain?
Or is it all the same stream anyway, and the UNORDERED-property need only be set at some
arbitrary point before the terminal operation triggers processing? Can I have a chain
partway processed in an order-respecting way, and partway processed in an unordered way?
Would that be good style (could anyone even think of an example when might want
that behavior?).
-- Sebastian
-----Original Message-----
From: lambda-dev-bounces at openjdk.java.net [mailto:lambda-dev-bounces at openjdk.java.net] On Behalf Of Arne Siegel
Sent: Sunday, October 06, 2013 4:27 PM
To: Brian Goetz; lambda-dev at openjdk.java.net
Subject: Re: stream.parallel().limit() on large streams
Hi Brian,
tried out both of your propositions, and indeed they do a good job on the order-independent scenario I was looking into:
IntStream.range(0, maxToGenerate)
.parallel()
.unordered()
.mapToObj(i -> generatorFunction.get())
.filter(condition)
.limit(needed)
.forEach(action);
[snip]
Software AG – Sitz/Registered office: Uhlandstraße 12, 64297 Darmstadt, Germany – Registergericht/Commercial register: Darmstadt HRB 1562 - Vorstand/Management Board: Karl-Heinz Streibich (Vorsitzender/Chairman), Dr. Wolfram Jost, Arnd Zinnhardt; - Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Dr. Andreas Bereczky - http://www.softwareag.com
More information about the lambda-dev
mailing list