Interface CombinerAggregator<T,A,R>

All Superinterfaces:
Operation, Serializable
All Known Implementing Classes:
Count, LongSum

public interface CombinerAggregator<T,A,R> extends Operation
Interface for aggregating values.
  • Method Summary

    Modifier and Type
    Method
    Description
    apply(A accumulator, T value)
    Updates the accumulator by applying the current accumulator with the value.
    The initial value of the accumulator to start with.
    merge(A accum1, A accum2)
    Merges two accumulators and returns the merged accumulator.
    static <T, R> CombinerAggregator<T,R,R>
    of(R initialValue, BiFunction<? super R,? super T,? extends R> accumulator, BiFunction<? super R,? super R,? extends R> combiner)
    A static factory to create a CombinerAggregator based on initial value, accumulator and combiner.
    result(A accum)
    Produces a result value out of the accumulator.
  • Method Details

    • of

      static <T, R> CombinerAggregator<T,R,R> of(R initialValue, BiFunction<? super R,? super T,? extends R> accumulator, BiFunction<? super R,? super R,? extends R> combiner)
      A static factory to create a CombinerAggregator based on initial value, accumulator and combiner.
      Parameters:
      initialValue - the initial value of the result to start with
      accumulator - a function that accumulates values into a partial result
      combiner - a function that combines partially accumulated results
      Returns:
      the CombinerAggregator
    • init

      A init()
      The initial value of the accumulator to start with.
      Returns:
      the initial value of the accumulator
    • apply

      A apply(A accumulator, T value)
      Updates the accumulator by applying the current accumulator with the value.
      Parameters:
      accumulator - the current accumulator
      value - the value
      Returns:
      the updated accumulator
    • merge

      A merge(A accum1, A accum2)
      Merges two accumulators and returns the merged accumulator.
      Parameters:
      accum1 - the first accumulator
      accum2 - the second accumulator
      Returns:
      the merged accumulator
    • result

      R result(A accum)
      Produces a result value out of the accumulator.
      Parameters:
      accum - the accumulator
      Returns:
      the result