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
RuntimeContext and provides setup and teardown methods:
RichFunction.open(org.apache.flink.configuration.Configuration) and
RichFunction.close().AggregateFunction,
Serialized Form| Constructor and Description |
|---|
RichAggregateFunction() |
| Modifier and Type | Method and Description |
|---|---|
abstract ACC |
add(IN value,
ACC accumulator)
Adds the given input value to the given accumulator, returning the
new accumulator value.
|
abstract ACC |
createAccumulator()
Creates a new accumulator, starting a new aggregate.
|
abstract OUT |
getResult(ACC accumulator)
Gets the result of the aggregation from the accumulator.
|
abstract ACC |
merge(ACC a,
ACC b)
Merges two accumulators, returning an accumulator with the merged state.
|
close, getIterationRuntimeContext, getRuntimeContext, open, setRuntimeContextpublic abstract ACC createAccumulator()
AggregateFunctionThe 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.
createAccumulator in interface AggregateFunction<IN,ACC,OUT>public abstract ACC add(IN value, ACC accumulator)
AggregateFunctionFor efficiency, the input accumulator may be modified and returned.
add in interface AggregateFunction<IN,ACC,OUT>value - The value to addaccumulator - The accumulator to add the value topublic abstract OUT getResult(ACC accumulator)
AggregateFunctiongetResult in interface AggregateFunction<IN,ACC,OUT>accumulator - The accumulator of the aggregationpublic abstract ACC merge(ACC a, ACC b)
AggregateFunctionThis 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.
merge in interface AggregateFunction<IN,ACC,OUT>a - An accumulator to mergeb - Another accumulator to mergeCopyright © 2014–2018 The Apache Software Foundation. All rights reserved.