pub trait RowAccumulator: Send + Sync + Debug {
    // Required methods
    fn update_batch(
        &mut self,
        values: &[Arc<dyn Array>],
        accessor: &mut RowAccessor<'_>
    ) -> Result<(), DataFusionError>;
    fn update_scalar_values(
        &mut self,
        values: &[ScalarValue],
        accessor: &mut RowAccessor<'_>
    ) -> Result<(), DataFusionError>;
    fn update_scalar(
        &mut self,
        value: &ScalarValue,
        accessor: &mut RowAccessor<'_>
    ) -> Result<(), DataFusionError>;
    fn merge_batch(
        &mut self,
        states: &[Arc<dyn Array>],
        accessor: &mut RowAccessor<'_>
    ) -> Result<(), DataFusionError>;
    fn evaluate(
        &self,
        accessor: &RowAccessor<'_>
    ) -> Result<ScalarValue, DataFusionError>;
    fn state_index(&self) -> usize;
}
Expand description

Row-based accumulator where the internal aggregate state(s) are stored using row format.

Unlike the datafusion_expr::Accumulator, the RowAccumulator does not store the state internally. Instead, it knows how to access/update the state stored in a row via the the provided accessor and its state’s starting field index in the row.

For example, we are evaluating SELECT a, sum(b), avg(c), count(d) from GROUP BY a;, we would have one row used as aggregation state for each distinct a value, the index of the first and the only state of sum(b) would be 0, the index of the first state of avg(c) would be 1, and the index of the first and only state of cound(d) would be 3:

sum(b) state_index = 0 count(d) state_index = 3 | | v v +––––+–––––+––––+–––––+ | sum(b) | count(c) | sum(c) | count(d) | +––––+–––––+––––+–––––+ ^ | avg(c) state_index = 1

Required Methods§

source

fn update_batch( &mut self, values: &[Arc<dyn Array>], accessor: &mut RowAccessor<'_> ) -> Result<(), DataFusionError>

updates the accumulator’s state from a vector of arrays.

source

fn update_scalar_values( &mut self, values: &[ScalarValue], accessor: &mut RowAccessor<'_> ) -> Result<(), DataFusionError>

updates the accumulator’s state from a vector of Scalar value.

source

fn update_scalar( &mut self, value: &ScalarValue, accessor: &mut RowAccessor<'_> ) -> Result<(), DataFusionError>

updates the accumulator’s state from a Scalar value.

source

fn merge_batch( &mut self, states: &[Arc<dyn Array>], accessor: &mut RowAccessor<'_> ) -> Result<(), DataFusionError>

updates the accumulator’s state from a vector of states.

source

fn evaluate( &self, accessor: &RowAccessor<'_> ) -> Result<ScalarValue, DataFusionError>

returns its value based on its current state.

source

fn state_index(&self) -> usize

State’s starting field index in the row.

Implementors§