Skip to main content

vortex_array/arrays/variant/
mod.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4mod vtable;
5
6pub use self::vtable::Variant;
7use crate::ArrayRef;
8
9/// The canonical in-memory representation of variant (semi-structured) data.
10///
11/// Wraps a single child array that contains the actual variant-encoded data
12/// (e.g. a `ParquetVariantArray` or any other variant encoding).
13///
14/// Nullability is delegated to the child array: `VariantArray`'s dtype is
15/// always the child's dtype. The child's validity determines which rows are
16/// null.
17#[derive(Clone, Debug)]
18pub struct VariantArray {
19    child: ArrayRef,
20}
21
22impl VariantArray {
23    /// Creates a new VariantArray. Nullability comes from the child's dtype.
24    pub fn new(child: ArrayRef) -> Self {
25        Self { child }
26    }
27
28    /// Returns a reference to the underlying child array.
29    pub fn child(&self) -> &ArrayRef {
30        &self.child
31    }
32}