public interface AggregateFunction<IN,ACC,OUT>
extends java.io.Serializable
| Modifier and Type | Method and Description |
|---|---|
ACC |
add(IN value,
ACC accumulator)
Adds the given input value to the given accumulator, returning the new accumulator value.
|
ACC |
createAccumulator()
Creates a new accumulator, starting a new aggregate.
|
OUT |
getResult(ACC accumulator)
Gets the result of the aggregation from the accumulator.
|
ACC |
merge(ACC a,
ACC b)
Merges two accumulators, returning an accumulator with the merged state.
|
ACC createAccumulator()
The new accumulator is typically meaningless unless a value is added via 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.
ACC add(IN value, ACC accumulator)
For efficiency, the input accumulator may be modified and returned.
value - The value to addaccumulator - The accumulator to add the value toOUT getResult(ACC accumulator)
accumulator - The accumulator of the aggregationACC 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 mergeb - Another accumulator to mergeCopyright © 2022. All rights reserved.