Trait datafusion_expr::Accumulator
source · [−]pub trait Accumulator: Send + Sync + Debug {
fn state(&self) -> Result<Vec<ScalarValue>>;
fn update_batch(&mut self, values: &[ArrayRef]) -> Result<()>;
fn merge_batch(&mut self, states: &[ArrayRef]) -> Result<()>;
fn evaluate(&self) -> Result<ScalarValue>;
}
Expand description
An accumulator represents a stateful object that lives throughout the evaluation of multiple rows and generically accumulates values.
An accumulator knows how to:
- update its state from inputs via
update_batch
- convert its internal state to a vector of scalar values
- update its state from multiple accumulators’ states via
merge_batch
- compute the final value from its internal state via
evaluate
Required methods
fn state(&self) -> Result<Vec<ScalarValue>>
fn state(&self) -> Result<Vec<ScalarValue>>
Returns the state of the accumulator at the end of the accumulation.
updates the accumulator’s state from a vector of arrays.
updates the accumulator’s state from a vector of states.
fn evaluate(&self) -> Result<ScalarValue>
fn evaluate(&self) -> Result<ScalarValue>
returns its value based on its current state.