pub struct StructArray { /* private fields */ }
Expand description
A StructArray
is a nested Array
with an optional validity representing
multiple Array
with the same number of rows.
Example
use std::sync::Arc;
use arrow2::array::*;
use arrow2::datatypes::*;
let boolean = Arc::new(BooleanArray::from_slice(&[false, false, true, true])) as Arc<dyn Array>;
let int = Arc::new(Int32Array::from_slice(&[42, 28, 19, 31])) as Arc<dyn Array>;
let fields = vec![
Field::new("b", DataType::Boolean, false),
Field::new("c", DataType::Int32, false),
];
let array = StructArray::new(DataType::Struct(fields), vec![boolean, int], None);
Implementations
sourceimpl<'a> StructArray
impl<'a> StructArray
sourcepub fn iter(
&'a self
) -> ZipValidity<'a, Vec<Box<dyn Scalar + 'static, Global>, Global>, StructValueIter<'a>>ⓘ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, Vec<Box<dyn Scalar + 'static, Global>, Global>, StructValueIter<'a>>ⓘ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<Box<dyn Array>>
sourcepub fn values_iter(&'a self) -> StructValueIter<'a>
pub fn values_iter(&'a self) -> StructValueIter<'a>
Returns an iterator of Box<dyn Array>
sourceimpl StructArray
impl StructArray
sourcepub fn try_new(
data_type: DataType,
values: Vec<Arc<dyn Array + 'static>, Global>,
validity: Option<Bitmap>
) -> Result<StructArray, ArrowError>
pub fn try_new(
data_type: DataType,
values: Vec<Arc<dyn Array + 'static>, Global>,
validity: Option<Bitmap>
) -> Result<StructArray, ArrowError>
Returns a new StructArray
.
Errors
This function errors iff:
data_type
’s physical type is notcrate::datatypes::PhysicalType::Struct
.- the children of
data_type
are empty - the values’s len is different from children’s length
- any of the values’s data type is different from its corresponding children’ data type
- any element of values has a different length than the first element
- the validity’s length is not equal to the length of the first element
sourcepub fn new(
data_type: DataType,
values: Vec<Arc<dyn Array + 'static>, Global>,
validity: Option<Bitmap>
) -> StructArray
pub fn new(
data_type: DataType,
values: Vec<Arc<dyn Array + 'static>, Global>,
validity: Option<Bitmap>
) -> StructArray
Returns a new StructArray
Panics
This function panics iff:
data_type
’s physical type is notcrate::datatypes::PhysicalType::Struct
.- the children of
data_type
are empty - the values’s len is different from children’s length
- any of the values’s data type is different from its corresponding children’ data type
- any element of values has a different length than the first element
- the validity’s length is not equal to the length of the first element
sourcepub fn from_data(
data_type: DataType,
values: Vec<Arc<dyn Array + 'static>, Global>,
validity: Option<Bitmap>
) -> StructArray
pub fn from_data(
data_type: DataType,
values: Vec<Arc<dyn Array + 'static>, Global>,
validity: Option<Bitmap>
) -> StructArray
Alias for new
sourcepub fn new_empty(data_type: DataType) -> StructArray
pub fn new_empty(data_type: DataType) -> StructArray
Creates an empty StructArray
.
sourcepub fn new_null(data_type: DataType, length: usize) -> StructArray
pub fn new_null(data_type: DataType, length: usize) -> StructArray
Creates a null StructArray
of length length
.
sourceimpl StructArray
impl StructArray
sourcepub fn into_data(
self
) -> (Vec<Field, Global>, Vec<Arc<dyn Array + 'static>, Global>, Option<Bitmap>)
pub fn into_data(
self
) -> (Vec<Field, Global>, Vec<Arc<dyn Array + 'static>, Global>, Option<Bitmap>)
Deconstructs the StructArray
into its individual components.
sourcepub fn slice(&self, offset: usize, length: usize) -> StructArray
pub fn slice(&self, offset: usize, length: usize) -> StructArray
Creates a new StructArray
that is a slice of self
.
Panics
offset + length
must be smaller thanself.len()
.
Implementation
This operation is O(F)
where F
is the number of fields.
sourcepub unsafe fn slice_unchecked(
&self,
offset: usize,
length: usize
) -> StructArray
pub unsafe fn slice_unchecked(
&self,
offset: usize,
length: usize
) -> StructArray
Creates a new StructArray
that is a slice of self
.
Implementation
This operation is O(F)
where F
is the number of fields.
Safety
The caller must ensure that offset + length <= self.len()
.
sourcepub fn with_validity(&self, validity: Option<Bitmap>) -> StructArray
pub fn with_validity(&self, validity: Option<Bitmap>) -> StructArray
Sets the validity bitmap on this StructArray
.
Panic
This function panics iff validity.len() != self.len()
.
sourceimpl StructArray
impl StructArray
sourceimpl StructArray
impl StructArray
Trait Implementations
sourceimpl Array for StructArray
impl Array for StructArray
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 Clone for StructArray
impl Clone for StructArray
sourcefn clone(&self) -> StructArray
fn clone(&self) -> StructArray
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 StructArray
impl Debug for StructArray
sourceimpl<'a> From<GrowableStruct<'a>> for StructArray
impl<'a> From<GrowableStruct<'a>> for StructArray
sourcefn from(val: GrowableStruct<'a>) -> StructArray
fn from(val: GrowableStruct<'a>) -> StructArray
Performs the conversion.
sourceimpl<'a> IntoIterator for &'a StructArray
impl<'a> IntoIterator for &'a StructArray
type Item = Option<Vec<Box<dyn Scalar + 'static, Global>, Global>>
type Item = Option<Vec<Box<dyn Scalar + 'static, Global>, Global>>
The type of the elements being iterated over.
type IntoIter = ZipValidity<'a, Vec<Box<dyn Scalar + 'static, Global>, Global>, StructValueIter<'a>>
type IntoIter = ZipValidity<'a, Vec<Box<dyn Scalar + 'static, Global>, Global>, StructValueIter<'a>>
Which kind of iterator are we turning this into?
sourcefn into_iter(self) -> <&'a StructArray as IntoIterator>::IntoIter
fn into_iter(self) -> <&'a StructArray as IntoIterator>::IntoIter
Creates an iterator from a value. Read more
sourceimpl<'_> PartialEq<&'_ (dyn Array + '_)> for StructArray
impl<'_> PartialEq<&'_ (dyn Array + '_)> for StructArray
sourceimpl PartialEq<StructArray> for StructArray
impl PartialEq<StructArray> for StructArray
sourceimpl TryFrom<StructArray> for DataFrame
impl TryFrom<StructArray> for DataFrame
type Error = PolarsError
type Error = PolarsError
The type returned in the event of a conversion error.
sourcefn try_from(arr: StructArray) -> Result<DataFrame, PolarsError>
fn try_from(arr: StructArray) -> Result<DataFrame, PolarsError>
Performs the conversion.
Auto Trait Implementations
impl !RefUnwindSafe for StructArray
impl Send for StructArray
impl Sync for StructArray
impl Unpin for StructArray
impl !UnwindSafe for StructArray
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<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