Package dev.frostlake.functions
Interface AggregateFunction.Accumulator
- All Known Implementing Classes:
AnyValueAccumulator,ApproxPercentileAccumulator,ApproxTopKAccumulator,ApproxTopKCombineAccumulator,ApproxTopKStateAccumulator,ArrayAggAccumulator,ArrayUnionAggAccumulator,ArrayUniqueAggAccumulator,AvgAccumulator,BitAndAccumulator,BitOrAccumulator,BitXorAccumulator,BoolAndAccumulator,BoolOrAccumulator,BoolXorAccumulator,CorrAccumulator,CountAccumulator,CountIfAccumulator,CovarAccumulator,HashAggAccumulator,HllAccumulator,KurtosisAccumulator,ListAggAccumulator,MaxAccumulator,MaxByMinByAccumulator,MedianAccumulator,MinAccumulator,ModeAccumulator,ObjectAggAccumulator,PercentileContAccumulator,PercentileDigestAccumulator,PercentileDigestCombineAccumulator,PercentileDiscAccumulator,RegrAccumulator,SkewAccumulator,StdDevAccumulator,StdDevPopAccumulator,SumAccumulator,VarianceAccumulator,VarPopAccumulator,VectorAggregateAccumulator
- Enclosing class:
AggregateFunction
public static interface AggregateFunction.Accumulator
The running state of one aggregate over one group: values are folded in one row at a time and
the group's result is read out at the end. Implementations ignore SQL NULL inputs where
Snowflake's aggregates do, and define the empty-group result (NULL for most, 0 for the counting
family).
THIS ONE STAYS NESTED, deliberately, against the house rule that interfaces live in their own
file. It means nothing away from its owner — an "accumulator" with no aggregate to accumulate for
is not a concept — which is the same reason the JDK keeps Map.Entry where it is. Moving it
would rename a type 43 files implement, including the frostlake-ai pack's aggregates, for no gain
beyond the letter of the rule. The nested-type Checkstyle rule cannot see it either way: an
interface nested in a class is implicitly static and never writes the keyword the rule keys on.
-
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.
-
Method Details
-
accumulate
Folds one row's argument value into the running state.- Parameters:
value- the aggregate argument's value for one row; SQL NULL arrives asnull
-
getResult
Object getResult()The aggregate's result over everything accumulated so far.- Returns:
- the group's result, or
nullwhere the aggregate defines an empty group as NULL
-
reset
void reset()Clears the state back to the empty-group starting point so the accumulator can be reused. -
merge
Folds another accumulator's state into this one, combining two partial aggregations of the same group.- Parameters:
other- a partial state of the same aggregate implementation
-