IN- The type of the values that are aggregated (input values)
ACC- The type of the accumulator (intermediate aggregate state).
OUT- The type of the aggregated result
@PublicEvolving public abstract class RichAggregateFunction<IN,ACC,OUT> extends AbstractRichFunction implements AggregateFunction<IN,ACC,OUT>
AggregateFunction. As a
RichFunction, it gives access to the
RuntimeContextand provides setup and teardown methods:
AggregateFunction, Serialized Form
|Constructor and Description|
|Modifier and Type||Method and Description|
Adds the given input value to the given accumulator, returning the new accumulator value.
Creates a new accumulator, starting a new aggregate.
Gets the result of the aggregation from the accumulator.
Merges two accumulators, returning an accumulator with the merged state.
close, getIterationRuntimeContext, getRuntimeContext, open, setRuntimeContext
public abstract ACC createAccumulator()
The new accumulator is typically meaningless unless a value is added via
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.
public abstract ACC add(IN value, ACC accumulator)
For efficiency, the input accumulator may be modified and returned.
value- The value to add
accumulator- The accumulator to add the value to
public abstract OUT getResult(ACC accumulator)
accumulator- The accumulator of the aggregation
public abstract ACC merge(ACC a, ACC b)
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.
a- An accumulator to merge
b- Another accumulator to merge
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.