pub trait Accumulator: Send + Sync + Debug {
    fn state(&self) -> Result<Vec<AggregateState>>;
    fn update_batch(&mut self, values: &[ArrayRef]) -> Result<()>;
    fn merge_batch(&mut self, states: &[ArrayRef]) -> Result<()>;
    fn evaluate(&self) -> Result<ScalarValue>;
    fn size(&self) -> usize;

    fn retract_batch(&mut self, _values: &[ArrayRef]) -> Result<()> { ... }
}
Expand description

An accumulator represents a stateful object that lives throughout the evaluation of multiple rows and generically accumulates values.

An accumulator knows how to:

  • update its state from inputs via update_batch
  • retract an update to its state from given inputs via retract_batch
  • convert its internal state to a vector of aggregate values
  • update its state from multiple accumulators’ states via merge_batch
  • compute the final value from its internal state via evaluate

Required Methods§

Returns the state of the accumulator at the end of the accumulation. in the case of an average on which we track sum and n, this function should return a vector of two values, sum and n.

Updates the accumulator’s state from a vector of arrays.

updates the accumulator’s state from a vector of states.

returns its value based on its current state.

Allocated size required for this accumulator, in bytes, including Self. Allocated means that for internal containers such as Vec, the capacity should be used not the len

Provided Methods§

Retracts an update (caused by the given inputs) to accumulator’s state. Inverse operation of the update_batch operation. This method must be for accumulators that should support bounded OVER aggregates.

Implementors§