pub struct VariantArray {
inner: StructArray,
shredding_state: ShreddingState,
}
Expand description
An array of Parquet [Variant
] values
A VariantArray
wraps an Arrow [StructArray
] that stores the underlying
metadata
and value
fields, and adds convenience methods to access
the Variant
s
See VariantArrayBuilder
for constructing a VariantArray
.
§Specification
- This code follows the conventions for storing variants in Arrow
StructArray
defined by Extension Type for Parquet Variant arrow and this document. At the time of this writing, this is not yet a standardized Arrow extension type.
Fields§
§inner: StructArray
Reference to the underlying StructArray
shredding_state: ShreddingState
how is this variant array shredded?
Implementations§
Source§impl VariantArray
impl VariantArray
Sourcepub fn try_new(inner: ArrayRef) -> Result<Self, ArrowError>
pub fn try_new(inner: ArrayRef) -> Result<Self, ArrowError>
Creates a new VariantArray
from a [StructArray
].
§Arguments
inner
- The underlying [StructArray
] that contains the variant data.
§Returns
- A new instance of
VariantArray
.
§Errors:
- If the
StructArray
does not contain the required fields
§Requirements of the StructArray
-
A required field named
metadata
which is binary, large_binary, or binary_view -
An optional field named
value
that is binary, large_binary, or binary_view -
An optional field named
typed_value
which can be any primitive type or be a list, large_list, list_view or struct
NOTE: It is also permissible for the metadata field to be Dictionary-Encoded, preferably (but not required) with an index type of int8.
Currently, only [BinaryViewArray
] are supported.
Sourcepub fn into_inner(self) -> StructArray
pub fn into_inner(self) -> StructArray
Returns the inner [StructArray
], consuming self
Sourcepub fn shredding_state(&self) -> &ShreddingState
pub fn shredding_state(&self) -> &ShreddingState
Return the shredding state of this VariantArray
Sourcepub fn value(&self, index: usize) -> Variant<'_, '_>
pub fn value(&self, index: usize) -> Variant<'_, '_>
Return the [Variant
] instance stored at the given row
Consistently with other Arrow arrays types, this API requires you to
check for nulls first using Self::is_valid
.
§Panics
- if the index is out of bounds
- if the array value is null
If this is a shredded variant but has no value at the shredded location, it
will return [Variant::Null
].
§Performance Note
This is certainly not the most efficient way to access values in a
VariantArray
, but it is useful for testing and debugging.
Note: Does not do deep validation of the [Variant
], so it is up to the
caller to ensure that the metadata and value were constructed correctly.
Sourcepub fn metadata_field(&self) -> &BinaryViewArray
pub fn metadata_field(&self) -> &BinaryViewArray
Return a reference to the metadata field of the [StructArray
]
Sourcepub fn value_field(&self) -> Option<&BinaryViewArray>
pub fn value_field(&self) -> Option<&BinaryViewArray>
Return a reference to the value field of the StructArray
Sourcepub fn typed_value_field(&self) -> Option<&ArrayRef>
pub fn typed_value_field(&self) -> Option<&ArrayRef>
Return a reference to the typed_value field of the StructArray
, if present
Trait Implementations§
Source§impl Array for VariantArray
impl Array for VariantArray
Source§fn data_type(&self) -> &DataType
fn data_type(&self) -> &DataType
DataType
] of this array. Read moreSource§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 nulls(&self) -> Option<&NullBuffer>
fn nulls(&self) -> Option<&NullBuffer>
Source§fn get_buffer_memory_size(&self) -> usize
fn get_buffer_memory_size(&self) -> usize
Source§fn get_array_memory_size(&self) -> usize
fn get_array_memory_size(&self) -> usize
get_buffer_memory_size()
and
includes the overhead of the data structures that contain the pointers to the various buffers.§fn shrink_to_fit(&mut self)
fn shrink_to_fit(&mut self)
§fn logical_nulls(&self) -> Option<NullBuffer>
fn logical_nulls(&self) -> Option<NullBuffer>
NullBuffer
] that represents the logical
null values of this array, if any. Read more§fn null_count(&self) -> usize
fn null_count(&self) -> usize
§fn logical_null_count(&self) -> usize
fn logical_null_count(&self) -> usize
§fn is_nullable(&self) -> bool
fn is_nullable(&self) -> bool
false
if the array is guaranteed to not contain any logical nulls Read more