pub struct StructArray { /* private fields */ }Expand description
A column of named child columns of equal length.
Implementations§
Source§impl StructArray
impl StructArray
Sourcepub fn try_new(
fields: Vec<Field>,
columns: Vec<ArrayRef>,
validity: Option<Bitmap>,
) -> Result<Self>
pub fn try_new( fields: Vec<Field>, columns: Vec<ArrayRef>, validity: Option<Bitmap>, ) -> Result<Self>
Builds a struct array from its fields and columns.
§Errors
DataError::ColumnCountMismatchwhen the counts disagree.DataError::TypeMismatchwhen a column’s type differs from its field’s.DataError::ColumnLengthMismatchwhen the columns are not all the same length.DataError::UnknownStructLengthwhen there are no columns.DataError::ValidityLengthMismatchwhen the bitmap length is wrong.
Sourcepub fn try_new_with_len(
fields: Vec<Field>,
columns: Vec<ArrayRef>,
len: usize,
validity: Option<Bitmap>,
) -> Result<Self>
pub fn try_new_with_len( fields: Vec<Field>, columns: Vec<ArrayRef>, len: usize, validity: Option<Bitmap>, ) -> Result<Self>
Builds a struct array with an explicit length.
Required for the zero-column case, and useful when the caller already knows the row count.
§Errors
The same set as StructArray::try_new, minus
DataError::UnknownStructLength.
use astrs_data::array::{Array, StructArray};
let empty = StructArray::try_new_with_len(Vec::new(), Vec::new(), 4, None)?;
assert_eq!(empty.len(), 4);
assert_eq!(empty.num_columns(), 0);Sourcepub fn new_null(fields: Vec<Field>, len: usize) -> Result<Self>
pub fn new_null(fields: Vec<Field>, len: usize) -> Result<Self>
An all-null struct array of len rows.
Every child column is itself all-null, which keeps the layout valid.
§Errors
DataError::InvalidFixedSize when a child type carries a
non-positive fixed width.
Sourcepub const fn num_columns(&self) -> usize
pub const fn num_columns(&self) -> usize
Number of child columns.
Sourcepub fn column_by_name(&self, name: &str) -> Option<&ArrayRef>
pub fn column_by_name(&self, name: &str) -> Option<&ArrayRef>
The first child column named name.
Sourcepub fn try_column_by_name(&self, name: &str) -> Result<&ArrayRef>
pub fn try_column_by_name(&self, name: &str) -> Result<&ArrayRef>
Sourcepub fn value(&self, index: usize) -> Option<Self>
pub fn value(&self, index: usize) -> Option<Self>
The row at index as a one-row struct array, ignoring validity.
Returns None only when index is out of range.
Sourcepub fn get(&self, index: usize) -> Option<Self>
pub fn get(&self, index: usize) -> Option<Self>
The logical row at index: None when the row is null or out of range.
Sourcepub fn slice(&self, offset: usize, len: usize) -> Self
pub fn slice(&self, offset: usize, len: usize) -> Self
A zero-copy sub-range, clamped to the array (the crate-wide slicing convention).
Every child column is sliced by the same window.
Sourcepub fn with_validity(&self, validity: Option<Bitmap>) -> Result<Self>
pub fn with_validity(&self, validity: Option<Bitmap>) -> Result<Self>
Returns a copy with a different validity bitmap.
§Errors
DataError::ValidityLengthMismatch when the bitmap length is wrong.
Trait Implementations§
Source§impl Array for StructArray
impl Array for StructArray
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
ArrayExt::downcast.Source§fn validity(&self) -> Option<&Bitmap>
fn validity(&self) -> Option<&Bitmap>
None when every slot is valid. Read moreSource§fn buffer_memory_size(&self) -> usize
fn buffer_memory_size(&self) -> usize
Source§fn children(&self) -> Vec<&ArrayRef> ⓘ
fn children(&self) -> Vec<&ArrayRef> ⓘ
Source§fn null_count(&self) -> usize
fn null_count(&self) -> usize
Source§impl Clone for StructArray
impl Clone for StructArray
Source§impl Debug for StructArray
impl Debug for StructArray
Auto Trait Implementations§
impl !Freeze for StructArray
impl !RefUnwindSafe for StructArray
impl !UnwindSafe for StructArray
impl Send for StructArray
impl Sync for StructArray
impl Unpin for StructArray
impl UnsafeUnpin 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§impl<A> IntoArrayRef for Awhere
A: Array,
impl<A> IntoArrayRef for Awhere
A: Array,
Source§fn into_array_ref(self) -> ArrayRef
fn into_array_ref(self) -> ArrayRef
self into a shared, dynamically typed column.