Struct arrow2::array::UnionArray
source · [−]pub struct UnionArray { /* private fields */ }
Expand description
UnionArray
represents an array whose each slot can contain different values.
Implementations
sourceimpl<'a> UnionArray
impl<'a> UnionArray
sourceimpl UnionArray
impl UnionArray
sourcepub fn try_new(
data_type: DataType,
types: Buffer<i8>,
fields: Vec<Box<dyn Array>>,
offsets: Option<Buffer<i32>>
) -> Result<Self, Error>
pub fn try_new(
data_type: DataType,
types: Buffer<i8>,
fields: Vec<Box<dyn Array>>,
offsets: Option<Buffer<i32>>
) -> Result<Self, Error>
Returns a new UnionArray
.
Errors
This function errors iff:
data_type
’s physical type is notcrate::datatypes::PhysicalType::Union
.- the fields’s len is different from the
data_type
’s children’s length - any of the values’s data type is different from its corresponding children’ data type
sourcepub fn new(
data_type: DataType,
types: Buffer<i8>,
fields: Vec<Box<dyn Array>>,
offsets: Option<Buffer<i32>>
) -> Self
pub fn new(
data_type: DataType,
types: Buffer<i8>,
fields: Vec<Box<dyn Array>>,
offsets: Option<Buffer<i32>>
) -> Self
Returns a new UnionArray
.
Panics
This function panics iff:
data_type
’s physical type is notcrate::datatypes::PhysicalType::Union
.- the fields’s len is different from the
data_type
’s children’s length - any of the values’s data type is different from its corresponding children’ data type
sourcepub fn from_data(
data_type: DataType,
types: Buffer<i8>,
fields: Vec<Box<dyn Array>>,
offsets: Option<Buffer<i32>>
) -> Self
pub fn from_data(
data_type: DataType,
types: Buffer<i8>,
fields: Vec<Box<dyn Array>>,
offsets: Option<Buffer<i32>>
) -> Self
Alias for new
sourcepub fn new_null(data_type: DataType, length: usize) -> Self
pub fn new_null(data_type: DataType, length: usize) -> Self
Creates a new null UnionArray
.
sourcepub fn new_empty(data_type: DataType) -> Self
pub fn new_empty(data_type: DataType) -> Self
Creates a new empty UnionArray
.
sourcepub fn boxed(self) -> Box<dyn Array>
pub fn boxed(self) -> Box<dyn Array>
Boxes self into a Box<dyn Array>
.
sourcepub fn arced(self) -> Arc<dyn Array>
pub fn arced(self) -> Arc<dyn Array>
Boxes self into a std::sync::Arc<dyn Array>
.
sourceimpl UnionArray
impl UnionArray
sourcepub fn slice(&self, offset: usize, length: usize) -> Self
pub fn slice(&self, offset: usize, length: usize) -> Self
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(&self, offset: usize, length: usize) -> Self
pub unsafe fn slice_unchecked(&self, offset: usize, length: usize) -> Self
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()
.
sourceimpl UnionArray
impl UnionArray
sourceimpl UnionArray
impl UnionArray
sourcepub fn get_fields(data_type: &DataType) -> &[Field]
pub fn get_fields(data_type: &DataType) -> &[Field]
Returns all fields from DataType::Union
.
Panic
Panics iff data_type
’s logical type is not DataType::Union
.
sourcepub fn is_sparse(data_type: &DataType) -> bool
pub fn is_sparse(data_type: &DataType) -> bool
Returns whether the DataType::Union
is sparse or not.
Panic
Panics iff data_type
’s logical type is not DataType::Union
.
Trait Implementations
sourceimpl Array for UnionArray
impl Array for UnionArray
sourcefn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
Converts itself to a reference of Any
, which enables downcasting to concrete types.
sourcefn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Converts itself to a mutable reference of Any
, which enables mutable downcasting to concrete types.
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
sourcefn null_count(&self) -> usize
fn null_count(&self) -> usize
sourceimpl Clone for UnionArray
impl Clone for UnionArray
sourcefn clone(&self) -> UnionArray
fn clone(&self) -> UnionArray
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for UnionArray
impl Debug for UnionArray
sourceimpl<'a> From<GrowableUnion<'a>> for UnionArray
impl<'a> From<GrowableUnion<'a>> for UnionArray
sourcefn from(val: GrowableUnion<'a>) -> Self
fn from(val: GrowableUnion<'a>) -> Self
Converts to this type from the input type.
sourceimpl<'a> IntoIterator for &'a UnionArray
impl<'a> IntoIterator for &'a UnionArray
sourceimpl PartialEq<&(dyn Array + 'static)> for UnionArray
impl PartialEq<&(dyn Array + 'static)> for UnionArray
sourceimpl PartialEq<UnionArray> for UnionArray
impl PartialEq<UnionArray> for UnionArray
Auto Trait Implementations
impl !RefUnwindSafe for UnionArray
impl Send for UnionArray
impl Sync for UnionArray
impl Unpin for UnionArray
impl !UnwindSafe for UnionArray
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