Skip to main content

PluginAccumulator

Trait PluginAccumulator 

Source
pub trait PluginAccumulator: Send {
    // Required methods
    fn update_batch(&mut self, values: &[ArrayRef]) -> Result<(), FnError>;
    fn merge_batch(&mut self, states: &[ArrayRef]) -> Result<(), FnError>;
    fn state(&self) -> Result<Vec<ScalarValue>, FnError>;
    fn evaluate(&self) -> Result<ScalarValue, FnError>;
    fn size(&self) -> usize;
}
Expand description

Per-group state machine for an aggregate function.

One PluginAccumulator instance is created per group. The host calls update_batch repeatedly with the group’s rows, then evaluate for the final value. For distributed aggregation, the host calls state on partial accumulators and merge_batch on the final accumulator.

Required Methods§

Source

fn update_batch(&mut self, values: &[ArrayRef]) -> Result<(), FnError>

Ingest a batch of input rows into the accumulator.

values[i] is the i-th argument’s column, all of equal length.

§Errors

Returns FnError if the input cannot be accumulated (type mismatch, resource exhaustion).

Source

fn merge_batch(&mut self, states: &[ArrayRef]) -> Result<(), FnError>

Merge per-partition partial states into this accumulator.

states[i] is the i-th state field across partial accumulators.

§Errors

Returns FnError if the merge cannot proceed.

Source

fn state(&self) -> Result<Vec<ScalarValue>, FnError>

Return the current accumulator state as scalar values, for transport across the partial / final aggregation boundary.

§Errors

Returns FnError if the state cannot be serialized.

Source

fn evaluate(&self) -> Result<ScalarValue, FnError>

Produce the final aggregate value.

§Errors

Returns FnError if the final value cannot be computed (e.g., undefined for empty input and the aggregate forbids it).

Source

fn size(&self) -> usize

Approximate in-memory size, in bytes — used for memory accounting.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§