Collectors inventory

Brian Goetz brian.goetz at oracle.com
Thu Jun 13 11:21:57 PDT 2013


>    - String-specific reductions
>      - concatenating()
>      - joining x2: delimiter [, prefix, suffix ]

Should we find a name other than joining?  "join" has a very database-y 
feel to it, and in fact we might want to support some sort of joining in 
the future?

They could all be called concatenating.

>    - Reductions:
>      - reducing x3: reducer [, identity [, mapper ] ]
>      - minBy(comparator)
>      - maxBy(comparator)

Also to discuss: the no-identity version of reducing, as well as 
min/max, could now return Optional (they couldn't before.)  While the 
likelihood of them actually being applied to an empty stream is 
considerably lower than for the corresponding methods on Stream (because 
these methods are mostly for use as downstream reducers for things like 
groupingBy), it is possible that a user will use them directly. 
Currently they return null for empty streams.

It seems "obvious" that we should make these bear Optional, but it also 
seems a shame, as this will impose a dramatic performance cost on any 
groupBy operation that uses them, because it means that every groupBy 
using them will be followed by a (sequential) Map.replaceAll.  So the 
combination of "higher cost" and "wouldn't ever happen in that case 
anyway" gives me some pause.



More information about the lambda-libs-spec-experts mailing list