Setting of UNORDERED on concurrent collectors
    Brian Goetz 
    brian.goetz at oracle.com
       
    Mon Apr  8 14:09:44 PDT 2013
    
    
  
That option is always available regardless of what we do with Collectors.
Remember, where Collector really shines is not the simple things like 
this, but composite collections, like
   Map<Buyer, Map<Seller, Transaction>>
     biggestTransactionByBuyerSeller =
       stream.collect(groupingBy(Txn::buyer,
                                 groupingBy(Txn::seller,
                                            maxBy(comparing(Txn::amount))
The groupBy combinator lets you compose complex collections out of 
building blocks.  These would have to be manually inlined with the 
explicit parallel forEach version.
On 4/8/2013 4:57 PM, Doug Lea wrote:
> On 04/08/13 16:41, Joe Bowbeer wrote:
>
>> I'm OK with this, but I wish groupingByConcurrent could go away.
>>
>
> These were the kinds of thoughts that led me last fall to suggest
> that we just tell people to do it themselves as a little idiom:
>    chm = ...
>    c.parallelStream().forEach( chm.merge(x->keyFor(x), x, mergefn); }
>
> The main downside is that this, the most commonly recommended
> way of doing parallel groupBy, would not be in the family of
> collect methods. Still maybe worth reconsidering though.
>
> -Doug
>
    
    
More information about the lambda-libs-spec-observers
mailing list