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).
StdDevPop
Population standard deviation state using Welford’s algorithm (count, mean, M2).
PercentileDisc
Discrete percentile state (values, percentile).
PercentileCont
Continuous percentile state (values, percentile).
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).
VariancePop
Population variance state using Welford’s algorithm (count, mean, M2).
Bivariate
Two-variable online statistics (Welford generalization for covariance/regression).
Fields
kind: AggregateFunctionWhich binary set function this state will finalize to.
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
impl AggregateState
Sourcepub fn new(
function: AggregateFunction,
distinct: bool,
percentile: Option<f64>,
separator: Option<&str>,
) -> Self
pub fn new( function: AggregateFunction, distinct: bool, percentile: Option<f64>, separator: Option<&str>, ) -> Self
Creates initial state for an aggregation function.
Sourcepub fn update(&mut self, value: Option<Value>)
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).
Sourcepub fn update_bivariate(&mut self, y_val: Option<Value>, x_val: Option<Value>)
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.
Trait Implementations§
Source§impl Clone for AggregateState
impl Clone for AggregateState
Source§fn clone(&self) -> AggregateState
fn clone(&self) -> AggregateState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for AggregateState
impl RefUnwindSafe for AggregateState
impl Send for AggregateState
impl Sync for AggregateState
impl Unpin for AggregateState
impl UnsafeUnpin for AggregateState
impl UnwindSafe for AggregateState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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