pub struct UnionArray { /* private fields */ }
Expand description
UnionArray
represents an array whose each slot can contain different values.
Implementations§
Source§impl<'a> UnionArray
impl<'a> UnionArray
Source§impl UnionArray
impl UnionArray
Sourcepub fn try_new(
dtype: ArrowDataType,
types: Buffer<i8>,
fields: Vec<Box<dyn Array>>,
offsets: Option<Buffer<i32>>,
) -> PolarsResult<Self>
pub fn try_new( dtype: ArrowDataType, types: Buffer<i8>, fields: Vec<Box<dyn Array>>, offsets: Option<Buffer<i32>>, ) -> PolarsResult<Self>
Returns a new UnionArray
.
§Errors
This function errors iff:
dtype
’s physical type is notcrate::datatypes::PhysicalType::Union
.- the fields’s len is different from the
dtype
’s children’s length - The number of
fields
is larger thani8::MAX
- any of the values’s data type is different from its corresponding children’ data type
Sourcepub fn new(
dtype: ArrowDataType,
types: Buffer<i8>,
fields: Vec<Box<dyn Array>>,
offsets: Option<Buffer<i32>>,
) -> Self
pub fn new( dtype: ArrowDataType, types: Buffer<i8>, fields: Vec<Box<dyn Array>>, offsets: Option<Buffer<i32>>, ) -> Self
Returns a new UnionArray
.
§Panics
This function panics iff:
dtype
’s physical type is notcrate::datatypes::PhysicalType::Union
.- the fields’s len is different from the
dtype
’s children’s length - any of the values’s data type is different from its corresponding children’ data type
Sourcepub fn new_null(dtype: ArrowDataType, length: usize) -> Self
pub fn new_null(dtype: ArrowDataType, length: usize) -> Self
Creates a new null UnionArray
.
Sourcepub fn new_empty(dtype: ArrowDataType) -> Self
pub fn new_empty(dtype: ArrowDataType) -> Self
Creates a new empty UnionArray
.
Source§impl UnionArray
impl UnionArray
Sourcepub fn slice(&mut self, offset: usize, length: usize)
pub fn slice(&mut self, offset: usize, length: usize)
Returns a slice of this UnionArray
.
§Implementation
This operation is O(F)
where F
is the number of fields.
§Panic
This function panics iff offset + length > self.len()
.
Sourcepub unsafe fn slice_unchecked(&mut self, offset: usize, length: usize)
pub unsafe fn slice_unchecked(&mut self, offset: usize, length: usize)
Returns a slice of this UnionArray
.
§Implementation
This operation is O(F)
where F
is the number of fields.
§Safety
The caller must ensure that offset + length <= self.len()
.
Sourcepub unsafe fn sliced_unchecked(self, offset: usize, length: usize) -> Self
pub unsafe fn sliced_unchecked(self, offset: usize, length: usize) -> Self
Sourcepub fn boxed(self) -> Box<dyn Array>
pub fn boxed(self) -> Box<dyn Array>
Boxes this array into a Box<dyn Array>
.
Sourcepub fn arced(self) -> Arc<dyn Array>
pub fn arced(self) -> Arc<dyn Array>
Arcs this array into a std::sync::Arc<dyn Array>
.
Source§impl UnionArray
impl UnionArray
Sourcepub fn index(&self, index: usize) -> (usize, usize)
pub fn index(&self, index: usize) -> (usize, usize)
Returns the index and slot of the field to select from self.fields
.
Sourcepub unsafe fn index_unchecked(&self, index: usize) -> (usize, usize)
pub unsafe fn index_unchecked(&self, index: usize) -> (usize, usize)
Returns the index and slot of the field to select from self.fields
.
The first value is guaranteed to be < self.fields().len()
§Safety
This function is safe iff index < self.len
.
Source§impl UnionArray
impl UnionArray
Sourcepub fn get_fields(dtype: &ArrowDataType) -> &[Field]
pub fn get_fields(dtype: &ArrowDataType) -> &[Field]
Returns all fields from ArrowDataType::Union
.
§Panic
Panics iff dtype
’s logical type is not ArrowDataType::Union
.
Sourcepub fn is_sparse(dtype: &ArrowDataType) -> bool
pub fn is_sparse(dtype: &ArrowDataType) -> bool
Returns whether the ArrowDataType::Union
is sparse or not.
§Panic
Panics iff dtype
’s logical type is not ArrowDataType::Union
.
Trait Implementations§
Source§impl Array for UnionArray
impl Array for UnionArray
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
Any
, which enables downcasting to concrete types.Source§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Any
, which enables mutable downcasting to concrete types.Source§fn len(&self) -> usize
fn len(&self) -> usize
Array
. Every array has a length corresponding to the number of
elements (slots).Source§fn dtype(&self) -> &ArrowDataType
fn dtype(&self) -> &ArrowDataType
ArrowDataType
of the Array
. In combination with Array::as_any
, this can be
used to downcast trait objects (dyn Array
) to concrete arrays.Source§unsafe fn split_at_boxed_unchecked(
&self,
offset: usize,
) -> (Box<dyn Array>, Box<dyn Array>)
unsafe fn split_at_boxed_unchecked( &self, offset: usize, ) -> (Box<dyn Array>, Box<dyn Array>)
Source§unsafe fn slice_unchecked(&mut self, offset: usize, length: usize)
unsafe fn slice_unchecked(&mut self, offset: usize, length: usize)
fn has_nulls(&self) -> bool
Source§unsafe fn is_null_unchecked(&self, i: usize) -> bool
unsafe fn is_null_unchecked(&self, i: usize) -> bool
i
is null. Read moreSource§impl Clone for UnionArray
impl Clone for UnionArray
Source§fn clone(&self) -> UnionArray
fn clone(&self) -> UnionArray
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for UnionArray
impl Debug for UnionArray
Source§impl<'a> IntoIterator for &'a UnionArray
impl<'a> IntoIterator for &'a UnionArray
Source§impl PartialEq<&(dyn Array + 'static)> for UnionArray
impl PartialEq<&(dyn Array + 'static)> for UnionArray
Source§impl PartialEq for UnionArray
impl PartialEq for UnionArray
Source§impl Splitable for UnionArray
impl Splitable for UnionArray
fn check_bound(&self, offset: usize) -> bool
Source§unsafe fn _split_at_unchecked(&self, offset: usize) -> (Self, Self)
unsafe fn _split_at_unchecked(&self, offset: usize) -> (Self, Self)
split_at_unchecked
. For any usage, prefer the using
split_at
or split_at_unchecked
. Read moreAuto Trait Implementations§
impl Freeze for UnionArray
impl !RefUnwindSafe for UnionArray
impl Send for UnionArray
impl Sync for UnionArray
impl Unpin for UnionArray
impl !UnwindSafe for UnionArray
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