RFR: JDK-8133680 add Stream.foldLeft() terminal operation
Remi Forax
forax at univ-mlv.fr
Wed Aug 16 12:33:34 UTC 2017
:)
let say that fold left is not as useful as one may think when used in parallel.
Remi
On August 15, 2017 4:49:44 PM GMT+02:00, Brian Goetz <brian.goetz at oracle.com> wrote:
>It's an overstatement to say that forEachOrdered/foldLeft cannot
>exploit
>parallelism. If I have a stream:
>
> stream.parallel()
> .map(e -> expensiveFn(e))
> .forEachOrdered(e -> ...);
>
>We still can (and do) perform the mapping in parallel even if we cannot
>
>perform the folding step yet. See ForEachOps.ForEachOrderedTask.
>
>On 8/13/2017 3:45 PM, Remi Forax wrote:
>> Hi Tagir,
>> foldLeft (and foldRight) were intentionally not included in the
>Stream API because as you know, their semantics is too strong to be
>useful for parallel streams.
>>
>> regards,
>> Rémi
>>
>> ----- Mail original -----
>>> De: "Tagir Valeev" <amaembo at gmail.com>
>>> À: "core-libs-dev" <core-libs-dev at openjdk.java.net>
>>> Envoyé: Dimanche 13 Août 2017 15:27:36
>>> Objet: RFR: JDK-8133680 add Stream.foldLeft() terminal operation
>>> Please review the preliminary implementation for Stream foldLeft and
>>> foldRight operations:
>>>
>>> http://cr.openjdk.java.net/~tvaleev/webrev/8133680/r1/
>>>
>>> This implementation has no tests yet. Before writing them I'd like
>to
>>> be sure that this enhancement could be accepted in general (or
>>> probably foldLeft is accepted and foldRight is not?) Could anybody
>>> sponsor it when it will be complete?
>>>
>>> Thank you in advance!
>>>
>>> Tagir Valeev.
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
More information about the core-libs-dev
mailing list