Struct arrow::array::UnionArray [−][src]
pub struct UnionArray { /* fields omitted */ }
Expand description
An Array that can represent slots of varying types.
Each slot in a UnionArray
can have a value chosen from a number of types. Each of the
possible types are named like the fields of a StructArray
.
A UnionArray
can have two possible memory layouts, “dense” or “sparse”. For more information
on please see the specification.
[UnionBuilder
]can be used to create UnionArray
’s of primitive types. UnionArray
’s of nested
types are also supported but not via UnionBuilder
, see the tests for examples.
Implementations
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.
Attempts to create a new UnionArray
and validates the inputs provided.
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
.
Returns the type_id
for the array slot at index
.
Panics
Panics if index
is greater than the length of the array.
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.
Returns the names of the types in the union.
Trait Implementations
Returns a reference-counted pointer to the underlying data of this array.
Returns a zero-copy slice of this array with the indicated offset and length. Read more
Returns the offset into the underlying data used by this array(-slice).
Note that the underlying data can be shared by many arrays.
This defaults to 0
. Read more
Returns whether the element at index
is null.
When using this function on a slice, the index is relative to the slice. Read more
Returns whether the element at index
is not null.
When using this function on a slice, the index is relative to the slice. Read more
Returns the total number of null values in this array. Read more
Returns the total number of bytes of memory pointed to by this array. The buffers store bytes in the Arrow memory format, and include the data as well as the validity map. Read more
Returns the total number of bytes of memory occupied physically by this array.
This value will always be greater than returned by get_buffer_memory_size()
and
includes the overhead of the data structures that contain the pointers to the various buffers. Read more
returns two pointers that represent this array in the C Data Interface (FFI)