Struct polars::prelude::StructArray  
pub struct StructArray { /* private fields */ }polars-io only.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§
§impl<'a> StructArray
 
impl<'a> StructArray
pub 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>>
pub fn values_iter(&'a self) -> StructValueIter<'a>
pub fn values_iter(&'a self) -> StructValueIter<'a>
Returns an iterator of Box<dyn Array>
§impl StructArray
 
impl StructArray
pub fn try_new(
    data_type: ArrowDataType,
    values: Vec<Box<dyn Array>>,
    validity: Option<Bitmap>
) -> Result<StructArray, PolarsError>
pub fn try_new( data_type: ArrowDataType, values: Vec<Box<dyn Array>>, validity: Option<Bitmap> ) -> Result<StructArray, PolarsError>
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
pub fn new(
    data_type: ArrowDataType,
    values: Vec<Box<dyn Array>>,
    validity: Option<Bitmap>
) -> StructArray
pub fn new( data_type: ArrowDataType, values: Vec<Box<dyn Array>>, validity: Option<Bitmap> ) -> StructArray
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
pub fn new_empty(data_type: ArrowDataType) -> StructArray
pub fn new_empty(data_type: ArrowDataType) -> StructArray
Creates an empty StructArray.
pub fn new_null(data_type: ArrowDataType, length: usize) -> StructArray
pub fn new_null(data_type: ArrowDataType, length: usize) -> StructArray
Creates a null StructArray of length length.
§impl StructArray
 
impl StructArray
pub 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.
pub 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.
pub 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().
pub fn sliced(self, offset: usize, length: usize) -> StructArray
pub fn sliced(self, offset: usize, length: usize) -> StructArray
pub unsafe fn sliced_unchecked(
    self,
    offset: usize,
    length: usize
) -> StructArray
pub unsafe fn sliced_unchecked( self, offset: usize, length: usize ) -> StructArray
pub fn with_validity(self, validity: Option<Bitmap>) -> StructArray
pub fn with_validity(self, validity: Option<Bitmap>) -> StructArray
pub fn set_validity(&mut self, validity: Option<Bitmap>)
pub fn set_validity(&mut self, validity: Option<Bitmap>)
pub fn take_validity(&mut self) -> Option<Bitmap>
pub fn take_validity(&mut self) -> Option<Bitmap>
Takes the validity of this array, leaving it without a validity mask.
pub fn boxed(self) -> Box<dyn Array>
pub fn boxed(self) -> Box<dyn Array>
Boxes this array into a Box<dyn Array>.
pub fn arced(self) -> Arc<dyn Array>
pub fn arced(self) -> Arc<dyn Array>
Arcs this array into a std::sync::Arc<dyn Array>.
§impl StructArray
 
impl StructArray
pub fn values(&self) -> &[Box<dyn Array>]
pub fn values(&self) -> &[Box<dyn Array>]
Returns the values of this StructArray.
pub fn fields(&self) -> &[Field]
pub fn fields(&self) -> &[Field]
Returns the fields of this StructArray.
§impl StructArray
 
impl StructArray
pub fn get_fields(data_type: &ArrowDataType) -> &[Field]
pub fn get_fields(data_type: &ArrowDataType) -> &[Field]
Returns the fields the DataType::Struct.
Trait Implementations§
§impl Array for StructArray
 
impl Array for StructArray
§fn as_any(&self) -> &(dyn Any + 'static)
 
fn as_any(&self) -> &(dyn Any + 'static)
Any, which enables downcasting to concrete types.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
 
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Any, which enables mutable downcasting to concrete types.§fn len(&self) -> usize
 
fn len(&self) -> usize
Array]. Every array has a length corresponding to the number of
elements (slots).§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.§fn split_at_boxed(&self, offset: usize) -> (Box<dyn Array>, Box<dyn Array>)
 
fn split_at_boxed(&self, offset: usize) -> (Box<dyn Array>, Box<dyn Array>)
Self] at offset into two boxed [Array]s where offset <= self.len().§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>)
§unsafe fn slice_unchecked(&mut self, offset: usize, length: usize)
 
unsafe fn slice_unchecked(&mut self, offset: usize, length: usize)
Array]. Read more§fn validity(&self) -> Option<&Bitmap>
 
fn validity(&self) -> Option<&Bitmap>
Array]: every array has an optional [Bitmap] that, when available
specifies whether the array slot is valid or not (null).
When the validity is None, all slots are valid.§fn with_validity(&self, validity: Option<Bitmap>) -> Box<dyn Array>
 
fn with_validity(&self, validity: Option<Bitmap>) -> Box<dyn Array>
Array] with a new new assigned bitmap. Read more§fn null_count(&self) -> usize
 
fn null_count(&self) -> usize
Array]. Read more§unsafe fn is_null_unchecked(&self, i: usize) -> bool
 
unsafe fn is_null_unchecked(&self, i: usize) -> bool
i is null. Read more§impl Clone for StructArray
 
impl Clone for StructArray
§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§impl Debug for StructArray
 
impl Debug for StructArray
§impl<'a> From<GrowableStruct<'a>> for StructArray
 
impl<'a> From<GrowableStruct<'a>> for StructArray
§fn from(val: GrowableStruct<'a>) -> StructArray
 
fn from(val: GrowableStruct<'a>) -> StructArray
§impl From<MutableStructArray> for StructArray
 
impl From<MutableStructArray> for StructArray
§fn from(other: MutableStructArray) -> StructArray
 
fn from(other: MutableStructArray) -> StructArray
§impl<'a> IntoIterator for &'a StructArray
 
impl<'a> IntoIterator for &'a StructArray
§type IntoIter = ZipValidity<Vec<Box<dyn Scalar>>, StructValueIter<'a>, BitmapIter<'a>>
 
type IntoIter = ZipValidity<Vec<Box<dyn Scalar>>, StructValueIter<'a>, BitmapIter<'a>>
§fn into_iter(self) -> <&'a StructArray as IntoIterator>::IntoIter
 
fn into_iter(self) -> <&'a StructArray as IntoIterator>::IntoIter
§impl PartialEq<&(dyn Array + 'static)> for StructArray
 
impl PartialEq<&(dyn Array + 'static)> for StructArray
§impl PartialEq for StructArray
 
impl PartialEq for StructArray
§fn eq(&self, other: &StructArray) -> bool
 
fn eq(&self, other: &StructArray) -> bool
self and other values to be equal, and is used
by ==.§impl Splitable for StructArray
 
impl Splitable for StructArray
fn check_bound(&self, offset: usize) -> bool
§unsafe fn _split_at_unchecked(
    &self,
    offset: usize
) -> (StructArray, StructArray)
 
unsafe fn _split_at_unchecked( &self, offset: usize ) -> (StructArray, StructArray)
split_at_unchecked. For any usage, prefer the using
split_at or split_at_unchecked. Read more§fn split_at(&self, offset: usize) -> (Self, Self)
 
fn split_at(&self, offset: usize) -> (Self, Self)
Self] at offset where offset <= self.len().§unsafe fn split_at_unchecked(&self, offset: usize) -> (Self, Self)
 
unsafe fn split_at_unchecked(&self, offset: usize) -> (Self, Self)
source§impl TryFrom<StructArray> for DataFrame
 
impl TryFrom<StructArray> for DataFrame
§type Error = PolarsError
 
type Error = PolarsError
source§fn try_from(arr: StructArray) -> Result<DataFrame, PolarsError>
 
fn try_from(arr: StructArray) -> Result<DataFrame, PolarsError>
Auto Trait Implementations§
impl !Freeze for StructArray
impl !RefUnwindSafe for StructArray
impl Send for StructArray
impl Sync for StructArray
impl Unpin for StructArray
impl !UnwindSafe for StructArray
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> 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§impl<T> Pointable for T
 
impl<T> Pointable for T
§impl<A> PolarsArray for Awhere
    A: Array + ?Sized,
 
impl<A> PolarsArray for Awhere
    A: Array + ?Sized,
fn has_validity(&self) -> bool
§impl<T> SlicedArray for Twhere
    T: Array + Clone,
 
impl<T> SlicedArray for Twhere
    T: Array + Clone,
§fn slice_typed(&self, offset: usize, length: usize) -> T
 
fn slice_typed(&self, offset: usize, length: usize) -> T
Array]. Read more§unsafe fn slice_typed_unchecked(&self, offset: usize, length: usize) -> T
 
unsafe fn slice_typed_unchecked(&self, offset: usize, length: usize) -> T
Array]. Read more