Struct arrow2::array::MutableUtf8Array
source · [−]pub struct MutableUtf8Array<O: Offset> { /* private fields */ }
Expand description
The mutable version of Utf8Array
. See MutableArray
for more details.
Implementations
sourceimpl<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: Vec<O>,
values: Vec<u8>,
validity: Option<MutableBitmap>
) -> Result<Self>
pub fn try_new(
data_type: DataType,
offsets: Vec<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 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 eitherUtf8
orLargeUtf8
. - The
values
between two consecutiveoffsets
are not valid utf8
Implementation
This function is O(N)
- checking monotinicity and utf8 is O(N)
sourcepub fn from_data(
data_type: DataType,
offsets: Vec<O>,
values: Vec<u8>,
validity: Option<MutableBitmap>
) -> Self
pub fn from_data(
data_type: DataType,
offsets: Vec<O>,
values: Vec<u8>,
validity: Option<MutableBitmap>
) -> Self
The canonical method to create a MutableUtf8Array
out of low-end APIs.
Panics
This function panics iff:
- The
offsets
andvalues
are inconsistent - The
values
betweenoffsets
are not utf8 encoded - The validity is not
None
and its length is different fromoffsets
’s length minus one.
sourcepub unsafe fn from_data_unchecked(
data_type: DataType,
offsets: Vec<O>,
values: Vec<u8>,
validity: Option<MutableBitmap>
) -> Self
pub unsafe fn from_data_unchecked(
data_type: DataType,
offsets: Vec<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
offsets
andvalues
are inconsistent - The validity is not
None
and its length is different fromoffsets
’s length minus one.
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 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 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 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, Vec<O>, Vec<u8>, Option<MutableBitmap>)
pub fn into_data(self) -> (DataType, Vec<O>, Vec<u8>, Option<MutableBitmap>)
Extract the low-end APIs from the MutableUtf8Array
.
sourceimpl<O: Offset> MutableUtf8Array<O>
impl<O: Offset> MutableUtf8Array<O>
sourceimpl<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) -> Self where
P: AsRef<str>,
I: Iterator<Item = Option<P>>,
pub unsafe fn from_trusted_len_iter_unchecked<I, P>(iterator: I) -> Self where
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) -> Self where
P: AsRef<str>,
I: TrustedLen<Item = Option<P>>,
pub fn from_trusted_len_iter<I, P>(iterator: I) -> Self where
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
sourceimpl<O: Debug + Offset> Debug for MutableUtf8Array<O>
impl<O: Debug + Offset> Debug for MutableUtf8Array<O>
sourceimpl<O: Offset> Default for MutableUtf8Array<O>
impl<O: Offset> Default for MutableUtf8Array<O>
sourceimpl<O: Offset, T: AsRef<str>> Extend<Option<T>> for MutableUtf8Array<O>
impl<O: Offset, T: AsRef<str>> Extend<Option<T>> for MutableUtf8Array<O>
sourcefn extend<I: IntoIterator<Item = Option<T>>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Option<T>>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<O: Offset> From<MutableUtf8Array<O>> for Utf8Array<O>
impl<O: Offset> From<MutableUtf8Array<O>> for Utf8Array<O>
sourcefn from(other: MutableUtf8Array<O>) -> Self
fn from(other: MutableUtf8Array<O>) -> Self
Converts to this type from the input type.
sourceimpl<O: Offset, P: AsRef<str>> FromIterator<Option<P>> for MutableUtf8Array<O>
impl<O: Offset, P: AsRef<str>> FromIterator<Option<P>> for MutableUtf8Array<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> MutableArray for MutableUtf8Array<O>
impl<O: Offset> MutableArray for MutableUtf8Array<O>
sourcefn validity(&self) -> Option<&MutableBitmap>
fn validity(&self) -> Option<&MutableBitmap>
The optional validity of the array.
sourcefn as_arc(&mut self) -> Arc<dyn Array>
fn as_arc(&mut self) -> Arc<dyn Array>
Convert itself to an (immutable) atomically reference counted Array
.
sourcefn as_mut_any(&mut self) -> &mut dyn Any
fn as_mut_any(&mut self) -> &mut dyn Any
Convert to mutable Any
, to enable dynamic casting.
sourcefn shrink_to_fit(&mut self)
fn shrink_to_fit(&mut self)
Shrink the array to fit its length.
sourceimpl<O: Offset, T: AsRef<str>> TryExtend<Option<T>> for MutableUtf8Array<O>
impl<O: Offset, T: AsRef<str>> TryExtend<Option<T>> for MutableUtf8Array<O>
sourcefn 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<()>
Fallible version of Extend::extend
.
Auto Trait Implementations
impl<O> RefUnwindSafe for MutableUtf8Array<O> where
O: RefUnwindSafe,
impl<O> Send for MutableUtf8Array<O>
impl<O> Sync for MutableUtf8Array<O>
impl<O> Unpin for MutableUtf8Array<O> where
O: Unpin,
impl<O> UnwindSafe for MutableUtf8Array<O> where
O: UnwindSafe,
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