Enum LengthTracker

Source
pub(crate) enum LengthTracker {
    Fixed {
        length: usize,
        num_rows: usize,
    },
    Variable {
        fixed_length: usize,
        lengths: Vec<usize>,
    },
}
Expand description

Stores the lengths of the rows. Lazily materializes lengths for columns with fixed-size types.

Variants§

§

Fixed

Fixed state: All rows have length length

Fields

§length: usize
§num_rows: usize
§

Variable

Variable state: The length of row i is lengths[i] + fixed_length

Fields

§fixed_length: usize
§lengths: Vec<usize>

Implementations§

Source§

impl LengthTracker

Source

pub(crate) fn new(num_rows: usize) -> Self

Source

pub(crate) fn push_fixed(&mut self, new_length: usize)

Adds a column of fixed-length elements, each of size new_length to the LengthTracker

Source

pub(crate) fn push_variable( &mut self, new_lengths: impl ExactSizeIterator<Item = usize>, )

Adds a column of possibly variable-length elements, element i has length new_lengths.nth(i)

Source

pub(crate) fn materialized(&mut self) -> &mut [usize]

Returns the tracked row lengths as a slice

Source

pub(crate) fn extend_offsets( &self, initial_offset: usize, offsets: &mut Vec<usize>, ) -> usize

Initializes the offsets using the tracked lengths. Returns the sum of the lengths of the rows added.

We initialize the offsets shifted down by one row index.

As the rows are appended to the offsets will be incremented to match

For example, consider the case of 3 rows of length 3, 4, and 6 respectively. The offsets would be initialized to 0, 0, 3, 7

Writing the first row entirely would yield 0, 3, 3, 7 The second, 0, 3, 7, 7 The third, 0, 3, 7, 13 This would be the final offsets for reading In this way offsets tracks the position during writing whilst eventually serving

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, 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.
§

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