Struct polars_arrow::array::StructArray  
source · 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 polars_arrow::array::*;
use polars_arrow::datatypes::*;
let boolean = BooleanArray::from_slice(&[false, false, true, true]).boxed();
let int = Int32Array::from_slice(&[42, 28, 19, 31]).boxed();
let fields = vec![
    Field::new("b", ArrowDataType::Boolean, false),
    Field::new("c", ArrowDataType::Int32, false),
];
let array = StructArray::new(ArrowDataType::Struct(fields), vec![boolean, int], None);Implementations§
source§impl<'a> StructArray
 
impl<'a> StructArray
sourcepub fn iter(
    &'a self
) -> ZipValidity<Vec<Box<dyn Scalar>>, StructValueIter<'a>, BitmapIter<'a>> ⓘ
 
pub fn iter( &'a self ) -> ZipValidity<Vec<Box<dyn Scalar>>, StructValueIter<'a>, BitmapIter<'a>> ⓘ
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>
source§impl StructArray
 
impl StructArray
sourcepub fn try_new(
    data_type: ArrowDataType,
    values: Vec<Box<dyn Array>>,
    validity: Option<Bitmap>
) -> PolarsResult<Self>
 
pub fn try_new( data_type: ArrowDataType, values: Vec<Box<dyn Array>>, validity: Option<Bitmap> ) -> PolarsResult<Self>
Returns a new StructArray.
Errors
This function errors iff:
- data_type’s physical type is not- crate::datatypes::PhysicalType::Struct.
- the children of data_typeare 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: ArrowDataType,
    values: Vec<Box<dyn Array>>,
    validity: Option<Bitmap>
) -> Self
 
pub fn new( data_type: ArrowDataType, values: Vec<Box<dyn Array>>, validity: Option<Bitmap> ) -> Self
Returns a new StructArray
Panics
This function panics iff:
- data_type’s physical type is not- crate::datatypes::PhysicalType::Struct.
- the children of data_typeare 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_empty(data_type: ArrowDataType) -> Self
 
pub fn new_empty(data_type: ArrowDataType) -> Self
Creates an empty StructArray.
sourcepub fn new_null(data_type: ArrowDataType, length: usize) -> Self
 
pub fn new_null(data_type: ArrowDataType, length: usize) -> Self
Creates a null StructArray of length length.
source§impl StructArray
 
impl StructArray
sourcepub fn into_data(self) -> (Vec<Field>, Vec<Box<dyn Array>>, Option<Bitmap>)
 
pub fn into_data(self) -> (Vec<Field>, Vec<Box<dyn Array>>, Option<Bitmap>)
Deconstructs the StructArray into its individual components.
sourcepub fn slice(&mut self, offset: usize, length: usize)
 
pub fn slice(&mut self, offset: usize, length: usize)
Slices this StructArray.
Panics
- offset + lengthmust be smaller than- self.len().
Implementation
This operation is O(F) where F is the number of fields.
sourcepub unsafe fn slice_unchecked(&mut self, offset: usize, length: usize)
 
pub unsafe fn slice_unchecked(&mut self, offset: usize, length: usize)
Slices this StructArray.
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 sliced(self, offset: usize, length: usize) -> Self
 
pub fn sliced(self, offset: usize, length: usize) -> Self
Returns this array sliced.
Implementation
This function is O(1).
Panics
iff 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
Returns this array sliced.
Implementation
This function is O(1).
Safety
The caller must ensure that offset + length <= self.len().
sourcepub fn with_validity(self, validity: Option<Bitmap>) -> Self
 
pub fn with_validity(self, validity: Option<Bitmap>) -> Self
sourcepub fn set_validity(&mut self, validity: Option<Bitmap>)
 
pub fn set_validity(&mut self, validity: Option<Bitmap>)
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 StructArray
 
impl StructArray
source§impl StructArray
 
impl StructArray
sourcepub fn get_fields(data_type: &ArrowDataType) -> &[Field]
 
pub fn get_fields(data_type: &ArrowDataType) -> &[Field]
Returns the fields the DataType::Struct.
Trait Implementations§
source§impl Array for StructArray
 
impl Array for StructArray
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 data_type(&self) -> &ArrowDataType
 
fn data_type(&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 slice_unchecked(&mut self, offset: usize, length: usize)
 
unsafe fn slice_unchecked(&mut self, offset: usize, length: usize)
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 Arrow2Arrow for StructArray
 
impl Arrow2Arrow for StructArray
source§impl Clone for StructArray
 
impl Clone for StructArray
source§fn clone(&self) -> StructArray
 
fn clone(&self) -> StructArray
1.0.0 · source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
source. Read more