Skip to main content

DynAccumulator

Trait DynAccumulator 

Source
pub trait DynAccumulator: 'static + Send {
    // Required methods
    fn accumulate(
        &mut self,
        batch: &ArrayRef,
        ctx: &mut ExecutionCtx,
    ) -> VortexResult<()>;
    fn merge_from(&mut self, other: &mut dyn DynAccumulator) -> VortexResult<()>;
    fn combine_partials(&mut self, partial: Scalar) -> VortexResult<()>;
    fn is_saturated(&self) -> bool;
    fn reset(&mut self);
    fn partial_scalar(&self) -> VortexResult<Scalar>;
    fn final_scalar(&self) -> VortexResult<Scalar>;
    fn flush(&mut self) -> VortexResult<Scalar>;
    fn finish(&mut self) -> VortexResult<Scalar>;
    fn as_any_mut(&mut self) -> &mut dyn Any;
}
Expand description

A trait object for type-erased accumulators, used for dynamic dispatch when the aggregate function is not known at compile time.

Required Methods§

Source

fn accumulate( &mut self, batch: &ArrayRef, ctx: &mut ExecutionCtx, ) -> VortexResult<()>

Accumulate a new array into the accumulator’s state.

Source

fn merge_from(&mut self, other: &mut dyn DynAccumulator) -> VortexResult<()>

Drain another accumulator’s state into this one, resetting other.

The other accumulator must have been constructed for the same aggregate function, options, and input dtype as this one.

Source

fn combine_partials(&mut self, partial: Scalar) -> VortexResult<()>

Parse a partial scalar and merge it into this accumulator’s state.

The scalar must have the dtype reported by the vtable’s partial_dtype, and represents input following the input already accumulated.

Source

fn is_saturated(&self) -> bool

Whether the accumulator’s result is fully determined.

Source

fn reset(&mut self)

Reset the accumulator’s state to the empty group.

Source

fn partial_scalar(&self) -> VortexResult<Scalar>

Read the current partial state as a scalar without resetting it.

The returned scalar has the dtype reported by the vtable’s partial_dtype.

Source

fn final_scalar(&self) -> VortexResult<Scalar>

Compute the final aggregate result as a scalar without resetting state.

Source

fn flush(&mut self) -> VortexResult<Scalar>

Flush the accumulation state and return the partial aggregate result as a scalar.

Resets the accumulator state back to the initial state.

Source

fn finish(&mut self) -> VortexResult<Scalar>

Finish the accumulation and return the final aggregate result as a scalar.

Resets the accumulator state back to the initial state.

Source

fn as_any_mut(&mut self) -> &mut dyn Any

Access the accumulator as Any, so it can be downcast to a typed Accumulator.

Implementations§

Source§

impl dyn DynAccumulator

Source

pub fn downcast_mut<V: AggregateFnVTable>( &mut self, ) -> Option<&mut Accumulator<V>>

Downcast to the typed Accumulator of the aggregate vtable V.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§