Class RichAggregateFunction<IN,​ACC,​OUT>

    • Constructor Detail

      • RichAggregateFunction

        public RichAggregateFunction()
    • Method Detail

      • createAccumulator

        public abstract ACC createAccumulator()
        Description copied from interface: AggregateFunction
        Creates a new accumulator, starting a new aggregate.

        The new accumulator is typically meaningless unless a value is added via AggregateFunction.add(Object, Object).

        The accumulator is the state of a running aggregation. When a program has multiple aggregates in progress (such as per key and window), the state (per key and window) is the size of the accumulator.

        Specified by:
        createAccumulator in interface AggregateFunction<IN,​ACC,​OUT>
        Returns:
        A new accumulator, corresponding to an empty aggregate.
      • add

        public abstract ACC add​(IN value,
                                ACC accumulator)
        Description copied from interface: AggregateFunction
        Adds the given input value to the given accumulator, returning the new accumulator value.

        For efficiency, the input accumulator may be modified and returned.

        Specified by:
        add in interface AggregateFunction<IN,​ACC,​OUT>
        Parameters:
        value - The value to add
        accumulator - The accumulator to add the value to
        Returns:
        The accumulator with the updated state
      • getResult

        public abstract OUT getResult​(ACC accumulator)
        Description copied from interface: AggregateFunction
        Gets the result of the aggregation from the accumulator.
        Specified by:
        getResult in interface AggregateFunction<IN,​ACC,​OUT>
        Parameters:
        accumulator - The accumulator of the aggregation
        Returns:
        The final aggregation result.
      • merge

        public abstract ACC merge​(ACC a,
                                  ACC b)
        Description copied from interface: AggregateFunction
        Merges two accumulators, returning an accumulator with the merged state.

        This function may reuse any of the given accumulators as the target for the merge and return that. The assumption is that the given accumulators will not be used any more after having been passed to this function.

        Specified by:
        merge in interface AggregateFunction<IN,​ACC,​OUT>
        Parameters:
        a - An accumulator to merge
        b - Another accumulator to merge
        Returns:
        The accumulator with the merged state