pub struct MutableBinaryArray<O: Offset> { /* private fields */ }
Expand description
The Arrow’s equivalent to Vec<Option<Vec<u8>>>
.
Converting a MutableBinaryArray
into a BinaryArray
is O(1)
.
§Implementation
This struct does not allocate a validity until one is required (i.e. push a null to it).
Implementations§
Source§impl<O: Offset> MutableBinaryArray<O>
impl<O: Offset> MutableBinaryArray<O>
Sourcepub fn try_new(
dtype: ArrowDataType,
offsets: Offsets<O>,
values: Vec<u8>,
validity: Option<MutableBitmap>,
) -> PolarsResult<Self>
pub fn try_new( dtype: ArrowDataType, offsets: Offsets<O>, values: Vec<u8>, validity: Option<MutableBitmap>, ) -> PolarsResult<Self>
Returns a MutableBinaryArray
created from its internal representation.
§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()
. - The
dtype
’scrate::datatypes::PhysicalType
is not equal to eitherBinary
orLargeBinary
.
§Implementation
This function is O(1)
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 MutableBinaryArray
from a slice of optional &[u8]
.
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Initializes a new MutableBinaryArray
with a pre-allocated capacity of slots.
Sourcepub fn with_capacities(capacity: usize, values: usize) -> Self
pub fn with_capacities(capacity: usize, values: usize) -> Self
Initializes a new MutableBinaryArray
with a pre-allocated capacity of slots and values.
§Implementation
This does not allocate the validity.
Sourcepub fn reserve(&mut self, additional: usize, additional_values: usize)
pub fn reserve(&mut self, additional: usize, additional_values: usize)
Reserves additional
elements and additional_values
on the values buffer.
Sourcepub fn push<T: AsRef<[u8]>>(&mut self, value: Option<T>)
pub fn push<T: AsRef<[u8]>>(&mut self, value: Option<T>)
Pushes a new element to the array.
§Panic
This operation panics iff the length of all values (in bytes) exceeds O
maximum value.
Sourcepub fn pop(&mut self) -> Option<Vec<u8>>
pub fn pop(&mut self) -> Option<Vec<u8>>
Pop the last entry from MutableBinaryArray
.
This function returns None
iff this array is empty
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the capacity of the MutableBinaryArray
to fit its current length.
Sourcepub fn with_validity(self, validity: Option<MutableBitmap>) -> Self
pub fn with_validity(self, validity: Option<MutableBitmap>) -> Self
Sourcepub fn set_validity(&mut self, validity: Option<MutableBitmap>)
pub fn set_validity(&mut self, validity: Option<MutableBitmap>)
Sourcepub fn apply_validity<F: FnOnce(MutableBitmap) -> MutableBitmap>(
&mut self,
f: F,
)
pub fn apply_validity<F: FnOnce(MutableBitmap) -> MutableBitmap>( &mut self, f: F, )
Source§impl<O: Offset> MutableBinaryArray<O>
impl<O: Offset> MutableBinaryArray<O>
Sourcepub fn iter(
&self,
) -> ZipValidity<&[u8], ArrayValuesIter<'_, MutableBinaryValuesArray<O>>, BitmapIter<'_>> ⓘ
pub fn iter( &self, ) -> ZipValidity<&[u8], ArrayValuesIter<'_, MutableBinaryValuesArray<O>>, BitmapIter<'_>> ⓘ
Returns an iterator of Option<&[u8]>
Sourcepub fn values_iter(&self) -> ArrayValuesIter<'_, MutableBinaryValuesArray<O>> ⓘ
pub fn values_iter(&self) -> ArrayValuesIter<'_, MutableBinaryValuesArray<O>> ⓘ
Returns an iterator over the values of this array
Source§impl<O: Offset> MutableBinaryArray<O>
impl<O: Offset> MutableBinaryArray<O>
Sourcepub unsafe fn from_trusted_len_iter_unchecked<I, P>(iterator: I) -> Self
pub unsafe fn from_trusted_len_iter_unchecked<I, P>(iterator: I) -> Self
Creates a MutableBinaryArray
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
pub fn from_trusted_len_iter<I, P>(iterator: I) -> Self
Creates a MutableBinaryArray
from an iterator of trusted length.
Sourcepub unsafe fn from_trusted_len_values_iter_unchecked<T: AsRef<[u8]>, I: Iterator<Item = T>>(
iterator: I,
) -> Self
pub unsafe fn from_trusted_len_values_iter_unchecked<T: AsRef<[u8]>, I: Iterator<Item = T>>( iterator: I, ) -> Self
Creates a new BinaryArray
from a TrustedLen
of &[u8]
.
§Safety
The iterator must be TrustedLen
.
I.e. that size_hint().1
correctly reports its length.
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 new BinaryArray
from a TrustedLen
of &[u8]
.
Sourcepub unsafe fn try_from_trusted_len_iter_unchecked<E, I, P>(
iterator: I,
) -> Result<Self, E>
pub unsafe fn try_from_trusted_len_iter_unchecked<E, I, P>( iterator: I, ) -> Result<Self, E>
Creates a MutableBinaryArray
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>(iterator: I) -> Result<Self, E>
pub fn try_from_trusted_len_iter<E, I, P>(iterator: I) -> Result<Self, E>
Creates a MutableBinaryArray
from an falible iterator of trusted length.
Sourcepub fn extend_trusted_len_values<I, P>(&mut self, iterator: I)
pub fn extend_trusted_len_values<I, P>(&mut self, iterator: I)
Extends the MutableBinaryArray
from an iterator of trusted length.
This differs from extend_trusted_len
which accepts iterator of optional values.
Sourcepub fn extend_values<I, P>(&mut self, iterator: I)
pub fn extend_values<I, P>(&mut self, iterator: I)
Extends the MutableBinaryArray
from an iterator of values.
This differs from extended_trusted_len
which accepts iterator of optional values.
Sourcepub unsafe fn extend_trusted_len_values_unchecked<I, P>(&mut self, iterator: I)
pub unsafe fn extend_trusted_len_values_unchecked<I, P>(&mut self, iterator: I)
Extends the MutableBinaryArray
from an iterator
of values of trusted length.
This differs from extend_trusted_len_unchecked
which accepts iterator of optional
values.
§Safety
The iterator
must be TrustedLen
Sourcepub fn extend_trusted_len<I, P>(&mut self, iterator: I)
pub fn extend_trusted_len<I, P>(&mut self, iterator: I)
Extends the MutableBinaryArray
from an iterator of TrustedLen
Sourcepub unsafe fn extend_trusted_len_unchecked<I, P>(&mut self, iterator: I)
pub unsafe fn extend_trusted_len_unchecked<I, P>(&mut self, iterator: I)
Extends the MutableBinaryArray
from an iterator of TrustedLen
§Safety
The iterator
must be TrustedLen
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 MutableBinaryArray
from a Iterator
of &[u8]
.
Sourcepub fn extend_fallible<T, I, E>(&mut self, iter: I) -> Result<(), E>
pub fn extend_fallible<T, I, E>(&mut self, iter: I) -> Result<(), E>
Extend with a fallible iterator
Trait Implementations§
Source§impl<O: Clone + Offset> Clone for MutableBinaryArray<O>
impl<O: Clone + Offset> Clone for MutableBinaryArray<O>
Source§fn clone(&self) -> MutableBinaryArray<O>
fn clone(&self) -> MutableBinaryArray<O>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<O: Offset> Default for MutableBinaryArray<O>
impl<O: Offset> Default for MutableBinaryArray<O>
Source§impl<O: Offset, T: AsRef<[u8]>> Extend<Option<T>> for MutableBinaryArray<O>
impl<O: Offset, T: AsRef<[u8]>> Extend<Option<T>> for MutableBinaryArray<O>
Source§fn extend<I: IntoIterator<Item = Option<T>>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Option<T>>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<O: Offset> From<MutableBinaryArray<O>> for BinaryArray<O>
impl<O: Offset> From<MutableBinaryArray<O>> for BinaryArray<O>
Source§fn from(other: MutableBinaryArray<O>) -> Self
fn from(other: MutableBinaryArray<O>) -> Self
Source§impl<O: Offset> From<MutableBinaryValuesArray<O>> for MutableBinaryArray<O>
impl<O: Offset> From<MutableBinaryValuesArray<O>> for MutableBinaryArray<O>
Source§fn from(other: MutableBinaryValuesArray<O>) -> Self
fn from(other: MutableBinaryValuesArray<O>) -> Self
Source§impl<O: Offset, P: AsRef<[u8]>> FromIterator<Option<P>> for MutableBinaryArray<O>
impl<O: Offset, P: AsRef<[u8]>> FromIterator<Option<P>> for MutableBinaryArray<O>
Source§impl<O: Offset> MutableArray for MutableBinaryArray<O>
impl<O: Offset> MutableArray for MutableBinaryArray<O>
Source§fn validity(&self) -> Option<&MutableBitmap>
fn validity(&self) -> Option<&MutableBitmap>
Source§fn as_arc(&mut self) -> Arc<dyn Array>
fn as_arc(&mut self) -> Arc<dyn Array>
Array
.Source§fn dtype(&self) -> &ArrowDataType
fn dtype(&self) -> &ArrowDataType
ArrowDataType
of the array.Source§fn as_mut_any(&mut self) -> &mut dyn Any
fn as_mut_any(&mut self) -> &mut dyn Any
Any
, to enable dynamic casting.Source§fn shrink_to_fit(&mut self)
fn shrink_to_fit(&mut self)
Source§impl<O: Offset> PartialEq for MutableBinaryArray<O>
impl<O: Offset> PartialEq for MutableBinaryArray<O>
Source§impl<O: Offset, T: AsRef<[u8]>> TryExtend<Option<T>> for MutableBinaryArray<O>
impl<O: Offset, T: AsRef<[u8]>> TryExtend<Option<T>> for MutableBinaryArray<O>
Source§fn try_extend<I: IntoIterator<Item = Option<T>>>(
&mut self,
iter: I,
) -> PolarsResult<()>
fn try_extend<I: IntoIterator<Item = Option<T>>>( &mut self, iter: I, ) -> PolarsResult<()>
Extend::extend
.Source§impl<O: Offset> TryExtendFromSelf for MutableBinaryArray<O>
impl<O: Offset> TryExtendFromSelf for MutableBinaryArray<O>
Source§fn try_extend_from_self(&mut self, other: &Self) -> PolarsResult<()>
fn try_extend_from_self(&mut self, other: &Self) -> PolarsResult<()>
other
, failing only on overflow.Auto Trait Implementations§
impl<O> Freeze for MutableBinaryArray<O>
impl<O> RefUnwindSafe for MutableBinaryArray<O>
impl<O> Send for MutableBinaryArray<O>
impl<O> Sync for MutableBinaryArray<O>
impl<O> Unpin for MutableBinaryArray<O>where
O: Unpin,
impl<O> UnwindSafe for MutableBinaryArray<O>where
O: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more