pub trait DynAccumulator: 'static + Send {
// Required methods
fn accumulate(
&mut self,
batch: &ArrayRef,
ctx: &mut ExecutionCtx,
) -> VortexResult<()>;
fn combine_partials(&mut self, other: 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>;
}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§
Sourcefn accumulate(
&mut self,
batch: &ArrayRef,
ctx: &mut ExecutionCtx,
) -> VortexResult<()>
fn accumulate( &mut self, batch: &ArrayRef, ctx: &mut ExecutionCtx, ) -> VortexResult<()>
Accumulate a new array into the accumulator’s state.
Sourcefn combine_partials(&mut self, other: Scalar) -> VortexResult<()>
fn combine_partials(&mut self, other: Scalar) -> VortexResult<()>
Fold an external partial-state scalar into this accumulator’s state.
The scalar must have the dtype reported by the vtable’s partial_dtype for the
options and input dtype used to construct this accumulator.
Sourcefn is_saturated(&self) -> bool
fn is_saturated(&self) -> bool
Whether the accumulator’s result is fully determined.
Sourcefn partial_scalar(&self) -> VortexResult<Scalar>
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.
Sourcefn final_scalar(&self) -> VortexResult<Scalar>
fn final_scalar(&self) -> VortexResult<Scalar>
Compute the final aggregate result as a scalar without resetting state.
Sourcefn flush(&mut self) -> VortexResult<Scalar>
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.
Sourcefn finish(&mut self) -> VortexResult<Scalar>
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.