pub struct Utf8Array<O> where
O: Offset, { /* private fields */ }
Expand description
A Utf8Array
is arrow’s equivalent of an immutable Vec<Option<String>>
.
Cloning and slicing this struct is O(1)
.
Example
use arrow2::array::Utf8Array;
let array = Utf8Array::<i32>::from([Some("hi"), None, Some("there")]);
assert_eq!(array.value(0), "hi");
assert_eq!(array.values().as_slice(), b"hithere".as_ref());
assert_eq!(array.offsets().as_slice(), &[0, 2, 2, 2 + 5]);
Safety
The following invariants hold:
- Two consecutives
offsets
casted (as
) tousize
are valid slices ofvalues
. - A slice of
values
taken from two consecutivesoffsets
is validutf8
. len
is equal tovalidity.len()
, when defined.
Implementations
sourceimpl<O> Utf8Array<O> where
O: Offset,
impl<O> Utf8Array<O> where
O: Offset,
sourcepub fn from_slice<T, P>(slice: P) -> Utf8Array<O> where
T: AsRef<str>,
P: AsRef<[T]>,
pub fn from_slice<T, P>(slice: P) -> Utf8Array<O> where
T: AsRef<str>,
P: AsRef<[T]>,
Creates a new Utf8Array
from a slice of &str
.
This is a convenience method that just calls Self::from_trusted_len_values_iter
.
sourcepub fn from<T, P>(slice: P) -> Utf8Array<O> where
T: AsRef<str>,
P: AsRef<[Option<T>]>,
pub fn from<T, P>(slice: P) -> Utf8Array<O> where
T: AsRef<str>,
P: AsRef<[Option<T>]>,
Creates a new Utf8Array
from a slice of &str
.
sourcepub fn from_trusted_len_values_iter<T, I>(iterator: I) -> Utf8Array<O> where
T: AsRef<str>,
I: TrustedLen<Item = T>,
pub fn from_trusted_len_values_iter<T, I>(iterator: I) -> Utf8Array<O> where
T: AsRef<str>,
I: TrustedLen<Item = T>,
Creates a new Utf8Array
from a TrustedLen
of &str
.
sourceimpl<O> Utf8Array<O> where
O: Offset,
impl<O> Utf8Array<O> where
O: Offset,
sourcepub unsafe fn from_trusted_len_iter_unchecked<I, P>(iterator: I) -> Utf8Array<O> where
P: AsRef<str>,
I: Iterator<Item = Option<P>>,
pub unsafe fn from_trusted_len_iter_unchecked<I, P>(iterator: I) -> Utf8Array<O> where
P: AsRef<str>,
I: Iterator<Item = Option<P>>,
Creates a Utf8Array
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) -> Utf8Array<O> where
P: AsRef<str>,
I: TrustedLen<Item = Option<P>>,
pub fn from_trusted_len_iter<I, P>(iterator: I) -> Utf8Array<O> where
P: AsRef<str>,
I: TrustedLen<Item = Option<P>>,
Creates a Utf8Array
from an iterator of trusted length.
sourcepub unsafe fn try_from_trusted_len_iter_unchecked<E, I, P>(
iterator: I
) -> Result<Utf8Array<O>, 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<Utf8Array<O>, E> where
P: AsRef<str>,
I: IntoIterator<Item = Result<Option<P>, E>>,
Creates a Utf8Array
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<Utf8Array<O>, E> where
P: AsRef<str>,
I: TrustedLen<Item = Result<Option<P>, E>>,
pub fn try_from_trusted_len_iter<E, I, P>(iter: I) -> Result<Utf8Array<O>, E> where
P: AsRef<str>,
I: TrustedLen<Item = Result<Option<P>, E>>,
Creates a Utf8Array
from an fallible iterator of trusted length.
sourceimpl<'a, O> Utf8Array<O> where
O: Offset,
impl<'a, O> Utf8Array<O> where
O: Offset,
sourcepub fn iter(&'a self) -> ZipValidity<'a, &'a str, Utf8ValuesIter<'a, O>>ⓘNotable traits for ZipValidity<'a, T, I>impl<'a, T, I> Iterator for ZipValidity<'a, T, I> where
I: Iterator<Item = T>, type Item = Option<T>;
pub fn iter(&'a self) -> ZipValidity<'a, &'a str, Utf8ValuesIter<'a, O>>ⓘNotable traits for ZipValidity<'a, T, I>impl<'a, T, I> Iterator for ZipValidity<'a, T, I> where
I: Iterator<Item = T>, type Item = Option<T>;
I: Iterator<Item = T>, type Item = Option<T>;
Returns an iterator of Option<&str>
sourcepub fn values_iter(&'a self) -> Utf8ValuesIter<'a, O>ⓘNotable traits for Utf8ValuesIter<'a, O>impl<'a, O> Iterator for Utf8ValuesIter<'a, O> where
O: Offset, type Item = &'a str;
pub fn values_iter(&'a self) -> Utf8ValuesIter<'a, O>ⓘNotable traits for Utf8ValuesIter<'a, O>impl<'a, O> Iterator for Utf8ValuesIter<'a, O> where
O: Offset, type Item = &'a str;
O: Offset, type Item = &'a str;
Returns an iterator of &str
sourceimpl<O> Utf8Array<O> where
O: Offset,
impl<O> Utf8Array<O> where
O: Offset,
sourcepub fn try_new(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Result<Utf8Array<O>, ArrowError>
pub fn try_new(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Result<Utf8Array<O>, ArrowError>
Returns a new Utf8Array
.
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 new(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Utf8Array<O>
pub fn new(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Utf8Array<O>
Creates a new Utf8Array
.
Panics
This function panics 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: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Utf8Array<O>
pub fn from_data(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Utf8Array<O>
Alias for new
sourcepub fn new_null(data_type: DataType, length: usize) -> Utf8Array<O>
pub fn new_null(data_type: DataType, length: usize) -> Utf8Array<O>
Returns a new Utf8Array
whose all slots are null / None
.
sourcepub fn default_data_type() -> DataType
pub fn default_data_type() -> DataType
Returns the default DataType
, DataType::Utf8
or DataType::LargeUtf8
sourceimpl<O> Utf8Array<O> where
O: Offset,
impl<O> Utf8Array<O> where
O: Offset,
sourcepub unsafe fn try_new_unchecked(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Result<Utf8Array<O>, ArrowError>
pub unsafe fn try_new_unchecked(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Result<Utf8Array<O>, ArrowError>
Creates a new Utf8Array
without checking for offsets monotinicity nor utf8-validity
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 eitherUtf8
orLargeUtf8
.
Safety
This function is unsound iff:
- the offsets are not monotonically increasing
- The
values
between two consecutiveoffsets
are not valid utf8
Implementation
This function is O(1)
sourcepub unsafe fn new_unchecked(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Utf8Array<O>
pub unsafe fn new_unchecked(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Utf8Array<O>
Creates a new Utf8Array
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 eitherUtf8
orLargeUtf8
.
Safety
This function is unsound iff:
- the offsets are not monotonically increasing
- The
values
between two consecutiveoffsets
are not valid utf8
Implementation
This function is O(1)
sourcepub unsafe fn from_data_unchecked(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Utf8Array<O>
pub unsafe fn from_data_unchecked(
data_type: DataType,
offsets: Buffer<O>,
values: Buffer<u8>,
validity: Option<Bitmap>
) -> Utf8Array<O>
Alias for [new_unchecked
]
Safety
This function is unsafe iff:
- the offsets are not monotonically increasing
- The
values
between two consecutiveoffsets
are not valid utf8
sourceimpl<O> Utf8Array<O> where
O: Offset,
impl<O> Utf8Array<O> where
O: Offset,
sourcepub fn slice(&self, offset: usize, length: usize) -> Utf8Array<O>
pub fn slice(&self, offset: usize, length: usize) -> Utf8Array<O>
Returns a slice of this Utf8Array
.
Implementation
This operation is O(1)
as it amounts to essentially increase two ref counts.
Panic
This function panics iff offset + length >= self.len()
.
sourcepub unsafe fn slice_unchecked(
&self,
offset: usize,
length: usize
) -> Utf8Array<O>
pub unsafe fn slice_unchecked(
&self,
offset: usize,
length: usize
) -> Utf8Array<O>
Returns a slice of this Utf8Array
.
Implementation
This operation is O(1)
as it amounts to essentially increase two ref counts.
Safety
The caller must ensure that offset + length <= self.len()
.
sourcepub fn with_validity(&self, validity: Option<Bitmap>) -> Utf8Array<O>
pub fn with_validity(&self, validity: Option<Bitmap>) -> Utf8Array<O>
sourcepub fn into_mut(self) -> Either<Utf8Array<O>, MutableUtf8Array<O>>ⓘNotable traits for Either<L, R>impl<L, R> Iterator for Either<L, R> where
L: Iterator,
R: Iterator<Item = <L as Iterator>::Item>, type Item = <L as Iterator>::Item;impl<L, R> Read for Either<L, R> where
L: Read,
R: Read, impl<L, R> Write for Either<L, R> where
L: Write,
R: Write,
pub fn into_mut(self) -> Either<Utf8Array<O>, MutableUtf8Array<O>>ⓘNotable traits for Either<L, R>impl<L, R> Iterator for Either<L, R> where
L: Iterator,
R: Iterator<Item = <L as Iterator>::Item>, type Item = <L as Iterator>::Item;impl<L, R> Read for Either<L, R> where
L: Read,
R: Read, impl<L, R> Write for Either<L, R> where
L: Write,
R: Write,
L: Iterator,
R: Iterator<Item = <L as Iterator>::Item>, type Item = <L as Iterator>::Item;impl<L, R> Read for Either<L, R> where
L: Read,
R: Read, impl<L, R> Write for Either<L, R> where
L: Write,
R: Write,
Try to convert this Utf8Array
to a MutableUtf8Array
Trait Implementations
sourceimpl<O> Array for Utf8Array<O> where
O: Offset,
impl<O> Array for Utf8Array<O> where
O: Offset,
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
sourceunsafe fn slice_unchecked(
&self,
offset: usize,
length: usize
) -> Box<dyn Array + 'static, Global>
unsafe fn slice_unchecked(
&self,
offset: usize,
length: usize
) -> Box<dyn Array + 'static, Global>
sourcefn null_count(&self) -> usize
fn null_count(&self) -> usize
sourceimpl ChunkApplyKernel<Utf8Array<i64>> for ChunkedArray<Utf8Type>
impl ChunkApplyKernel<Utf8Array<i64>> for ChunkedArray<Utf8Type>
sourcefn apply_kernel(&self, f: &dyn Fn(&Utf8Array<i64>)) -> ChunkedArray<Utf8Type>
fn apply_kernel(&self, f: &dyn Fn(&Utf8Array<i64>)) -> ChunkedArray<Utf8Type>
Apply kernel and return result as a new ChunkedArray.
sourcefn apply_kernel_cast<S>(&self, f: &dyn Fn(&Utf8Array<i64>)) -> ChunkedArray<S> where
S: PolarsDataType,
fn apply_kernel_cast<S>(&self, f: &dyn Fn(&Utf8Array<i64>)) -> ChunkedArray<S> where
S: PolarsDataType,
Apply a kernel that outputs an array of different type.
sourceimpl<'a, O> From<GrowableUtf8<'a, O>> for Utf8Array<O> where
O: Offset,
impl<'a, O> From<GrowableUtf8<'a, O>> for Utf8Array<O> where
O: Offset,
sourcefn from(val: GrowableUtf8<'a, O>) -> Utf8Array<O>
fn from(val: GrowableUtf8<'a, O>) -> Utf8Array<O>
Performs the conversion.
sourceimpl<O> From<MutableUtf8Array<O>> for Utf8Array<O> where
O: Offset,
impl<O> From<MutableUtf8Array<O>> for Utf8Array<O> where
O: Offset,
sourcefn from(other: MutableUtf8Array<O>) -> Utf8Array<O>
fn from(other: MutableUtf8Array<O>) -> Utf8Array<O>
Performs the conversion.
sourceimpl FromDataUtf8 for Utf8Array<i64>
impl FromDataUtf8 for Utf8Array<i64>
sourceimpl<O> GenericBinaryArray<O> for Utf8Array<O> where
O: Offset,
impl<O> GenericBinaryArray<O> for Utf8Array<O> where
O: Offset,
sourceimpl<'a, O> IntoIterator for &'a Utf8Array<O> where
O: Offset,
impl<'a, O> IntoIterator for &'a Utf8Array<O> where
O: Offset,
type IntoIter = ZipValidity<'a, &'a str, Utf8ValuesIter<'a, O>>
type IntoIter = ZipValidity<'a, &'a str, Utf8ValuesIter<'a, O>>
Which kind of iterator are we turning this into?
sourceimpl ValueSize for Utf8Array<i64>
impl ValueSize for Utf8Array<i64>
sourcefn get_values_size(&self) -> usize
fn get_values_size(&self) -> usize
Useful for a Utf8 or a List to get underlying value size. During a rechunk this is handy Read more
impl ArrowArray for Utf8Array<i64>
Auto Trait Implementations
impl<O> RefUnwindSafe for Utf8Array<O> where
O: RefUnwindSafe,
impl<O> Send for Utf8Array<O>
impl<O> Sync for Utf8Array<O>
impl<O> Unpin for Utf8Array<O>
impl<O> UnwindSafe for Utf8Array<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<A> IsValid for A where
A: ArrowArray,
impl<A> IsValid for A where
A: ArrowArray,
sourceunsafe fn is_valid_unchecked(&self, i: usize) -> bool
unsafe fn is_valid_unchecked(&self, i: usize) -> bool
Safety Read more
sourceunsafe fn is_null_unchecked(&self, i: usize) -> bool
unsafe fn is_null_unchecked(&self, i: usize) -> bool
Safety Read more
sourceimpl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<A> PolarsArray for A where
A: Array + ?Sized,
impl<A> PolarsArray for A where
A: Array + ?Sized,
fn has_validity(&self) -> bool
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