pub trait Aggregator: Send + Clone {
type Acc: Accumulator;
// Required methods
fn create_accumulator(&self) -> Self::Acc;
fn extract(
&self,
event: &Event,
) -> Option<<Self::Acc as Accumulator>::Input>;
// Provided methods
fn output_data_type(&self) -> DataType { ... }
fn output_nullable(&self) -> bool { ... }
fn extract_batch(
&self,
event: &Event,
) -> SmallVec<[<Self::Acc as Accumulator>::Input; 4]> { ... }
}Expand description
Trait for window aggregation functions.
Aggregators define how events are combined within a window. They must be serializable for checkpointing.
Required Associated Types§
Sourcetype Acc: Accumulator
type Acc: Accumulator
The accumulator type used by this aggregator.
Required Methods§
Sourcefn create_accumulator(&self) -> Self::Acc
fn create_accumulator(&self) -> Self::Acc
Creates a new empty accumulator.
Provided Methods§
Sourcefn output_data_type(&self) -> DataType
fn output_data_type(&self) -> DataType
Returns the Arrow [DataType] for this aggregator’s output.
Defaults to Int64. Override for aggregators that produce different types
(e.g., AvgAggregator returns Float64).
Sourcefn output_nullable(&self) -> bool
fn output_nullable(&self) -> bool
Returns whether the output is nullable (e.g., empty windows produce null).
Defaults to false. Override for aggregators like MIN/MAX/AVG.
Sourcefn extract_batch(
&self,
event: &Event,
) -> SmallVec<[<Self::Acc as Accumulator>::Input; 4]>
fn extract_batch( &self, event: &Event, ) -> SmallVec<[<Self::Acc as Accumulator>::Input; 4]>
Extracts all values from a multi-row batch event.
The default implementation calls extract() and wraps
the single result. Override this in aggregators that need to process
all rows in a batch (e.g., AvgAggregator).
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.