public class AggregateAggFunction extends Object implements AggregateFunction<CRow,Row,Row>, Compiler<GeneratedAggregations>, Logging
WindowedStream
param: genAggregations Generated aggregate helper function
Constructor and Description |
---|
AggregateAggFunction(GeneratedAggregationsFunction genAggregations) |
Modifier and Type | Method and Description |
---|---|
void |
add(CRow value,
Row accumulatorRow)
Adds the given value to the given accumulator.
|
Row |
createAccumulator()
Creates a new accumulator, starting a new aggregate.
|
Row |
getResult(Row accumulatorRow)
Gets the result of the aggregation from the accumulator.
|
void |
initFunction() |
Row |
merge(Row aAccumulatorRow,
Row bAccumulatorRow)
Merges two accumulators, returning an accumulator with the merged state.
|
public AggregateAggFunction(GeneratedAggregationsFunction genAggregations)
public Row 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<CRow,Row,Row>
public void add(CRow value, Row accumulatorRow)
AggregateFunction
add
in interface AggregateFunction<CRow,Row,Row>
value
- The value to addaccumulatorRow
- The accumulator to add the value topublic Row getResult(Row accumulatorRow)
AggregateFunction
getResult
in interface AggregateFunction<CRow,Row,Row>
accumulatorRow
- The accumulator of the aggregationpublic Row merge(Row aAccumulatorRow, Row bAccumulatorRow)
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<CRow,Row,Row>
aAccumulatorRow
- An accumulator to mergebAccumulatorRow
- Another accumulator to mergepublic void initFunction()
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.