StructArray in polars::prelude - Rust (original) (raw)
Struct StructArray
pub struct StructArray { /* private fields */ }
Available on crate feature 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".into(), ArrowDataType::Boolean, false),
Field::new("c".into(), ArrowDataType::Int32, false),
];
let array = StructArray::new(ArrowDataType::Struct(fields), 4, vec![boolean, int], None);
Returns an iterator of Option<Box<dyn Array>>
Returns an iterator of Box<dyn Array>
Returns a new StructArray.
§Errors
This function errors iff:
dtype
’s physical type is not [crate::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
Returns a new StructArray
§Panics
This function panics iff:
dtype
’s physical type is not [crate::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
Deconstructs the StructArray into its individual components.
Slices this StructArray.
§Panics
panics iff offset + length > self.len()
§Implementation
This operation is O(F)
where F
is the number of fields.
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()
.
Returns this array sliced.
§Implementation
This function is O(1)
.
§Panics
iff offset + length > self.len()
.
Returns this array sliced.
§Implementation
This function is O(1)
.
§Safety
The caller must ensure that offset + length <= self.len()
.
Returns this array with a new validity.
§Panic
Panics iff validity.len() != self.len()
.
Sets the validity of this array.
§Panics
This function panics iff values.len() != self.len()
.
Takes the validity of this array, leaving it without a validity mask.
Returns the fields the DataType::Struct
.
Converts itself to a reference of Any, which enables downcasting to concrete types.
Converts itself to a mutable reference of Any, which enables mutable downcasting to concrete types.
The length of the [Array
]. Every array has a length corresponding to the number of elements (slots).
The ArrowDataType of the [Array
]. In combination with [Array::as_any
], this can be used to downcast trait objects (dyn Array
) to concrete arrays.
Split [Self
] at offset
into two boxed [Array
]s where offset <= self.len()
.
Split [Self
] at offset
into two boxed [Array
]s without checking offset <= self.len()
. Read more
Clone a &dyn Array
to an owned Box<dyn Array>
.
The validity of the [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.
Clones this [Array
] with a new assigned bitmap. Read more
whether the array is empty
The number of null slots on this [Array
]. Read more
Returns whether slot i
is null. Read more
Returns whether slot i
is null. Read more
Returns whether slot i
is valid. Read more
Returns a slice of this [Array
]. Read more
Returns a slice of this [Array
]. Read more
Formats the value using the given formatter. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
Tests for self
and other
values to be equal, and is used by ==
.
Tests for !=
. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Tests for self
and other
values to be equal, and is used by ==
.
Tests for !=
. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Internal implementation of split_at_unchecked
. For any usage, prefer the usingsplit_at
or split_at_unchecked
. Read more
Split [Self
] at offset
where offset <= self.len()
.
Split [Self
] at offset
without checking offset <= self.len()
. Read more
The type returned in the event of a conversion error.
Performs the conversion.