Class SumAccumulator
java.lang.Object
dev.frostlake.functions.aggregate.SumAccumulator
- All Implemented Interfaces:
ApproximateAwareAccumulator,AggregateFunction.Accumulator
public class SumAccumulator
extends Object
implements AggregateFunction.Accumulator, ApproximateAwareAccumulator
Accumulator for
Sum.
Exact inputs sum exactly. A FLOAT input — by its runtime class, or by the argument's DECLARED type when its values arrive in an exact carrier — puts the whole sum on the double path, compensated the way the account adds doubles; a VARIANT input does the same (live: SUM of PARSE_JSON('1') and PARSE_JSON('2') is 3.0, SYSTEM$TYPEOF FLOAT). Every input feeds the double sum in order regardless, so the answer is the same whichever input first decides the tier.
-
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.voidsetApproximateArgument(boolean declaredApproximate) Tell the accumulator what its argument's declared type is.
-
Constructor Details
-
SumAccumulator
public SumAccumulator()
-
-
Method Details
-
setApproximateArgument
public void setApproximateArgument(boolean declaredApproximate) Description copied from interface:ApproximateAwareAccumulatorTell the accumulator what its argument's declared type is.- Specified by:
setApproximateArgumentin interfaceApproximateAwareAccumulator- Parameters:
declaredApproximate- whether the aggregated expression is declared FLOAT / DOUBLE / REAL
-
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
-