Struct polars_arrow::array::ListArray
source · pub struct ListArray<O: Offset> { /* private fields */ }Expand description
An Array semantically equivalent to Vec<Option<Vec<Option<T>>>> with Arrow’s in-memory.
Implementations§
source§impl<'a, O: Offset> ListArray<O>
impl<'a, O: Offset> ListArray<O>
sourcepub fn iter(
&'a self
) -> ZipValidity<Box<dyn Array>, ListValuesIter<'a, O>, BitmapIter<'a>> ⓘ
pub fn iter( &'a self ) -> ZipValidity<Box<dyn Array>, ListValuesIter<'a, O>, BitmapIter<'a>> ⓘ
Returns an iterator of Option<Box<dyn Array>>
sourcepub fn values_iter(&'a self) -> ListValuesIter<'a, O>
pub fn values_iter(&'a self) -> ListValuesIter<'a, O>
Returns an iterator of Box<dyn Array>
sourcepub fn non_null_values_iter(&'a self) -> NonNullValuesIter<'a, ListArray<O>> ⓘ
pub fn non_null_values_iter(&'a self) -> NonNullValuesIter<'a, ListArray<O>> ⓘ
Returns an iterator of the non-null values Box<dyn Array>.
source§impl<O: Offset> ListArray<O>
impl<O: Offset> ListArray<O>
sourcepub fn try_new(
data_type: ArrowDataType,
offsets: OffsetsBuffer<O>,
values: Box<dyn Array>,
validity: Option<Bitmap>
) -> PolarsResult<Self>
pub fn try_new( data_type: ArrowDataType, offsets: OffsetsBuffer<O>, values: Box<dyn Array>, validity: Option<Bitmap> ) -> PolarsResult<Self>
Creates a new ListArray.
Errors
This function returns an error iff:
- The last offset is not equal to the values’ length.
- the validity’s length is not equal to
offsets.len(). - The
data_type’scrate::datatypes::PhysicalTypeis not equal to eithercrate::datatypes::PhysicalType::Listorcrate::datatypes::PhysicalType::LargeList. - The
data_type’s inner field’s data type is not equal tovalues.data_type.
Implementation
This function is O(1)
sourcepub fn new(
data_type: ArrowDataType,
offsets: OffsetsBuffer<O>,
values: Box<dyn Array>,
validity: Option<Bitmap>
) -> Self
pub fn new( data_type: ArrowDataType, offsets: OffsetsBuffer<O>, values: Box<dyn Array>, validity: Option<Bitmap> ) -> Self
Creates a new ListArray.
Panics
This function panics iff:
- The last offset is not equal to the values’ length.
- the validity’s length is not equal to
offsets.len(). - The
data_type’scrate::datatypes::PhysicalTypeis not equal to eithercrate::datatypes::PhysicalType::Listorcrate::datatypes::PhysicalType::LargeList. - The
data_type’s inner field’s data type is not equal tovalues.data_type.
Implementation
This function is O(1)
sourcepub fn new_empty(data_type: ArrowDataType) -> Self
pub fn new_empty(data_type: ArrowDataType) -> Self
Returns a new empty ListArray.
sourcepub fn new_null(data_type: ArrowDataType, length: usize) -> Self
pub fn new_null(data_type: ArrowDataType, length: usize) -> Self
Returns a new null ListArray.
source§impl<O: Offset> ListArray<O>
impl<O: Offset> ListArray<O>
sourcepub unsafe fn slice_unchecked(&mut self, offset: usize, length: usize)
pub unsafe fn slice_unchecked(&mut self, offset: usize, length: usize)
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<O: Offset> ListArray<O>
impl<O: Offset> ListArray<O>
source§impl<O: Offset> ListArray<O>
impl<O: Offset> ListArray<O>
sourcepub fn default_datatype(data_type: ArrowDataType) -> ArrowDataType
pub fn default_datatype(data_type: ArrowDataType) -> ArrowDataType
Returns a default ArrowDataType: inner field is named “item” and is nullable
sourcepub fn get_child_field(data_type: &ArrowDataType) -> &Field
pub fn get_child_field(data_type: &ArrowDataType) -> &Field
sourcepub fn try_get_child(data_type: &ArrowDataType) -> PolarsResult<&Field>
pub fn try_get_child(data_type: &ArrowDataType) -> PolarsResult<&Field>
sourcepub fn get_child_type(data_type: &ArrowDataType) -> &ArrowDataType
pub fn get_child_type(data_type: &ArrowDataType) -> &ArrowDataType
Returns a the inner ArrowDataType
Panics
Panics iff the logical type is not consistent with this struct.
Trait Implementations§
source§impl<O: Offset> Array for ListArray<O>
impl<O: Offset> Array for ListArray<O>
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 more