Struct arrow2::array::MutableUtf8Array
source · pub struct MutableUtf8Array<O: Offset> { /* private fields */ }Expand description
A MutableArray that builds a Utf8Array. It differs
from MutableUtf8ValuesArray in that it can build nullable Utf8Arrays.
Implementations§
source§impl<O: Offset> MutableUtf8Array<O>
impl<O: Offset> MutableUtf8Array<O>
sourcepub fn new() -> Self
pub fn new() -> Self
Initializes a new empty MutableUtf8Array.
sourcepub fn try_new(
data_type: DataType,
offsets: Offsets<O>,
values: Vec<u8>,
validity: Option<MutableBitmap>
) -> Result<Self>
pub fn try_new( data_type: DataType, offsets: Offsets<O>, values: Vec<u8>, validity: Option<MutableBitmap> ) -> Result<Self>
Returns a MutableUtf8Array 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
data_type’scrate::datatypes::PhysicalTypeis not equal to eitherUtf8orLargeUtf8. - The
valuesbetween two consecutiveoffsetsare not valid utf8
Implementation
This function is O(N) - checking utf8 is O(N)
sourcepub unsafe fn new_unchecked(
data_type: DataType,
offsets: Offsets<O>,
values: Vec<u8>,
validity: Option<MutableBitmap>
) -> Self
pub unsafe fn new_unchecked( data_type: DataType, offsets: Offsets<O>, values: Vec<u8>, validity: Option<MutableBitmap> ) -> Self
Create a MutableUtf8Array out of low-end APIs.
Safety
The caller must ensure that every value between offsets is a valid utf8.
Panics
This function panics iff:
- The
offsetsandvaluesare inconsistent - The validity is not
Noneand its length is different fromoffsets’s length minus one.
sourcepub fn from<T: AsRef<str>, P: AsRef<[Option<T>]>>(slice: P) -> Self
pub fn from<T: AsRef<str>, P: AsRef<[Option<T>]>>(slice: P) -> Self
Creates a new MutableUtf8Array from a slice of optional &[u8].
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Initializes a new MutableUtf8Array 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 MutableUtf8Array with a pre-allocated capacity of slots and values.
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 capacity(&self) -> usize
pub fn capacity(&self) -> usize
Reserves additional elements and additional_values on the values buffer.
sourcepub fn push<T: AsRef<str>>(&mut self, value: Option<T>)
pub fn push<T: AsRef<str>>(&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 value(&self, i: usize) -> &str
pub fn value(&self, i: usize) -> &str
Returns the value of the element at index i, ignoring the array’s validity.
Safety
This function is safe iff i < self.len.
sourcepub unsafe fn value_unchecked(&self, i: usize) -> &str
pub unsafe fn value_unchecked(&self, i: usize) -> &str
Returns the value of the element at index i, ignoring the array’s validity.
Safety
This function is safe iff i < self.len.
sourcepub fn pop(&mut self) -> Option<String>
pub fn pop(&mut self) -> Option<String>
Pop the last entry from MutableUtf8Array.
This function returns None iff this array is empty.
sourcepub fn iter(
&self
) -> ZipValidity<&str, ArrayValuesIter<'_, MutableUtf8ValuesArray<O>>, BitmapIter<'_>> ⓘ
pub fn iter( &self ) -> ZipValidity<&str, ArrayValuesIter<'_, MutableUtf8ValuesArray<O>>, BitmapIter<'_>> ⓘ
Returns an iterator of Option<&str>
sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the capacity of the MutableUtf8Array to fit its current length.
sourcepub fn into_data(self) -> (DataType, Offsets<O>, Vec<u8>, Option<MutableBitmap>)
pub fn into_data(self) -> (DataType, Offsets<O>, Vec<u8>, Option<MutableBitmap>)
Extract the low-end APIs from the MutableUtf8Array.
sourcepub fn values_iter(&self) -> ArrayValuesIter<'_, MutableUtf8ValuesArray<O>> ⓘ
pub fn values_iter(&self) -> ArrayValuesIter<'_, MutableUtf8ValuesArray<O>> ⓘ
Returns an iterator of &str
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> MutableUtf8Array<O>
impl<O: Offset> MutableUtf8Array<O>
source§impl<O: Offset> MutableUtf8Array<O>
impl<O: Offset> MutableUtf8Array<O>
sourcepub fn extend_trusted_len_values<I, P>(&mut self, iterator: I)where
P: AsRef<str>,
I: TrustedLen<Item = P>,
pub fn extend_trusted_len_values<I, P>(&mut self, iterator: I)where P: AsRef<str>, I: TrustedLen<Item = P>,
Extends the MutableUtf8Array from an iterator of values of trusted len.
This differs from extended_trusted_len which accepts iterator of optional values.
sourcepub fn extend_values<I, P>(&mut self, iterator: I)where
P: AsRef<str>,
I: Iterator<Item = P>,
pub fn extend_values<I, P>(&mut self, iterator: I)where P: AsRef<str>, I: Iterator<Item = P>,
Extends the MutableUtf8Array 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)where
P: AsRef<str>,
I: Iterator<Item = P>,
pub unsafe fn extend_trusted_len_values_unchecked<I, P>(&mut self, iterator: I)where P: AsRef<str>, I: Iterator<Item = P>,
Extends the MutableUtf8Array from an iterator of values of trusted len.
This differs from extended_trusted_len_unchecked which accepts iterator of optional
values.
Safety
The iterator must be trusted len.
sourcepub fn extend_trusted_len<I, P>(&mut self, iterator: I)where
P: AsRef<str>,
I: TrustedLen<Item = Option<P>>,
pub fn extend_trusted_len<I, P>(&mut self, iterator: I)where P: AsRef<str>, I: TrustedLen<Item = Option<P>>,
Extends the MutableUtf8Array from an iterator of trusted len.
sourcepub unsafe fn extend_trusted_len_unchecked<I, P>(&mut self, iterator: I)where
P: AsRef<str>,
I: Iterator<Item = Option<P>>,
pub unsafe fn extend_trusted_len_unchecked<I, P>(&mut self, iterator: I)where P: AsRef<str>, I: Iterator<Item = Option<P>>,
sourcepub unsafe fn from_trusted_len_iter_unchecked<I, P>(iterator: I) -> Selfwhere
P: AsRef<str>,
I: Iterator<Item = Option<P>>,
pub unsafe fn from_trusted_len_iter_unchecked<I, P>(iterator: I) -> Selfwhere P: AsRef<str>, I: Iterator<Item = Option<P>>,
Creates a MutableUtf8Array 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) -> Selfwhere
P: AsRef<str>,
I: TrustedLen<Item = Option<P>>,
pub fn from_trusted_len_iter<I, P>(iterator: I) -> Selfwhere P: AsRef<str>, I: TrustedLen<Item = Option<P>>,
Creates a MutableUtf8Array from an iterator of trusted length.
sourcepub unsafe fn from_trusted_len_values_iter_unchecked<T: AsRef<str>, I: Iterator<Item = T>>(
iterator: I
) -> Self
pub unsafe fn from_trusted_len_values_iter_unchecked<T: AsRef<str>, I: Iterator<Item = T>>( iterator: I ) -> Self
Creates a MutableUtf8Array from an iterator of trusted length of &str.
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<str>, I: TrustedLen<Item = T>>(
iterator: I
) -> Self
pub fn from_trusted_len_values_iter<T: AsRef<str>, I: TrustedLen<Item = T>>( iterator: I ) -> Self
Creates a new MutableUtf8Array from a TrustedLen of &str.
sourcepub unsafe fn try_from_trusted_len_iter_unchecked<E, I, P>(
iterator: I
) -> Result<Self, E>where
P: AsRef<str>,
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<str>, I: IntoIterator<Item = Result<Option<P>, E>>,
Creates a MutableUtf8Array 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>where
P: AsRef<str>,
I: TrustedLen<Item = Result<Option<P>, E>>,
pub fn try_from_trusted_len_iter<E, I, P>(iterator: I) -> Result<Self, E>where P: AsRef<str>, I: TrustedLen<Item = Result<Option<P>, E>>,
Creates a MutableUtf8Array from an falible iterator of trusted length.
sourcepub fn from_iter_values<T: AsRef<str>, I: Iterator<Item = T>>(
iterator: I
) -> Self
pub fn from_iter_values<T: AsRef<str>, I: Iterator<Item = T>>( iterator: I ) -> Self
Creates a new MutableUtf8Array from a Iterator of &str.
Trait Implementations§
source§impl<O: Clone + Offset> Clone for MutableUtf8Array<O>
impl<O: Clone + Offset> Clone for MutableUtf8Array<O>
source§fn clone(&self) -> MutableUtf8Array<O>
fn clone(&self) -> MutableUtf8Array<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 MutableUtf8Array<O>
impl<O: Offset> Default for MutableUtf8Array<O>
source§impl<O: Offset, T: AsRef<str>> Extend<Option<T>> for MutableUtf8Array<O>
impl<O: Offset, T: AsRef<str>> Extend<Option<T>> for MutableUtf8Array<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<MutableUtf8Array<O>> for Utf8Array<O>
impl<O: Offset> From<MutableUtf8Array<O>> for Utf8Array<O>
source§fn from(other: MutableUtf8Array<O>) -> Self
fn from(other: MutableUtf8Array<O>) -> Self
source§impl<O: Offset> From<MutableUtf8ValuesArray<O>> for MutableUtf8Array<O>
impl<O: Offset> From<MutableUtf8ValuesArray<O>> for MutableUtf8Array<O>
source§fn from(other: MutableUtf8ValuesArray<O>) -> Self
fn from(other: MutableUtf8ValuesArray<O>) -> Self
source§impl<O: Offset, P: AsRef<str>> FromIterator<Option<P>> for MutableUtf8Array<O>
impl<O: Offset, P: AsRef<str>> FromIterator<Option<P>> for MutableUtf8Array<O>
source§impl<'a, O: Offset> IntoIterator for &'a MutableUtf8Array<O>
impl<'a, O: Offset> IntoIterator for &'a MutableUtf8Array<O>
§type IntoIter = ZipValidity<&'a str, ArrayValuesIter<'a, MutableUtf8ValuesArray<O>>, BitmapIter<'a>>
type IntoIter = ZipValidity<&'a str, ArrayValuesIter<'a, MutableUtf8ValuesArray<O>>, BitmapIter<'a>>
source§impl<O: Offset> MutableArray for MutableUtf8Array<O>
impl<O: Offset> MutableArray for MutableUtf8Array<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 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<MutableUtf8Array<O>> for MutableUtf8Array<O>
impl<O: Offset> PartialEq<MutableUtf8Array<O>> for MutableUtf8Array<O>
source§impl<O: Offset, T: AsRef<str>> TryExtend<Option<T>> for MutableUtf8Array<O>
impl<O: Offset, T: AsRef<str>> TryExtend<Option<T>> for MutableUtf8Array<O>
source§fn try_extend<I: IntoIterator<Item = Option<T>>>(
&mut self,
iter: I
) -> Result<()>
fn try_extend<I: IntoIterator<Item = Option<T>>>( &mut self, iter: I ) -> Result<()>
Extend::extend.