arrow_buffer::buffer

Struct RunEndBuffer

Source
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> Freeze for RunEndBuffer<E>

§

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 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

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