Class VarianceAccumulator

java.lang.Object
dev.frostlake.functions.aggregate.VarianceAccumulator
All Implemented Interfaces:
ApproximateAwareAccumulator, AggregateFunction.Accumulator

public class VarianceAccumulator extends Object implements AggregateFunction.Accumulator, ApproximateAwareAccumulator
Accumulator for Variance.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Folds one row's argument value into the running state.
    The aggregate's result over everything accumulated so far.
    void
    Folds another accumulator's state into this one, combining two partial aggregations of the same group.
    void
    Clears the state back to the empty-group starting point so the accumulator can be reused.
    void
    setApproximateArgument(boolean approximate)
    The argument's DECLARED type, which the values alone cannot say: a FLOAT column is stored exactly here, so its 2 and a NUMBER(1,0)'s 2 arrive as the same object and only this flag separates them.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • VarianceAccumulator

      public VarianceAccumulator()
  • Method Details

    • setApproximateArgument

      public void setApproximateArgument(boolean approximate)
      The argument's DECLARED type, which the values alone cannot say: a FLOAT column is stored exactly here, so its 2 and a NUMBER(1,0)'s 2 arrive as the same object and only this flag separates them. Without it a FLOAT input was scaled as an exact number — live's 2.333333333 came back 2.333333.
      Specified by:
      setApproximateArgument in interface ApproximateAwareAccumulator
      Parameters:
      approximate - whether the aggregated expression is declared FLOAT / DOUBLE / REAL
    • accumulate

      public void accumulate(Object value)
      Description copied from interface: AggregateFunction.Accumulator
      Folds one row's argument value into the running state.
      Specified by:
      accumulate in interface AggregateFunction.Accumulator
      Parameters:
      value - the aggregate argument's value for one row; SQL NULL arrives as null
    • getResult

      public Object getResult()
      Description copied from interface: AggregateFunction.Accumulator
      The aggregate's result over everything accumulated so far.
      Specified by:
      getResult in interface AggregateFunction.Accumulator
      Returns:
      the group's result, or null where the aggregate defines an empty group as NULL
    • reset

      public void reset()
      Description copied from interface: AggregateFunction.Accumulator
      Clears the state back to the empty-group starting point so the accumulator can be reused.
      Specified by:
      reset in interface AggregateFunction.Accumulator
    • merge

      public void merge(AggregateFunction.Accumulator other)
      Description copied from interface: AggregateFunction.Accumulator
      Folds another accumulator's state into this one, combining two partial aggregations of the same group.
      Specified by:
      merge in interface AggregateFunction.Accumulator
      Parameters:
      other - a partial state of the same aggregate implementation