pub struct UnionArray { /* private fields */ }Expand description
An Array that can represent slots of varying types
Implementations§
Source§impl UnionArray
impl UnionArray
Sourcepub fn new(
type_ids: Buffer,
value_offsets: Option<Buffer>,
child_arrays: Vec<(Field, ArrayRef)>,
bitmap_data: Option<(Buffer, usize)>,
) -> Self
pub fn new( type_ids: Buffer, value_offsets: Option<Buffer>, child_arrays: Vec<(Field, ArrayRef)>, bitmap_data: Option<(Buffer, usize)>, ) -> Self
Creates a new UnionArray.
Accepts type ids, child arrays and optionally offsets (for dense unions) to create
a new UnionArray. This method makes no attempt to validate the data provided by the
caller and assumes that each of the components are correct and consistent with each other.
See try_new for an alternative that validates the data provided.
§Data Consistency
The type_ids Buffer should contain i8 values. These values should be greater than
zero and must be less than the number of children provided in child_arrays. These values
are used to index into the child_arrays.
The value_offsets Buffer is only provided in the case of a dense union, sparse unions
should use None. If provided the value_offsets Buffer should contain i32 values.
These values should be greater than zero and must be less than the length of the overall
array.
In both cases above we use signed integer types to maintain compatibility with other Arrow implementations.
In both of the cases above we are accepting Buffer’s which are assumed to be representing
i8 and i32 values respectively. Buffer objects are untyped and no attempt is made
to ensure that the data provided is valid.
Sourcepub fn try_new(
type_ids: Buffer,
value_offsets: Option<Buffer>,
child_arrays: Vec<(Field, ArrayRef)>,
bitmap: Option<Buffer>,
) -> Result<Self>
pub fn try_new( type_ids: Buffer, value_offsets: Option<Buffer>, child_arrays: Vec<(Field, ArrayRef)>, bitmap: Option<Buffer>, ) -> Result<Self>
Attempts to create a new UnionArray and validates the inputs provided.
Sourcepub fn child(&self, type_id: i8) -> ArrayRef
pub fn child(&self, type_id: i8) -> ArrayRef
Accesses the child array for type_id.
§Panics
Panics if the type_id provided is less than zero or greater than the number of types
in the Union.
Sourcepub fn type_id(&self, index: usize) -> i8
pub fn type_id(&self, index: usize) -> i8
Returns the type_id for the array slot at index.
§Panics
Panics if index is greater than the length of the array.
Sourcepub fn value_offset(&self, index: usize) -> i32
pub fn value_offset(&self, index: usize) -> i32
Returns the offset into the underlying values array for the array slot at index.
§Panics
Panics if index is greater than the length of the array.
Sourcepub fn value(&self, index: usize) -> ArrayRef
pub fn value(&self, index: usize) -> ArrayRef
Returns the array’s value at index.
§Panics
Panics if index is greater than the length of the array.
Sourcepub fn type_names(&self) -> Vec<&str>
pub fn type_names(&self) -> Vec<&str>
Returns the names of the types in the union.
Trait Implementations§
Source§impl Array for UnionArray
impl Array for UnionArray
Source§fn data(&self) -> ArrayDataRef
fn data(&self) -> ArrayDataRef
Source§fn data_ref(&self) -> &ArrayDataRef
fn data_ref(&self) -> &ArrayDataRef
Source§fn slice(&self, offset: usize, length: usize) -> ArrayRef
fn slice(&self, offset: usize, length: usize) -> ArrayRef
Source§fn offset(&self) -> usize
fn offset(&self) -> usize
0. Read moreSource§fn is_null(&self, index: usize) -> bool
fn is_null(&self, index: usize) -> bool
index is null.
When using this function on a slice, the index is relative to the slice. Read moreSource§fn is_valid(&self, index: usize) -> bool
fn is_valid(&self, index: usize) -> bool
index is not null.
When using this function on a slice, the index is relative to the slice. Read more