Brian Goetz brian.goetz at oracle.com
Fri Feb 1 08:50:19 PST 2013


Spliterator is cool because it means all you have to do to be a source 
for parallel streams -- thereby getting all the benefits of 
filter/map/reduce/etc -- is provide a Spliterator, and the library does 
the rest.

If you cannot come up with a Spliterator, we can convert an Iterator to 
a Spliterator, and even extract *some* parallelism.  Obviously not as 
much as a well-tuned spliterator that produces exact binary splits, but 
still better than nothing.



On 2/1/2013 11:22 AM, Luc Duponcheel wrote:
> thanks so much
>
> it is always a bit tricky to know which methods are for
> app developers and which ones are for lib developers
>
> I worked with the parallel stream alternative already
> ( but was intrigued by the spliterator as well :-) )
>
> Luc
>
>
> On Fri, Feb 1, 2013 at 4:33 PM, Brian Goetz <brian.goetz at oracle.com
> <mailto:brian.goetz at oracle.com>> wrote:
>
>     It "just works", but it doesn't try to split ;)
>
>     Spliterator is NOT a parallel execution framework.  It is the
>     low-level adapter type that lets an arbitrary data structure (array,
>     List, whatever) feed data into a parallel execution framework.
>       Think of it as the parallel analogue of Iterator, but the
>     framework has to decide when to split.
>
>     Spliterator is not meant for most devs to use; only for developers
>     of library-based aggregates.  EVeryone else will do:
>
>        list.parallelStream().forEach(__...)
>
>     and get what you are looking for.
>
>
>     On 2/1/2013 10:14 AM, Luc Duponcheel wrote:
>
>         Hello,
>
>         I have a (hopefully) very simple question about spliterators
>
>         consider something like
>
>             Spliterator<Integer> spliterator =
>              // ... make a spliterator
>
>             spliterator.forEach(integer ->
>               new Integer(integer.intValue() + 1)
>              );
>
>         does the foreach method "just work"
>         (I mean: will it try to split)
>
>         or do I somehow have to invoke the trySplit() method myself
>
>         thx
>
>         Luc
>
>
>
>
> --
>     __~O
>    -\ <,
> (*)/ (*)
>
> reality goes far beyond imagination


More information about the lambda-dev mailing list