pub enum CompiledAggregate {
Show 14 variants
CountStar {
count: i64,
},
Count {
count: i64,
},
CountDistinct {
distinct_tracker: DistinctTracker,
},
Sum {
state: SumState,
},
SumDistinct {
state: SumState,
distinct_tracker: DistinctTracker,
},
Avg {
sum: f64,
count: i64,
},
AvgDistinct {
sum: f64,
count: i64,
distinct_tracker: DistinctTracker,
},
Min {
min_value: Option<Value>,
},
Max {
max_value: Option<Value>,
},
MinInteger {
min_value: Option<i64>,
},
MaxInteger {
max_value: Option<i64>,
},
MinFloat {
min_value: Option<f64>,
},
MaxFloat {
max_value: Option<f64>,
},
Dynamic(Box<dyn AggregateFunction>),
}Expand description
Compiled aggregate function - enum-based specialization for zero virtual dispatch
This enum provides specialized implementations for the most common aggregate
functions (COUNT, SUM, AVG, MIN, MAX), with a Dynamic fallback for complex
or rare aggregates (STRING_AGG, ARRAY_AGG, MEDIAN, etc.).
Variants§
CountStar
COUNT(*) - counts all rows
Count
COUNT(column) - counts non-NULL values
CountDistinct
COUNT(DISTINCT column) - counts distinct non-NULL values
Fields
distinct_tracker: DistinctTrackerSum
SUM(column) - sums numeric values
SumDistinct
SUM(DISTINCT column) - sums distinct numeric values
Avg
AVG(column) - average of numeric values
AvgDistinct
AVG(DISTINCT column) - average of distinct numeric values
Min
MIN(column) - minimum value (type-generic using Value comparison)
Max
MAX(column) - maximum value (type-generic using Value comparison)
MinInteger
MIN for integers only (faster path)
MaxInteger
MAX for integers only (faster path)
MinFloat
MIN for floats only (faster path)
MaxFloat
MAX for floats only (faster path)
Dynamic(Box<dyn AggregateFunction>)
Fallback to dynamic dispatch for complex aggregates
Implementations§
Source§impl CompiledAggregate
impl CompiledAggregate
Sourcepub fn count_star() -> Self
pub fn count_star() -> Self
Create a compiled COUNT(*) aggregate
Sourcepub fn min_integer() -> Self
pub fn min_integer() -> Self
Create a compiled MIN aggregate for integers
Sourcepub fn max_integer() -> Self
pub fn max_integer() -> Self
Create a compiled MAX aggregate for integers
Sourcepub fn dynamic(func: Box<dyn AggregateFunction>) -> Self
pub fn dynamic(func: Box<dyn AggregateFunction>) -> Self
Create from a dynamic aggregate function (fallback)
Sourcepub fn compile(
name: &str,
is_count_star: bool,
distinct: bool,
dynamic_fallback: Option<Box<dyn AggregateFunction>>,
) -> Option<Self>
pub fn compile( name: &str, is_count_star: bool, distinct: bool, dynamic_fallback: Option<Box<dyn AggregateFunction>>, ) -> Option<Self>
Compile from a function name and configuration
Returns a compiled aggregate for common functions, or wraps the provided dynamic function for complex/rare aggregates.
Sourcepub fn accumulate(&mut self, value: &Value)
pub fn accumulate(&mut self, value: &Value)
Accumulate a value into the aggregate
This is the hot path - all code here should be as fast as possible.
Sourcepub fn accumulate_with_distinct(&mut self, value: &Value, distinct: bool)
pub fn accumulate_with_distinct(&mut self, value: &Value, distinct: bool)
Accumulate with DISTINCT flag (for dynamic fallback compatibility)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CompiledAggregate
impl !RefUnwindSafe for CompiledAggregate
impl Send for CompiledAggregate
impl Sync for CompiledAggregate
impl Unpin for CompiledAggregate
impl !UnwindSafe for CompiledAggregate
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> 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