struct CountGroupsAccumulator {
counts: Vec<i64>,
}Expand description
An accumulator to compute the counts of [PrimitiveArray<T>].
Stores values as native types, and does overflow checking
Unlike most other accumulators, COUNT never produces NULLs. If no non-null values are seen in any group the output is 0. Thus, this accumulator has no additional null or seen filter tracking.
Fields§
§counts: Vec<i64>Count per group.
Note this is an i64 and not a u64 (or usize) because the
output type of count is DataType::Int64. Thus by using i64
for the counts, the output [Int64Array] can be created
without copy.
Implementations§
Trait Implementations§
Source§impl Debug for CountGroupsAccumulator
impl Debug for CountGroupsAccumulator
Source§impl GroupsAccumulator for CountGroupsAccumulator
impl GroupsAccumulator for CountGroupsAccumulator
Source§fn convert_to_state(
&self,
values: &[ArrayRef],
opt_filter: Option<&BooleanArray>,
) -> Result<Vec<ArrayRef>>
fn convert_to_state( &self, values: &[ArrayRef], opt_filter: Option<&BooleanArray>, ) -> Result<Vec<ArrayRef>>
Converts an input batch directly to a state batch
The state of COUNT is always a single Int64Array:
1(for non-null, non filtered values)0(for null values)
Source§fn update_batch(
&mut self,
values: &[ArrayRef],
group_indices: &[usize],
opt_filter: Option<&BooleanArray>,
total_num_groups: usize,
) -> Result<()>
fn update_batch( &mut self, values: &[ArrayRef], group_indices: &[usize], opt_filter: Option<&BooleanArray>, total_num_groups: usize, ) -> Result<()>
Updates the accumulator’s state from its arguments, encoded as
a vector of [
ArrayRef]s. Read moreSource§fn merge_batch(
&mut self,
values: &[ArrayRef],
group_indices: &[usize],
_opt_filter: Option<&BooleanArray>,
total_num_groups: usize,
) -> Result<()>
fn merge_batch( &mut self, values: &[ArrayRef], group_indices: &[usize], _opt_filter: Option<&BooleanArray>, total_num_groups: usize, ) -> Result<()>
Merges intermediate state (the output from [
Self::state])
into this accumulator’s current state. Read moreSource§fn evaluate(&mut self, emit_to: EmitTo) -> Result<ArrayRef>
fn evaluate(&mut self, emit_to: EmitTo) -> Result<ArrayRef>
Returns the final aggregate value for each group as a single
RecordBatch, resetting the internal state. Read moreSource§fn state(&mut self, emit_to: EmitTo) -> Result<Vec<ArrayRef>>
fn state(&mut self, emit_to: EmitTo) -> Result<Vec<ArrayRef>>
Returns the intermediate aggregate state for this accumulator,
used for multi-phase grouping, resetting its internal state. Read more
Source§fn supports_convert_to_state(&self) -> bool
fn supports_convert_to_state(&self) -> bool
Returns
true if [Self::convert_to_state] is implemented to support
intermediate aggregate state conversion.Auto Trait Implementations§
impl Freeze for CountGroupsAccumulator
impl RefUnwindSafe for CountGroupsAccumulator
impl Send for CountGroupsAccumulator
impl Sync for CountGroupsAccumulator
impl Unpin for CountGroupsAccumulator
impl UnwindSafe for CountGroupsAccumulator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more