pub struct NullState { /* private fields */ }
Expand description

Track the accumulator null state per row: if any values for that group were null and if any values have been seen at all for that group.

This is part of the inner loop for many GroupsAccumulators, and thus the performance is critical and so there are multiple specialized implementations, invoked depending on the specific combinations of the input.

Typically there are 4 potential combinations of inputs must be special cased for performance:

  • With / Without filter
  • With / Without nulls in the input

If the input has nulls, then the accumulator must potentially handle each input null value specially (e.g. for SUM to mark the corresponding sum as null)

If there are filters present, NullState tracks if it has seen any value for that group (as some values may be filtered out). Without a filter, the accumulator is only passed groups that had at least one value to accumulate so they do not need to track if they have seen values for a particular group.

Implementations§

Source§

impl NullState

Source

pub fn new() -> Self

Source

pub fn size(&self) -> usize

return the size of all buffers allocated by this null state, not including self

Source

pub fn accumulate<T, F>( &mut self, group_indices: &[usize], values: &PrimitiveArray<T>, opt_filter: Option<&BooleanArray>, total_num_groups: usize, value_fn: F, )
where T: ArrowPrimitiveType + Send, F: FnMut(usize, T::Native) + Send,

Invokes value_fn(group_index, value) for each non null, non filtered value of value, while tracking which groups have seen null inputs and which groups have seen any inputs if necessary

§Arguments:
  • values: the input arguments to the accumulator
  • group_indices: To which groups do the rows in values belong, (aka group_index)
  • opt_filter: if present, only rows for which is Some(true) are included
  • value_fn: function invoked for (group_index, value) where value is non null

See accumulate, for more details on how value_fn is called

When value_fn is called it also sets

  1. self.seen_values[group_index] to true for all rows that had a non null value
Source

pub fn accumulate_boolean<F>( &mut self, group_indices: &[usize], values: &BooleanArray, opt_filter: Option<&BooleanArray>, total_num_groups: usize, value_fn: F, )
where F: FnMut(usize, bool) + Send,

Invokes value_fn(group_index, value) for each non null, non filtered value in values, while tracking which groups have seen null inputs and which groups have seen any inputs, for BooleanArrays.

Since BooleanArray is not a PrimitiveArray it must be handled specially.

See Self::accumulate, which handles PrimitiveArrays, for more details on other arguments.

Source

pub fn build(&mut self, emit_to: EmitTo) -> NullBuffer

Creates the a NullBuffer representing which group_indices should have null values (because they never saw any values) for the emit_to rows.

resets the internal state appropriately

Trait Implementations§

Source§

impl Debug for NullState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for NullState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,