RFR: 8015318: Extend Collector with 'finish' operation

Paul Sandoz paul.sandoz at oracle.com
Mon Jul 8 02:53:48 PDT 2013

On Jul 8, 2013, at 11:19 AM, Arne Siegel <v.a.ammodytes at googlemail.com> wrote:

> Hi,
> when reading the sources, I gut puzzled about 3 lines in ReduceOps.java:
> 150      * @param <T> the type of the input elements
> 151      * @param <I> the type of the intermediate reduction result
> 152      * @param <I> the type of the final reduction result
> My first thought was that the third of these three lines should be changed
> from <I> to <R>.
> Looking further, I got the impression that R could be eliminated altogether
> as it is used nowhere inside of makeRef.

Yes, well spotted. That should be:

     * Constructs a {@code TerminalOp} that implements a mutable reduce on
     * reference values.
     * @param <T> the type of the input elements
     * @param <I> the type of the intermediate reduction result
     * @param collector a {@code Collector} defining the reduction
     * @return a {@code ReduceOp} implementing the reduction
    public static <T, I, ?> TerminalOp<T, I>
    makeRef(Collector<? super T, I, ?> collector) {

> Looking even deeper, I'm wondering if makeRef shouldn't consider the
> finisher method of Collector, maybe in the get method in the ReduceOp.

That would require overriding the evaluateParallel and evaluateSequential methods.

I think it better to keep this separate, thus reduction focuses on accumulation and combining in it's various forms (not just for Collector). The logic for finishing a Collector is then kept in one place in ReferencePipeline.collect


More information about the lambda-dev mailing list