pub struct VariantArray {
inner: StructArray,
metadata_ref: ArrayRef,
value_ref: ArrayRef,
}
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
StructArray of up to three fields:
-
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.
metadata_ref: ArrayRef
Reference to the metadata column of inner
value_ref: ArrayRef
Reference to the value column of inner
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
§Current support
This structure does not (yet) support the full Arrow Variant Array specification.
Only StructArrays
with metadata
and value
fields that are
BinaryViewArray
are supported. Shredded values are not currently supported
nor are using types other than BinaryViewArray
Sourcepub fn into_inner(self) -> StructArray
pub fn into_inner(self) -> StructArray
Returns the inner [StructArray
], consuming self
Sourcepub fn value(&self, index: usize) -> Variant<'_, '_>
pub fn value(&self, index: usize) -> Variant<'_, '_>
Return the [Variant
] instance stored at the given row
Panics if the index is out of bounds.
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.
fn find_metadata_field(array: &StructArray) -> Option<ArrayRef>
fn find_value_field(array: &StructArray) -> Option<ArrayRef>
Sourcepub fn metadata_field(&self) -> &ArrayRef
pub fn metadata_field(&self) -> &ArrayRef
Return a reference to the metadata field of the [StructArray
]
Sourcepub fn value_field(&self) -> &ArrayRef
pub fn value_field(&self) -> &ArrayRef
Return a reference to the value field of the StructArray
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