pub struct Accumulator { /* private fields */ }Expand description
A running aggregate.
Implementations§
Source§impl Accumulator
impl Accumulator
Sourcepub fn new(name: &str, returns: &LogicalType) -> Result<Self>
pub fn new(name: &str, returns: &LogicalType) -> Result<Self>
A fresh accumulator for a named aggregate returning returns.
§Errors
If the name is not an aggregate this crate implements.
Sourcepub fn update(&mut self, args: &[Value]) -> Result<()>
pub fn update(&mut self, args: &[Value]) -> Result<()>
Folds one row in.
§Errors
If the argument count is wrong for the aggregate, if the value is not one the aggregate can accumulate, or if a whole running total overflows.
Sourcepub fn update_run(&mut self, args: &[Vector], rows: usize) -> Result<()>
pub fn update_run(&mut self, args: &[Vector], rows: usize) -> Result<()>
Folds a whole vector in, in one pass over the data and without building a Value per row.
rows is how many rows to fold, which is the row count of the chunk rather than the capacity
of the vectors in it. count(*) takes no argument and reads nothing but that number, and
every other aggregate here takes exactly one vector.
A shape the one pass form does not cover falls through to Accumulator::update per row and
records itself in crate::fallback, so this always reaches the answer the row at a time
loop reaches and never a different one. That is not a slogan about floating point: the
running total below is carried into the vector loop rather than restarted at zero, precisely
so that the additions happen in the same order and round the same way.
§Errors
The same errors Accumulator::update raises, for the same reasons.
Trait Implementations§
Source§impl Clone for Accumulator
impl Clone for Accumulator
Source§fn clone(&self) -> Accumulator
fn clone(&self) -> Accumulator
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more