Skip to main content

AggregateFnVTable

Trait AggregateFnVTable 

Source
pub trait AggregateFnVTable:
    'static
    + Sized
    + Clone
    + Send
    + Sync {
    type Options: 'static + Send + Sync + Clone + Debug + Display + PartialEq + Eq + Hash;
    type Partial: 'static + Send;

Show 16 methods // Required methods fn id(&self) -> AggregateFnId; fn return_dtype( &self, options: &Self::Options, input_dtype: &DType, ) -> Option<DType>; fn partial_dtype( &self, options: &Self::Options, input_dtype: &DType, ) -> Option<DType>; fn empty_partial( &self, args: AggregateArgs<'_, Self::Options>, ) -> VortexResult<Self::Partial>; fn partial_from_scalar( &self, args: AggregateArgs<'_, Self::Options>, scalar: &Scalar, ) -> VortexResult<Self::Partial>; fn merge_partials( &self, args: AggregateArgs<'_, Self::Options>, first: Self::Partial, second: Self::Partial, ) -> VortexResult<Self::Partial>; fn to_scalar( &self, args: AggregateArgs<'_, Self::Options>, partial: &Self::Partial, ) -> VortexResult<Scalar>; fn is_saturated( &self, args: AggregateArgs<'_, Self::Options>, partial: &Self::Partial, ) -> bool; fn accumulate( &self, args: AggregateArgs<'_, Self::Options>, state: &mut Self::Partial, batch: &Columnar, ctx: &mut ExecutionCtx, ) -> VortexResult<()>; fn finalize( &self, args: AggregateArgs<'_, Self::Options>, states: ArrayRef, ) -> VortexResult<ArrayRef>; fn finalize_scalar( &self, args: AggregateArgs<'_, Self::Options>, partial: &Self::Partial, ) -> VortexResult<Scalar>; // Provided methods fn serialize( &self, options: &Self::Options, ) -> VortexResult<Option<Vec<u8>>> { ... } fn deserialize( &self, _metadata: &[u8], _session: &VortexSession, ) -> VortexResult<Self::Options> { ... } fn can_satisfy( &self, options: &Self::Options, requested: &AggregateFnRef, ) -> AggregateFnSatisfaction { ... } fn zone_stat_default(&self, _input_dtype: &DType) -> Option<AggregateFnRef> { ... } fn try_accumulate( &self, _args: AggregateArgs<'_, Self::Options>, _state: &mut Self::Partial, _batch: &ArrayRef, _ctx: &mut ExecutionCtx, ) -> VortexResult<bool> { ... }
}
Expand description

Defines the interface for aggregate function vtables.

This trait is non-object-safe and allows the implementer to make use of associated types for improved type safety, while allowing Vortex to enforce runtime checks on the inputs and outputs of each function.

The AggregateFnVTable trait should be implemented for a struct that holds global data across all instances of the aggregate. In almost all cases, this struct will be an empty unit struct, since most aggregates do not require any global state.

Required Associated Types§

Source

type Options: 'static + Send + Sync + Clone + Debug + Display + PartialEq + Eq + Hash

Options for this aggregate function.

Source

type Partial: 'static + Send

The partial accumulator state for a single group.

Required Methods§

Source

fn id(&self) -> AggregateFnId

Returns the ID of the aggregate function vtable.

Source

fn return_dtype( &self, options: &Self::Options, input_dtype: &DType, ) -> Option<DType>

The return DType of the aggregate.

Returns None if the aggregate function cannot be applied to the input dtype.

Source

fn partial_dtype( &self, options: &Self::Options, input_dtype: &DType, ) -> Option<DType>

DType of the intermediate partial accumulator state.

Use a struct dtype when multiple fields are needed (e.g., Mean: Struct { sum: f64, count: u64 }).

Returns None if the aggregate function cannot be applied to the input dtype.

Source

fn empty_partial( &self, args: AggregateArgs<'_, Self::Options>, ) -> VortexResult<Self::Partial>

The partial state of a group with no accumulated values.

The identity of merge_partials.

Source

fn partial_from_scalar( &self, args: AggregateArgs<'_, Self::Options>, scalar: &Scalar, ) -> VortexResult<Self::Partial>

Parse a partial scalar into the typed partial state.

The scalar must have dtype args.partial_dtype; this is the inverse of to_scalar.

Source

fn merge_partials( &self, args: AggregateArgs<'_, Self::Options>, first: Self::Partial, second: Self::Partial, ) -> VortexResult<Self::Partial>

Merge two partial states into one.

first accumulated the input preceding second’s. Order-dependent aggregates (e.g. first/last or is_sorted) rely on this, so the merge need not be commutative. Merging with empty_partial on either side is the identity.

Source

fn to_scalar( &self, args: AggregateArgs<'_, Self::Options>, partial: &Self::Partial, ) -> VortexResult<Scalar>

Convert the partial state into a partial scalar of dtype args.partial_dtype.

This is the inverse of partial_from_scalar: parsing the returned scalar must reconstruct an equivalent state.

Source

fn is_saturated( &self, args: AggregateArgs<'_, Self::Options>, partial: &Self::Partial, ) -> bool

Is the partial state “saturated”, i.e. has it reached a state where the final result is fully determined.

Source

fn accumulate( &self, args: AggregateArgs<'_, Self::Options>, state: &mut Self::Partial, batch: &Columnar, ctx: &mut ExecutionCtx, ) -> VortexResult<()>

Accumulate a new canonical array into the partial state.

Source

fn finalize( &self, args: AggregateArgs<'_, Self::Options>, states: ArrayRef, ) -> VortexResult<ArrayRef>

Finalize an array of partial states into an array of aggregate results.

The states array has dtype args.partial_dtype; the result must have dtype args.return_dtype.

Source

fn finalize_scalar( &self, args: AggregateArgs<'_, Self::Options>, partial: &Self::Partial, ) -> VortexResult<Scalar>

Finalize a partial state into an aggregate result of dtype args.return_dtype.

Provided Methods§

Source

fn serialize(&self, options: &Self::Options) -> VortexResult<Option<Vec<u8>>>

Serialize the options for this aggregate function.

Should return Ok(None) if the function is not serializable, and Ok(vec![]) if it is serializable but has no metadata.

Source

fn deserialize( &self, _metadata: &[u8], _session: &VortexSession, ) -> VortexResult<Self::Options>

Deserialize the options of this aggregate function.

Source

fn can_satisfy( &self, options: &Self::Options, requested: &AggregateFnRef, ) -> AggregateFnSatisfaction

Return whether this stored aggregate can satisfy requested.

The default implementation only treats exactly equal aggregate functions as satisfying the request. Approximate pruning aggregates can override this to expose looser-but-sound bounds.

Source

fn zone_stat_default(&self, _input_dtype: &DType) -> Option<AggregateFnRef>

If this aggregate should be computed as a default zone statistic for input_dtype, return the bound aggregate to store. Default: not a zone-map default.

Source

fn try_accumulate( &self, _args: AggregateArgs<'_, Self::Options>, _state: &mut Self::Partial, _batch: &ArrayRef, _ctx: &mut ExecutionCtx, ) -> VortexResult<bool>

Try to accumulate the raw array before decompression.

Returns true if the array was handled, false to fall through to the default kernel dispatch and canonicalization path. When returning false, the partial state must be unchanged, since the same batch is then accumulated by the fallback path.

This is useful for aggregates that only depend on array metadata (e.g., validity) rather than the encoded data, avoiding unnecessary decompression.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl AggregateFnVTable for AllNan

Source§

impl AggregateFnVTable for AllNonDistinct

Source§

impl AggregateFnVTable for AllNonNan

Source§

impl AggregateFnVTable for AllNonNull

Source§

impl AggregateFnVTable for AllNull

Source§

impl AggregateFnVTable for BoundedMax

Source§

impl AggregateFnVTable for BoundedMin

Source§

impl AggregateFnVTable for Count

Source§

impl AggregateFnVTable for First

Source§

impl AggregateFnVTable for IsConstant

Source§

impl AggregateFnVTable for IsSorted

Source§

impl AggregateFnVTable for Last

Source§

impl AggregateFnVTable for Max

Source§

impl AggregateFnVTable for Min

Source§

impl AggregateFnVTable for MinMax

Source§

impl AggregateFnVTable for NanCount

Source§

impl AggregateFnVTable for NullCount

Source§

impl AggregateFnVTable for Sum

Source§

impl AggregateFnVTable for SumV2

Source§

impl AggregateFnVTable for UncompressedSizeInBytes

Source§

impl<T: BinaryCombined> AggregateFnVTable for Combined<T>