Skip to main content

AggregateState

Enum AggregateState 

Source
pub enum AggregateState {
Show 25 variants Count(i64), CountDistinct(i64, HashSet<HashableValue>), SumInt(i64, i64), SumIntDistinct(i64, i64, HashSet<HashableValue>), SumFloat(f64, f64, i64), SumFloatDistinct(f64, f64, i64, HashSet<HashableValue>), Avg(f64, i64), AvgDistinct(f64, i64, HashSet<HashableValue>), Min(Option<Value>), Max(Option<Value>), First(Option<Value>), Last(Option<Value>), Collect(Vec<Value>), CollectDistinct(Vec<Value>, HashSet<HashableValue>), StdDev { count: i64, mean: f64, m2: f64, }, StdDevPop { count: i64, mean: f64, m2: f64, }, PercentileDisc { values: Vec<f64>, percentile: f64, }, PercentileCont { values: Vec<f64>, percentile: f64, }, GroupConcat(Vec<String>, String), GroupConcatDistinct(Vec<String>, String, HashSet<HashableValue>), Sample(Option<Value>), Variance { count: i64, mean: f64, m2: f64, }, VariancePop { count: i64, mean: f64, m2: f64, }, Bivariate { kind: AggregateFunction, count: i64, mean_x: f64, mean_y: f64, m2_x: f64, m2_y: f64, c_xy: f64, }, Frozen(Value),
}
Expand description

State for a single aggregation computation.

Used by both the pull-based HashAggregateOperator and the push-based AggregatePushOperator. Supports all AggregateFunction variants including Welford’s algorithm for online statistics, Kahan summation, distinct tracking, and bivariate regression functions.

Variants§

§

Count(i64)

Count state.

§

CountDistinct(i64, HashSet<HashableValue>)

Count distinct state (count, seen values).

§

SumInt(i64, i64)

Sum state (integer sum, count of values added).

§

SumIntDistinct(i64, i64, HashSet<HashableValue>)

Sum distinct state (integer sum, count, seen values).

§

SumFloat(f64, f64, i64)

Sum state (float sum, count of values added).

§

SumFloatDistinct(f64, f64, i64, HashSet<HashableValue>)

Sum distinct state (float sum, compensation, count, seen values).

§

Avg(f64, i64)

Average state (sum, count).

§

AvgDistinct(f64, i64, HashSet<HashableValue>)

Average distinct state (sum, count, seen values).

§

Min(Option<Value>)

Min state.

§

Max(Option<Value>)

Max state.

§

First(Option<Value>)

First state.

§

Last(Option<Value>)

Last state.

§

Collect(Vec<Value>)

Collect state.

§

CollectDistinct(Vec<Value>, HashSet<HashableValue>)

Collect distinct state (values, seen).

§

StdDev

Sample standard deviation state using Welford’s algorithm (count, mean, M2).

Fields

§count: i64
§mean: f64
§m2: f64
§

StdDevPop

Population standard deviation state using Welford’s algorithm (count, mean, M2).

Fields

§count: i64
§mean: f64
§m2: f64
§

PercentileDisc

Discrete percentile state (values, percentile).

Fields

§values: Vec<f64>
§percentile: f64
§

PercentileCont

Continuous percentile state (values, percentile).

Fields

§values: Vec<f64>
§percentile: f64
§

GroupConcat(Vec<String>, String)

GROUP_CONCAT / LISTAGG state (collected string values, separator).

§

GroupConcatDistinct(Vec<String>, String, HashSet<HashableValue>)

GROUP_CONCAT / LISTAGG distinct state (collected string values, separator, seen).

§

Sample(Option<Value>)

SAMPLE state (first non-null value encountered).

§

Variance

Sample variance state using Welford’s algorithm (count, mean, M2).

Fields

§count: i64
§mean: f64
§m2: f64
§

VariancePop

Population variance state using Welford’s algorithm (count, mean, M2).

Fields

§count: i64
§mean: f64
§m2: f64
§

Bivariate

Two-variable online statistics (Welford generalization for covariance/regression).

Fields

§kind: AggregateFunction

Which binary set function this state will finalize to.

§count: i64
§mean_x: f64
§mean_y: f64
§m2_x: f64
§m2_y: f64
§c_xy: f64
§

Frozen(Value)

Immutable finalized value restored from spill. Ignores further updates so that reloaded groups that were serialized via the FINALIZED fallback do not silently corrupt their result when more rows arrive.

Implementations§

Source§

impl AggregateState

Source

pub fn new( function: AggregateFunction, distinct: bool, percentile: Option<f64>, separator: Option<&str>, ) -> Self

Creates initial state for an aggregation function.

Source

pub fn update(&mut self, value: Option<Value>)

Updates the state with a new value.

For COUNT(*), pass None to count all rows. For column-specific aggregates, pass Some(value) (nulls are skipped by most functions).

Source

pub fn update_bivariate(&mut self, y_val: Option<Value>, x_val: Option<Value>)

Updates a bivariate (two-variable) aggregate state with a pair of values.

Uses the two-variable Welford online algorithm for numerically stable computation of covariance and related statistics. Skips the update if either value is null.

Source

pub fn finalize(&self) -> Value

Finalizes the state and returns the result value.

Trait Implementations§

Source§

impl Clone for AggregateState

Source§

fn clone(&self) -> AggregateState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AggregateState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.