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 FormConstructor 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, setRuntimeContext
public abstract ACC createAccumulator()
AggregateFunction
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.
createAccumulator
in interface AggregateFunction<IN,ACC,OUT>
public abstract ACC add(IN value, ACC accumulator)
AggregateFunction
For 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)
AggregateFunction
getResult
in interface AggregateFunction<IN,ACC,OUT>
accumulator
- The accumulator of the aggregationpublic abstract ACC merge(ACC a, ACC b)
AggregateFunction
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.
merge
in interface AggregateFunction<IN,ACC,OUT>
a
- An accumulator to mergeb
- Another accumulator to mergeCopyright © 2014–2019 The Apache Software Foundation. All rights reserved.