pub struct StructArray { /* private fields */ }
json
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".into(), ArrowDataType::Boolean, false),
Field::new("c".into(), ArrowDataType::Int32, false),
];
let array = StructArray::new(ArrowDataType::Struct(fields), 4, 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(
dtype: ArrowDataType,
length: usize,
values: Vec<Box<dyn Array>>,
validity: Option<Bitmap>,
) -> Result<StructArray, PolarsError>
pub fn try_new( dtype: ArrowDataType, length: usize, values: Vec<Box<dyn Array>>, validity: Option<Bitmap>, ) -> Result<StructArray, PolarsError>
Returns a new StructArray
.
§Errors
This function errors iff:
dtype
’s physical type is notcrate::datatypes::PhysicalType::Struct
.- the children of
dtype
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(
dtype: ArrowDataType,
length: usize,
values: Vec<Box<dyn Array>>,
validity: Option<Bitmap>,
) -> StructArray
pub fn new( dtype: ArrowDataType, length: usize, values: Vec<Box<dyn Array>>, validity: Option<Bitmap>, ) -> StructArray
Returns a new StructArray
§Panics
This function panics iff:
dtype
’s physical type is notcrate::datatypes::PhysicalType::Struct
.- the children of
dtype
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_empty(dtype: ArrowDataType) -> StructArray
pub fn new_empty(dtype: ArrowDataType) -> StructArray
Creates an empty StructArray
.
Sourcepub fn new_null(dtype: ArrowDataType, length: usize) -> StructArray
pub fn new_null(dtype: ArrowDataType, length: usize) -> StructArray
Creates a null StructArray
of length length
.
Source§impl StructArray
impl StructArray
Sourcepub fn into_data(
self,
) -> (Vec<Field>, usize, Vec<Box<dyn Array>>, Option<Bitmap>)
pub fn into_data( self, ) -> (Vec<Field>, usize, 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 + length
must be smaller thanself.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 propagate_nulls(&self) -> StructArray
pub fn propagate_nulls(&self) -> StructArray
Set the outer nulls into the inner arrays.
Sourcepub fn sliced(self, offset: usize, length: usize) -> StructArray
pub fn sliced(self, offset: usize, length: usize) -> StructArray
Sourcepub unsafe fn sliced_unchecked(
self,
offset: usize,
length: usize,
) -> StructArray
pub unsafe fn sliced_unchecked( self, offset: usize, length: usize, ) -> StructArray
Sourcepub fn with_validity(self, validity: Option<Bitmap>) -> StructArray
pub fn with_validity(self, validity: Option<Bitmap>) -> StructArray
Sourcepub fn set_validity(&mut self, validity: Option<Bitmap>)
pub fn set_validity(&mut self, validity: Option<Bitmap>)
Sourcepub 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.
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(dtype: &ArrowDataType) -> &[Field]
pub fn get_fields(dtype: &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 + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Any
, which enables downcasting to concrete types.Source§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.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 ArrayFromIter<()> for StructArray
impl ArrayFromIter<()> for StructArray
fn arr_from_iter<I>(_iter: I) -> StructArraywhere
I: IntoIterator<Item = ()>,
fn try_arr_from_iter<E, I>(_iter: I) -> Result<StructArray, E>
fn arr_from_iter_trusted<I>(iter: I) -> Self
fn try_arr_from_iter_trusted<E, I>(iter: I) -> Result<Self, E>
Source§impl ArrayFromIter<Option<()>> for StructArray
impl ArrayFromIter<Option<()>> for StructArray
fn arr_from_iter<I>(_iter: I) -> StructArray
fn try_arr_from_iter<E, I>(_iter: I) -> Result<StructArray, E>
fn arr_from_iter_trusted<I>(iter: I) -> Self
fn try_arr_from_iter_trusted<E, I>(iter: I) -> Result<Self, E>
Source§impl ArrayFromIterDtype<()> for StructArray
impl ArrayFromIterDtype<()> for StructArray
fn arr_from_iter_with_dtype<I>(_dtype: ArrowDataType, _iter: I) -> StructArraywhere
I: IntoIterator<Item = ()>,
fn try_arr_from_iter_with_dtype<E, I>( _dtype: ArrowDataType, _iter: I, ) -> Result<StructArray, E>
fn arr_from_iter_trusted_with_dtype<I>(dtype: ArrowDataType, iter: I) -> Self
fn try_arr_from_iter_trusted_with_dtype<E, I>( dtype: ArrowDataType, iter: I, ) -> Result<Self, E>
Source§impl ArrayFromIterDtype<Option<()>> for StructArray
impl ArrayFromIterDtype<Option<()>> for StructArray
fn arr_from_iter_with_dtype<I>(_dtype: ArrowDataType, _iter: I) -> StructArray
fn try_arr_from_iter_with_dtype<E, I>( _dtype: ArrowDataType, _iter: I, ) -> Result<StructArray, E>
fn arr_from_iter_trusted_with_dtype<I>(dtype: ArrowDataType, iter: I) -> Self
fn try_arr_from_iter_trusted_with_dtype<E, I>( dtype: ArrowDataType, iter: I, ) -> Result<Self, E>
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 moreSource§impl Debug for StructArray
impl Debug for StructArray
Source§impl<'a> From<GrowableStruct<'a>> for StructArray
impl<'a> From<GrowableStruct<'a>> for StructArray
Source§fn from(val: GrowableStruct<'a>) -> StructArray
fn from(val: GrowableStruct<'a>) -> StructArray
Source§impl From<MutableStructArray> for StructArray
impl From<MutableStructArray> for StructArray
Source§fn from(other: MutableStructArray) -> StructArray
fn from(other: MutableStructArray) -> StructArray
Source§impl<'a> IntoIterator for &'a StructArray
impl<'a> IntoIterator for &'a StructArray
Source§type IntoIter = ZipValidity<Vec<Box<dyn Scalar>>, StructValueIter<'a>, BitmapIter<'a>>
type IntoIter = ZipValidity<Vec<Box<dyn Scalar>>, StructValueIter<'a>, BitmapIter<'a>>
Source§fn into_iter(self) -> <&'a StructArray as IntoIterator>::IntoIter
fn into_iter(self) -> <&'a StructArray as IntoIterator>::IntoIter
Source§impl PartialEq<&(dyn Array + 'static)> for StructArray
impl PartialEq<&(dyn Array + 'static)> for StructArray
Source§impl PartialEq for StructArray
impl PartialEq for StructArray
Source§impl Splitable for StructArray
impl Splitable for StructArray
fn check_bound(&self, offset: usize) -> bool
Source§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 moreSource§impl StaticArray for StructArray
impl StaticArray for StructArray
type ValueT<'a> = ()
type ZeroableValueT<'a> = ()
type ValueIterT<'a> = Repeat<()>
fn with_validity_typed(self, validity: Option<Bitmap>) -> StructArray
fn full_null(length: usize, dtype: ArrowDataType) -> StructArray
fn get(&self, idx: usize) -> Option<Self::ValueT<'_>>
fn last(&self) -> Option<Self::ValueT<'_>>
fn value(&self, idx: usize) -> Self::ValueT<'_>
fn as_slice(&self) -> Option<&[Self::ValueT<'_>]>
fn iter( &self, ) -> ZipValidity<Self::ValueT<'_>, Self::ValueIterT<'_>, BitmapIter<'_>>
fn values_iter(&self) -> Self::ValueIterT<'_>
fn from_vec(v: Vec<Self::ValueT<'_>>, dtype: ArrowDataType) -> Self
fn from_zeroable_vec( v: Vec<Self::ZeroableValueT<'_>>, dtype: ArrowDataType, ) -> Self
fn full(length: usize, value: Self::ValueT<'_>, dtype: ArrowDataType) -> Self
Source§impl TotalEqKernel for StructArray
impl TotalEqKernel for StructArray
type Scalar = Box<dyn Array>
fn tot_eq_kernel(&self, other: &StructArray) -> Bitmap
fn tot_ne_kernel(&self, other: &StructArray) -> Bitmap
fn tot_eq_kernel_broadcast( &self, _other: &<StructArray as TotalEqKernel>::Scalar, ) -> Bitmap
fn tot_ne_kernel_broadcast( &self, _other: &<StructArray as TotalEqKernel>::Scalar, ) -> Bitmap
fn tot_eq_missing_kernel(&self, other: &Self) -> Bitmap
fn tot_ne_missing_kernel(&self, other: &Self) -> Bitmap
fn tot_eq_missing_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap
fn tot_ne_missing_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap
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> 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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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