Skip to main content

AggregateFunc

Trait AggregateFunc 

Source
pub trait AggregateFunc: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn apply(&self, events: &[Event], field: Option<&str>) -> Value;

    // Provided methods
    fn apply_shared(&self, events: &[SharedEvent], field: Option<&str>) -> Value { ... }
    fn apply_refs(&self, events: &[&Event], field: Option<&str>) -> Value { ... }
    fn apply_columnar(
        &self,
        buffer: &mut ColumnarBuffer,
        field: Option<&str>,
    ) -> Value { ... }
}
Expand description

Trait for implementing aggregation functions.

Aggregation functions compute summary values over collections of events. They are used in windowed stream processing to produce aggregate results.

§Required Methods

  • name: Returns the aggregation function name
  • apply: Computes the aggregation over owned events

§Optional Methods

§Thread Safety

Implementations must be Send + Sync to work with parallel processing.

Required Methods§

Source

fn name(&self) -> &str

Returns the name of this aggregation function (e.g., “sum”, “avg”).

Source

fn apply(&self, events: &[Event], field: Option<&str>) -> Value

Apply the aggregation to a slice of events.

§Arguments
  • events: Slice of events to aggregate
  • field: Optional field name to aggregate (defaults to “value”)
§Returns

The aggregated value, or Value::Null if no valid values found.

Provided Methods§

Source

fn apply_shared(&self, events: &[SharedEvent], field: Option<&str>) -> Value

Apply aggregation to shared events (avoids cloning in hot paths).

Override this for better performance when events are wrapped in Arc.

Source

fn apply_refs(&self, events: &[&Event], field: Option<&str>) -> Value

Apply aggregation to event references (internal helper)

Source

fn apply_columnar( &self, buffer: &mut ColumnarBuffer, field: Option<&str>, ) -> Value

Apply aggregation to columnar buffer (SIMD-optimized for numeric aggregations).

Default implementation falls back to shared events. Override this for aggregations that can benefit from columnar data layout (sum, avg, min, max).

Implementors§