pub trait Accumulator:
Send
+ Sync
+ Debug {
// Required methods
fn state(&self) -> Result<Vec<Value>>;
fn update_batch(&mut self, values: &[VectorRef]) -> Result<()>;
fn merge_batch(&mut self, states: &[VectorRef]) -> Result<()>;
fn evaluate(&self) -> Result<Value>;
}
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
Modified from DataFusion.
Required Methods§
sourcefn state(&self) -> Result<Vec<Value>>
fn state(&self) -> Result<Vec<Value>>
Returns the state of the accumulator at the end of the accumulation.
sourcefn update_batch(&mut self, values: &[VectorRef]) -> Result<()>
fn update_batch(&mut self, values: &[VectorRef]) -> Result<()>
updates the accumulator’s state from a vector of arrays.
sourcefn merge_batch(&mut self, states: &[VectorRef]) -> Result<()>
fn merge_batch(&mut self, states: &[VectorRef]) -> Result<()>
updates the accumulator’s state from a vector of states.