Struct arrow2::offset::Offsets

source ·
pub struct Offsets<O: Offset>(/* private fields */);
Expand description

A wrapper type of Vec<O> representing the invariants of Arrow’s offsets. It is guaranteed to (sound to assume that):

  • every element is >= 0
  • element at position i is >= than element at position i-1.

Implementations§

source§

impl<O: Offset> Offsets<O>

source

pub fn new() -> Self

Returns an empty Offsets (i.e. with a single element, the zero)

source

pub fn new_zeroed(length: usize) -> Self

Returns an Offsets whose all lengths are zero.

source

pub fn try_from_iter<I: IntoIterator<Item = usize>>( iter: I ) -> Result<Self, Error>

Creates a new Offsets from an iterator of lengths

source

pub fn with_capacity(capacity: usize) -> Self

Returns a new Offsets with a capacity, allocating at least capacity + 1 entries.

source

pub fn capacity(&self) -> usize

Returns the capacity of Offsets.

source

pub fn reserve(&mut self, additional: usize)

Reserves additional entries.

source

pub fn shrink_to_fit(&mut self)

Shrinks the capacity of self to fit.

source

pub fn try_push(&mut self, length: O) -> Result<(), Error>

Pushes a new element with a given length.

§Error

This function errors iff the new last item is larger than what O supports.

§Panic

This function asserts that length > 0.

source

pub fn try_push_usize(&mut self, length: usize) -> Result<(), Error>

Pushes a new element with a given length.

§Error

This function errors iff the new last item is larger than what O supports.

§Implementation

This function:

  • checks that this length does not overflow
source

pub unsafe fn new_unchecked(offsets: Vec<O>) -> Self

Returns Offsets assuming that offsets fulfills its invariants

§Safety

This is safe iff the invariants of this struct are guaranteed in offsets.

source

pub fn last(&self) -> &O

Returns the last offset of this container.

source

pub fn start_end(&self, index: usize) -> (usize, usize)

Returns a range (start, end) corresponding to the position index

§Panic

This function panics iff index >= self.len()

source

pub unsafe fn start_end_unchecked(&self, index: usize) -> (usize, usize)

Returns a range (start, end) corresponding to the position index

§Safety

index must be < self.len()

source

pub fn len_proxy(&self) -> usize

Returns the length an array with these offsets would be.

source

pub fn len(&self) -> usize

Returns the number of offsets in this container.

source

pub fn as_slice(&self) -> &[O]

Returns the byte slice stored in this buffer

source

pub fn pop(&mut self) -> Option<O>

Pops the last element

source

pub fn extend_constant(&mut self, additional: usize)

Extends itself with additional elements equal to the last offset. This is useful to extend offsets with empty values, e.g. for null slots.

source

pub fn try_from_lengths<I: Iterator<Item = usize>>( lengths: I ) -> Result<Self, Error>

Try to create a new Offsets from a sequence of lengths

§Errors

This function errors iff this operation overflows for the maximum value of O.

source

pub fn try_extend_from_lengths<I: Iterator<Item = usize>>( &mut self, lengths: I ) -> Result<(), Error>

Try extend from an iterator of lengths

§Errors

This function errors iff this operation overflows for the maximum value of O.

source

pub fn try_extend_from_self(&mut self, other: &Self) -> Result<(), Error>

Extends itself from another Offsets

§Errors

This function errors iff this operation overflows for the maximum value of O.

source

pub fn try_extend_from_slice( &mut self, other: &OffsetsBuffer<O>, start: usize, length: usize ) -> Result<(), Error>

Extends itself from another Offsets sliced by start, length

§Errors

This function errors iff this operation overflows for the maximum value of O.

source

pub fn into_inner(self) -> Vec<O>

Returns the inner Vec.

Trait Implementations§

source§

impl<O: Clone + Offset> Clone for Offsets<O>

source§

fn clone(&self) -> Offsets<O>

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<O: Debug + Offset> Debug for Offsets<O>

source§

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

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

impl<O: Offset> Default for Offsets<O>

source§

fn default() -> Self

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

impl<O: Offset> From<Offsets<O>> for OffsetsBuffer<O>

source§

fn from(offsets: Offsets<O>) -> Self

Converts to this type from the input type.
source§

impl From<Offsets<i32>> for Offsets<i64>

source§

fn from(offsets: Offsets<i32>) -> Self

Converts to this type from the input type.
source§

impl<O: PartialEq + Offset> PartialEq for Offsets<O>

source§

fn eq(&self, other: &Offsets<O>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<Offsets<i64>> for Offsets<i32>

§

type Error = Error

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

fn try_from(offsets: Offsets<i64>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<O: Offset> TryFrom<Vec<O>> for Offsets<O>

§

type Error = Error

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

fn try_from(offsets: Vec<O>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<O: Eq + Offset> Eq for Offsets<O>

source§

impl<O: Offset> StructuralPartialEq for Offsets<O>

Auto Trait Implementations§

§

impl<O> Freeze for Offsets<O>

§

impl<O> RefUnwindSafe for Offsets<O>
where O: RefUnwindSafe,

§

impl<O> Send for Offsets<O>

§

impl<O> Sync for Offsets<O>

§

impl<O> Unpin for Offsets<O>
where O: Unpin,

§

impl<O> UnwindSafe for Offsets<O>
where O: 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> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

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,

§

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

§

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

§

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.