Struct arrow_array::array::MapArray
source · pub struct MapArray { /* private fields */ }
Expand description
An array of key-value maps
Keys should always be non-null, but values can be null.
MapArray
is physically a ListArray
of key values pairs stored as an entries
StructArray
with 2 child fields.
See MapBuilder
for how to construct a MapArray
Implementations§
source§impl MapArray
impl MapArray
sourcepub fn try_new(
field: FieldRef,
offsets: OffsetBuffer<i32>,
entries: StructArray,
nulls: Option<NullBuffer>,
ordered: bool
) -> Result<Self, ArrowError>
pub fn try_new( field: FieldRef, offsets: OffsetBuffer<i32>, entries: StructArray, nulls: Option<NullBuffer>, ordered: bool ) -> Result<Self, ArrowError>
Create a new MapArray
from the provided parts
See MapBuilder
for a higher-level interface
to construct a MapArray
Errors
Errors if
offsets.len() - 1 != nulls.len()
offsets.last() > entries.len()
field.is_nullable()
entries.null_count() != 0
entries.columns().len() != 2
field.data_type() != entries.data_type()
sourcepub fn new(
field: FieldRef,
offsets: OffsetBuffer<i32>,
entries: StructArray,
nulls: Option<NullBuffer>,
ordered: bool
) -> Self
pub fn new( field: FieldRef, offsets: OffsetBuffer<i32>, entries: StructArray, nulls: Option<NullBuffer>, ordered: bool ) -> Self
Create a new MapArray
from the provided parts
See MapBuilder
for a higher-level interface
to construct a MapArray
Panics
Panics if Self::try_new
returns an error
sourcepub fn into_parts(
self
) -> (FieldRef, OffsetBuffer<i32>, StructArray, Option<NullBuffer>, bool)
pub fn into_parts( self ) -> (FieldRef, OffsetBuffer<i32>, StructArray, Option<NullBuffer>, bool)
Deconstruct this array into its constituent parts
sourcepub fn offsets(&self) -> &OffsetBuffer<i32>
pub fn offsets(&self) -> &OffsetBuffer<i32>
Returns a reference to the offsets of this map
Unlike Self::value_offsets
this returns the OffsetBuffer
allowing for zero-copy cloning
sourcepub fn entries(&self) -> &StructArray
pub fn entries(&self) -> &StructArray
Returns a reference to the StructArray
entries of this map
sourcepub fn value_type(&self) -> &DataType
pub fn value_type(&self) -> &DataType
Returns the data type of the map’s values.
sourcepub unsafe fn value_unchecked(&self, i: usize) -> StructArray
pub unsafe fn value_unchecked(&self, i: usize) -> StructArray
Returns ith value of this map array.
Safety
Caller must ensure that the index is within the array bounds
sourcepub fn value(&self, i: usize) -> StructArray
pub fn value(&self, i: usize) -> StructArray
Returns ith value of this map array.
This is a StructArray
containing two fields
sourcepub fn value_offsets(&self) -> &[i32]
pub fn value_offsets(&self) -> &[i32]
Returns the offset values in the offsets buffer
sourcepub fn value_length(&self, i: usize) -> i32
pub fn value_length(&self, i: usize) -> i32
Returns the length for value at index i
.
sourcepub fn slice(&self, offset: usize, length: usize) -> Self
pub fn slice(&self, offset: usize, length: usize) -> Self
Returns a zero-copy slice of this array with the indicated offset and length.
sourcepub fn iter(&self) -> MapArrayIter<'_>
pub fn iter(&self) -> MapArrayIter<'_>
constructs a new iterator
Trait Implementations§
source§impl Array for MapArray
impl Array for MapArray
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 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.source§fn logical_nulls(&self) -> Option<NullBuffer>
fn logical_nulls(&self) -> Option<NullBuffer>
source§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 moresource§fn null_count(&self) -> usize
fn null_count(&self) -> usize
source§fn is_nullable(&self) -> bool
fn is_nullable(&self) -> bool
false
if the array is guaranteed to not contain any logical nulls Read more