Class VectorAggregateAccumulator
- All Implemented Interfaces:
AggregateFunction.Accumulator
VectorSum, VectorAvg,
VectorMin and VectorMax.
Live-verified over the deliberately CROSSING rows [1,9,3], [4,5,-6] and
[7,2,0] — where a row-wise winner would give a different answer than an element-wise one:
VECTOR_MIN is [1.0,2.0,-6.0] and VECTOR_MAX is [7.0,9.0,3.0], so each
DIMENSION is reduced independently. VECTOR_SUM is [12.0,16.0,-3.0] and
VECTOR_AVG [4.0,5.3333335,-1.0] — the float64 mean 16/3 narrowed to a float32
element.
NULL rows are SKIPPED and do not count towards the average (VECTOR_AVG over
[1,2,3], [4,5,6] and a NULL row is [2.5,3.5,4.5], i.e. divided by 2), and a
group with no non-NULL row is SQL NULL rather than a zero vector.
The result's element type follows the INPUT for SUM / MIN / MAX (VECTOR_SUM over a
VECTOR(INT,3) column is [5,14,-3], SYSTEM$TYPEOF VECTOR(INT, 3)) and
is always FLOAT for AVG (VECTOR_AVG over the same column is [2.5,7.0,-1.5],
VECTOR(FLOAT, 3)).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccumulate(Object value) Folds one row's argument value into the running state.The aggregate's result over everything accumulated so far.voidFolds another accumulator's state into this one, combining two partial aggregations of the same group.voidreset()Clears the state back to the empty-group starting point so the accumulator can be reused.
-
Constructor Details
-
VectorAggregateAccumulator
-
-
Method Details
-
accumulate
Description copied from interface:AggregateFunction.AccumulatorFolds one row's argument value into the running state.- Specified by:
accumulatein interfaceAggregateFunction.Accumulator- Parameters:
value- the aggregate argument's value for one row; SQL NULL arrives asnull
-
getResult
Description copied from interface:AggregateFunction.AccumulatorThe aggregate's result over everything accumulated so far.- Specified by:
getResultin interfaceAggregateFunction.Accumulator- Returns:
- the group's result, or
nullwhere the aggregate defines an empty group as NULL
-
reset
public void reset()Description copied from interface:AggregateFunction.AccumulatorClears the state back to the empty-group starting point so the accumulator can be reused.- Specified by:
resetin interfaceAggregateFunction.Accumulator
-
merge
Description copied from interface:AggregateFunction.AccumulatorFolds another accumulator's state into this one, combining two partial aggregations of the same group.- Specified by:
mergein interfaceAggregateFunction.Accumulator- Parameters:
other- a partial state of the same aggregate implementation
-