Skip to main content

Accumulator

Trait Accumulator 

Source
pub trait Accumulator:
    Default
    + Clone
    + Send {
    type Input;
    type Output: ResultToI64 + ResultToArrow;

    // Required methods
    fn add(&mut self, value: Self::Input);
    fn merge(&mut self, other: &Self);
    fn result(&self) -> Self::Output;
    fn is_empty(&self) -> bool;
}
Expand description

Accumulator state for aggregations.

This is the state stored per window in the state store. Different aggregators store different types of accumulators.

Implementors should derive rkyv::Archive, rkyv::Serialize, and rkyv::Deserialize for zero-copy serialization on the hot path.

Required Associated Types§

Source

type Input

The input type for the aggregation.

Source

type Output: ResultToI64 + ResultToArrow

The output type produced by the aggregation.

Required Methods§

Source

fn add(&mut self, value: Self::Input)

Adds a value to the accumulator.

Source

fn merge(&mut self, other: &Self)

Merges another accumulator into this one.

Source

fn result(&self) -> Self::Output

Extracts the final result from the accumulator.

Source

fn is_empty(&self) -> bool

Returns true if the accumulator is empty (no values added).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§