pub struct RunEndBuffer<E: ArrowNativeType> { /* private fields */ }
Expand description

A slice-able buffer of monotonically increasing, positive integers used to store run-ends

Logical vs Physical

A RunEndBuffer is used to encode runs of the same value, the index of each run is called the physical index. The logical index is then the corresponding index in the logical run-encoded array, i.e. a single run of length 3, would have the logical indices 0..3.

Each value in RunEndBuffer::values is the cumulative length of all runs in the logical array, up to that physical index.

Consider a RunEndBuffer containing [3, 4, 6]. The maximum physical index is 2, as there are 3 values, and the maximum logical index is 5, as the maximum run end is 6. The physical indices are therefore [0, 0, 0, 1, 2, 2]

    ┌─────────┐        ┌─────────┐           ┌─────────┐
    │    3    │        │    0    │ ─┬──────▶ │    0    │
    ├─────────┤        ├─────────┤  │        ├─────────┤
    │    4    │        │    1    │ ─┤ ┌────▶ │    1    │
    ├─────────┤        ├─────────┤  │ │      ├─────────┤
    │    6    │        │    2    │ ─┘ │ ┌──▶ │    2    │
    └─────────┘        ├─────────┤    │ │    └─────────┘
     run ends          │    3    │ ───┘ │  physical indices
                       ├─────────┤      │
                       │    4    │ ─────┤
                       ├─────────┤      │
                       │    5    │ ─────┘
                       └─────────┘
                     logical indices

Slicing

In order to provide zero-copy slicing, this container stores a separate offset and length

For example, a RunEndBuffer containing values [3, 6, 8] with offset and length 4 would describe the physical indices 1, 1, 2, 2

For example, a RunEndBuffer containing values [6, 8, 9] with offset 2 and length 5 would describe the physical indices 0, 0, 0, 0, 1

Implementations§

source§

impl<E> RunEndBuffer<E>where E: ArrowNativeType,

source

pub fn new(run_ends: ScalarBuffer<E>, offset: usize, len: usize) -> Self

Create a new RunEndBuffer from a ScalarBuffer, an offset and len

Panics
  • buffer does not contain strictly increasing values greater than zero
  • the last value of buffer is less than offset + len
source

pub unsafe fn new_unchecked( run_ends: ScalarBuffer<E>, offset: usize, len: usize ) -> Self

Create a new RunEndBuffer from an ScalarBuffer, an offset and len

Safety
  • buffer must contain strictly increasing values greater than zero
  • The last value of buffer must be greater than or equal to offset + len
source

pub fn offset(&self) -> usize

Returns the logical offset into the run-ends stored by this buffer

source

pub fn len(&self) -> usize

Returns the logical length of the run-ends stored by this buffer

source

pub fn is_empty(&self) -> bool

Returns true if this buffer is empty

source

pub fn values(&self) -> &[E]

Returns the values of this RunEndBuffer not including any offset

source

pub fn max_value(&self) -> usize

Returns the maximum run-end encoded in the underlying buffer

source

pub fn get_physical_index(&self, logical_index: usize) -> usize

Performs a binary search to find the physical index for the given logical index

The result is arbitrary if logical_index >= self.len()

source

pub fn get_start_physical_index(&self) -> usize

Returns the physical index at which the logical array starts

source

pub fn get_end_physical_index(&self) -> usize

Returns the physical index at which the logical array ends

source

pub fn slice(&self, offset: usize, len: usize) -> Self

Slices this RunEndBuffer by the provided offset and length

source

pub fn inner(&self) -> &ScalarBuffer<E>

Returns the inner ScalarBuffer

source

pub fn into_inner(self) -> ScalarBuffer<E>

Returns the inner ScalarBuffer, consuming self

Trait Implementations§

source§

impl<E: Clone + ArrowNativeType> Clone for RunEndBuffer<E>

source§

fn clone(&self) -> RunEndBuffer<E>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<E: Debug + ArrowNativeType> Debug for RunEndBuffer<E>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<E> RefUnwindSafe for RunEndBuffer<E>where E: RefUnwindSafe,

§

impl<E> Send for RunEndBuffer<E>

§

impl<E> Sync for RunEndBuffer<E>

§

impl<E> Unpin for RunEndBuffer<E>where E: Unpin,

§

impl<E> UnwindSafe for RunEndBuffer<E>where E: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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 Twhere T: RefUnwindSafe + Send + Sync,