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
14use crate::dtype::DType;
15use crate::dtype::Nullability;
16use crate::dtype::PType;
17
18mod array;
19pub use array::UnionArrayExt;
20pub use array::UnionDataParts;
21pub use vtable::UnionArray;
22
23pub(crate) mod compute;
24
25mod vtable;
26pub use vtable::Union;
27
28pub(crate) fn union_type_ids_dtype(nullability: Nullability) -> DType {
29    DType::Primitive(PType::U8, nullability)
30}
31
32#[cfg(test)]
33mod tests;