Struct arrow2::array::BinaryArray
source · [−]pub struct BinaryArray<O: Offset> { /* private fields */ }
Expand description
A BinaryArray
is a nullable array of bytes - the Arrow equivalent of Vec<Option<Vec<u8>>>
.
Safety
The following invariants hold:
- Two consecutives
offsets
casted (as
) tousize
are valid slices ofvalues
. len
is equal tovalidity.len()
, when defined.
Implementations
sourceimpl<'a, O: Offset> BinaryArray<O>
impl<'a, O: Offset> BinaryArray<O>
sourcepub fn iter(&'a self) -> ZipValidity<'a, &'a [u8], BinaryValueIter<'a, O>>ⓘNotable traits for ZipValidity<'a, T, I>impl<'a, T, I: Iterator<Item = T>> Iterator for ZipValidity<'a, T, I> type Item = Option<T>;
pub fn iter(&'a self) -> ZipValidity<'a, &'a [u8], BinaryValueIter<'a, O>>ⓘNotable traits for ZipValidity<'a, T, I>impl<'a, T, I: Iterator<Item = T>> Iterator for ZipValidity<'a, T, I> type Item = Option<T>;
Returns an iterator of Option<&[u8]>
sourcepub fn values_iter(&'a self) -> BinaryValueIter<'a, O>ⓘNotable traits for BinaryValueIter<'a, O>impl<'a, O: Offset> Iterator for BinaryValueIter<'a, O> type Item = &'a [u8];
pub fn values_iter(&'a self) -> BinaryValueIter<'a, O>ⓘNotable traits for BinaryValueIter<'a, O>impl<'a, O: Offset> Iterator for BinaryValueIter<'a, O> type Item = &'a [u8];
Returns an iterator of &[u8]
sourceimpl<O: Offset> BinaryArray<O>
impl<O: Offset> BinaryArray<O>
sourcepub fn from_slice<T: AsRef<[u8]>, P: AsRef<[T]>>(slice: P) -> Self
pub fn from_slice<T: AsRef<[u8]>, P: AsRef<[T]>>(slice: P) -> Self
Creates a new BinaryArray
from slices of &[u8]
.
sourcepub fn from<T: AsRef<[u8]>, P: AsRef<[Option<T>]>>(slice: P) -> Self
pub fn from<T: AsRef<[u8]>, P: AsRef<[Option<T>]>>(slice: P) -> Self
Creates a new BinaryArray
from a slice of optional &[u8]
.
sourcepub fn from_trusted_len_values_iter<T: AsRef<[u8]>, I: TrustedLen<Item = T>>(
iterator: I
) -> Self
pub fn from_trusted_len_values_iter<T: AsRef<[u8]>, I: TrustedLen<Item = T>>(
iterator: I
) -> Self
Creates a BinaryArray
from an iterator of trusted length.
sourcepub fn from_iter_values<T: AsRef<[u8]>, I: Iterator<Item = T>>(
iterator: I
) -> Self
pub fn from_iter_values<T: AsRef<[u8]>, I: Iterator<Item = T>>(
iterator: I
) -> Self
Creates a new BinaryArray
from a Iterator
of &str
.
sourceimpl<O: Offset> BinaryArray<O>
impl<O: Offset> BinaryArray<O>
sourcepub unsafe fn from_trusted_len_iter_unchecked<I, P>(iterator: I) -> Self where
P: AsRef<[u8]>,
I: Iterator<Item = Option<P>>,
pub unsafe fn from_trusted_len_iter_unchecked<I, P>(iterator: I) -> Self where
P: AsRef<[u8]>,
I: Iterator<Item = Option<P>>,
Creates a BinaryArray
from an iterator of trusted length.
Safety
The iterator must be TrustedLen
.
I.e. that size_hint().1
correctly reports its length.
sourcepub fn from_trusted_len_iter<I, P>(iterator: I) -> Self where
P: AsRef<[u8]>,
I: TrustedLen<Item = Option<P>>,
pub fn from_trusted_len_iter<I, P>(iterator: I) -> Self where
P: AsRef<[u8]>,
I: TrustedLen<Item = Option<P>>,
Creates a BinaryArray
from an iterator of trusted length.
sourcepub unsafe fn try_from_trusted_len_iter_unchecked<E, I, P>(
iterator: I
) -> Result<Self, E> where
P: AsRef<[u8]>,
I: IntoIterator<Item = Result<Option<P>, E>>,
pub unsafe fn try_from_trusted_len_iter_unchecked<E, I, P>(
iterator: I
) -> Result<Self, E> where
P: AsRef<[u8]>,
I: IntoIterator<Item = Result<Option<P>, E>>,
Creates a BinaryArray
from an falible iterator of trusted length.
Safety
The iterator must be TrustedLen
.
I.e. that size_hint().1
correctly reports its length.
sourcepub fn try_from_trusted_len_iter<E, I, P>(iter: I) -> Result<Self, E> where
P: AsRef<[u8]>,
I: TrustedLen<Item = Result<Option<P>, E>>,
pub fn try_from_trusted_len_iter<E, I, P>(iter: I) -> Result<Self, E> where
P: AsRef<[u8]>,
I: TrustedLen<Item = Result<Option<P>, E>>,
Creates a BinaryArray
from an fallible iterator of trusted length.
sourceimpl<O: Offset> BinaryArray<O>
impl<O: Offset> BinaryArray<O>
sourcepub fn try_new(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Result<Self>
pub fn try_new(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Result<Self>
Creates a new BinaryArray
.
Errors
This function returns an error iff:
- the offsets are not monotonically increasing
- The last offset is not equal to the values’ length.
- the validity’s length is not equal to
offsets.len() - 1
. - The
data_type
’scrate::datatypes::PhysicalType
is not equal to eitherBinary
orLargeBinary
.
Implementation
This function is O(N)
- checking monotinicity is O(N)
sourcepub fn new(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Self
pub fn new(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Self
Creates a new BinaryArray
.
Panics
- the offsets are not monotonically increasing
- The last offset is not equal to the values’ length.
- the validity’s length is not equal to
offsets.len() - 1
. - The
data_type
’scrate::datatypes::PhysicalType
is not equal to eitherBinary
orLargeBinary
.
Implementation
This function is O(N)
- checking monotinicity is O(N)
sourcepub fn from_data(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Self
pub fn from_data(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Self
Alias for new
sourcepub fn new_empty(data_type: DataType) -> Self
pub fn new_empty(data_type: DataType) -> Self
Creates an empty BinaryArray
, i.e. whose .len
is zero.
sourcepub fn new_null(data_type: DataType, length: usize) -> Self
pub fn new_null(data_type: DataType, length: usize) -> Self
Creates an null BinaryArray
, i.e. whose .null_count() == .len()
.
sourcepub fn default_data_type() -> DataType
pub fn default_data_type() -> DataType
Returns the default DataType
, DataType::Binary
or DataType::LargeBinary
sourceimpl<O: Offset> BinaryArray<O>
impl<O: Offset> BinaryArray<O>
sourcepub unsafe fn try_new_unchecked(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Result<Self>
pub unsafe fn try_new_unchecked(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Result<Self>
Creates a new BinaryArray
without checking for offsets monotinicity.
Errors
This function returns an error iff:
- The last offset is not equal to the values’ length.
- the validity’s length is not equal to
offsets.len() - 1
. - The
data_type
’scrate::datatypes::PhysicalType
is not equal to eitherBinary
orLargeBinary
.
Safety
This function is unsafe iff:
- the offsets are not monotonically increasing
Implementation
This function is O(1)
sourcepub unsafe fn new_unchecked(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Self
pub unsafe fn new_unchecked(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Self
Creates a new BinaryArray
without checking for offsets monotinicity.
Panics
This function returns an error iff:
- The last offset is not equal to the values’ length.
- the validity’s length is not equal to
offsets.len() - 1
. - The
data_type
’scrate::datatypes::PhysicalType
is not equal to eitherBinary
orLargeBinary
.
Safety
This function is unsafe iff:
- the offsets are not monotonically increasing
Implementation
This function is O(1)
sourceimpl<O: Offset> BinaryArray<O>
impl<O: Offset> BinaryArray<O>
sourcepub fn slice(&self, offset: usize, length: usize) -> Self
pub fn slice(&self, offset: usize, length: usize) -> Self
Creates a new BinaryArray
by slicing this BinaryArray
.
Implementation
This function is O(1)
: all data will be shared between both arrays.
Panics
iff offset + length > self.len()
.
sourcepub unsafe fn slice_unchecked(&self, offset: usize, length: usize) -> Self
pub unsafe fn slice_unchecked(&self, offset: usize, length: usize) -> Self
Creates a new BinaryArray
by slicing this BinaryArray
.
Implementation
This function is O(1)
: all data will be shared between both arrays.
Safety
The caller must ensure that offset + length <= self.len()
.
sourcepub fn with_validity(&self, validity: Option<Bitmap>) -> Self
pub fn with_validity(&self, validity: Option<Bitmap>) -> Self
sourceimpl<O: Offset> BinaryArray<O>
impl<O: Offset> BinaryArray<O>
sourcepub fn value(&self, i: usize) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn value(&self, i: usize) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
sourcepub unsafe fn value_unchecked(&self, i: usize) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub unsafe fn value_unchecked(&self, i: usize) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Trait Implementations
sourceimpl<O: Offset> Array for BinaryArray<O>
impl<O: Offset> Array for BinaryArray<O>
sourcefn data_type(&self) -> &DataType
fn data_type(&self) -> &DataType
The DataType
of the Array
. In combination with Array::as_any
, this can be
used to downcast trait objects (dyn Array
) to concrete arrays. Read more
sourcefn null_count(&self) -> usize
fn null_count(&self) -> usize
sourceimpl<O: Clone + Offset> Clone for BinaryArray<O>
impl<O: Clone + Offset> Clone for BinaryArray<O>
sourcefn clone(&self) -> BinaryArray<O>
fn clone(&self) -> BinaryArray<O>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<O: Offset> Debug for BinaryArray<O>
impl<O: Offset> Debug for BinaryArray<O>
sourceimpl<'a, O: Offset> From<GrowableBinary<'a, O>> for BinaryArray<O>
impl<'a, O: Offset> From<GrowableBinary<'a, O>> for BinaryArray<O>
sourcefn from(val: GrowableBinary<'a, O>) -> Self
fn from(val: GrowableBinary<'a, O>) -> Self
Performs the conversion.
sourceimpl<O: Offset> From<MutableBinaryArray<O>> for BinaryArray<O>
impl<O: Offset> From<MutableBinaryArray<O>> for BinaryArray<O>
sourcefn from(other: MutableBinaryArray<O>) -> Self
fn from(other: MutableBinaryArray<O>) -> Self
Performs the conversion.
sourceimpl<O: Offset, P: AsRef<[u8]>> FromIterator<Option<P>> for BinaryArray<O>
impl<O: Offset, P: AsRef<[u8]>> FromIterator<Option<P>> for BinaryArray<O>
sourcefn from_iter<I: IntoIterator<Item = Option<P>>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = Option<P>>>(iter: I) -> Self
Creates a value from an iterator. Read more
sourceimpl<O: Offset> GenericBinaryArray<O> for BinaryArray<O>
impl<O: Offset> GenericBinaryArray<O> for BinaryArray<O>
sourceimpl<'a, O: Offset> IntoIterator for &'a BinaryArray<O>
impl<'a, O: Offset> IntoIterator for &'a BinaryArray<O>
sourceimpl<O: Offset> PartialEq<&'_ (dyn Array + '_)> for BinaryArray<O>
impl<O: Offset> PartialEq<&'_ (dyn Array + '_)> for BinaryArray<O>
Auto Trait Implementations
impl<O> RefUnwindSafe for BinaryArray<O> where
O: RefUnwindSafe,
impl<O> Send for BinaryArray<O>
impl<O> Sync for BinaryArray<O>
impl<O> Unpin for BinaryArray<O>
impl<O> UnwindSafe for BinaryArray<O> where
O: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more