Skip to main content

vortex_array/arrays/union/
mod.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4//! Canonical sparse union arrays.
5//!
6//! A [`UnionArray`] stores one `u8` type ID per row followed by one row-aligned child for each
7//! variant. The type ID selects which child's value is active for a row; values in all other
8//! children at that row are placeholders. Outer union nulls are stored as nulls in the type IDs
9//! child, independently of nulls in the selected variant child.
10//!
11//! Type ID values are not validated during construction. Accessing a non-null row whose type ID
12//! is not declared by the union variants will panic.
13//!
14//! Mask rewrites only the type IDs. Slice and take rewrite every child to keep them row-aligned,
15//! so each costs `O(variants)` child operations.
16
17use crate::dtype::DType;
18use crate::dtype::Nullability;
19use crate::dtype::PType;
20
21mod array;
22pub use array::UnionArrayExt;
23pub use array::UnionArraySlotsExt;
24pub use array::UnionDataParts;
25pub use array::UnionSlots;
26pub use array::UnionSlotsView;
27pub use vtable::UnionArray;
28
29pub(crate) mod compute;
30
31mod vtable;
32pub use vtable::Union;
33
34pub(crate) fn union_type_ids_dtype(nullability: Nullability) -> DType {
35    DType::Primitive(PType::U8, nullability)
36}
37
38#[cfg(test)]
39mod tests;