1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors
//! Vortex crate containing core logic for encoding and memory representation of [arrays](ArrayRef).
//!
//! At the heart of Vortex are [arrays](ArrayRef).
//!
//! Arrays are typed views of memory buffers that hold [scalars](crate::scalar::Scalar). These
//! buffers can be held in a number of physical encodings to perform lightweight compression that
//! exploits the particular data distribution of the array's values.
//!
//! Every data type recognized by Vortex also has a canonical physical encoding format, which
//! arrays can be [canonicalized](Canonical) into for ease of access in compute functions.
//!
//! # Core Handles
//!
//! [`ArrayRef`] is the erased, shared handle used by most public APIs. It carries the logical
//! [`DType`], row count, encoding id, children, buffers, and statistics for an
//! array tree. Use it when an API should accept any encoding.
//!
//! [`Array<V>`] is the typed owned handle for a known encoding `V: VTable`. It wraps an
//! [`ArrayRef`] and dereferences to the encoding-specific `V::TypedArrayData`.
//!
//! [`ArrayView<V>`] is the lightweight typed borrow handed to vtable methods. It exposes both the
//! shared [`ArrayRef`] metadata and the encoding-specific data without cloning the handle.
//!
//! [`ArrayParts<V>`] is the construction boundary for typed arrays. It groups externally supplied
//! logical metadata and encoding data, then [`Array::try_from_parts`] validates that they agree.
//!
//! # Logical Types and Physical Encodings
//!
//! A [`DType`] describes the logical values an array may hold. It does not
//! describe the memory layout. For example, a `DType::Primitive(I32, Nullable)` can be stored as a
//! canonical [`PrimitiveArray`], a dictionary, a slice, or a
//! compressed external encoding.
//!
//! The [`Canonical`] enum names the default uncompressed encoding for each logical family. Execution
//! normally moves an array tree toward canonical form, but canonicalization is shallow: children of
//! canonical struct/list arrays may still be encoded.
//!
//! # Built-in, Lazy, and Experimental Arrays
//!
//! Built-in arrays live in [`arrays`]. Some are canonical (`PrimitiveArray`, `StructArray`,
//! `VarBinViewArray`); others are utility or lazy arrays such as [`ChunkedArray`],
//! [`ConstantArray`], [`FilterArray`], [`SliceArray`], and [`ScalarFnArray`].
//! Lazy arrays defer work so compute kernels can operate on encoded data or prune children
//! before materialization.
//!
//! Experimental arrays are public because they are used inside Vortex, but their storage contracts
//! may still move. Prefer the higher-level constructors and accessors documented on each array
//! module rather than relying on child slot order.
//!
//! # Nulls and Scalars
//!
//! [`Validity`](crate::validity::Validity) separates nullness from values. It can be a cheap
//! constant state (`NonNullable`, `AllValid`, `AllInvalid`) or a boolean array that may itself be
//! encoded. [`Scalar`](crate::scalar::Scalar) is the single-value counterpart: it pairs a
//! [`DType`] with an optional [`ScalarValue`](crate::scalar::ScalarValue).
//!
//! # Extending Vortex
//!
//! New array encodings implement [`VTable`], usually through the local `array_slots!` and
//! `vtable!` patterns used by built-ins. The important extension contracts are:
//!
//! - [`VTable::validate`] checks that externally supplied dtype, length, slots, and data agree.
//! - [`VTable::execute`] returns an [`ExecutionResult`] that makes progress toward canonical form.
//! - [`OperationsVTable`] provides scalar access.
//! - [`ValidityVTable`] exposes validity only for nullable arrays.
//!
//! New logical extension dtypes implement [`ExtVTable`](crate::dtype::extension::ExtVTable) and
//! store values in an ordinary Vortex storage dtype.
//!
//! [`PrimitiveArray`]: crate::arrays::PrimitiveArray
//! [`DType`]: crate::dtype::DType
//! [`ChunkedArray`]: crate::arrays::ChunkedArray
//! [`ConstantArray`]: crate::arrays::ConstantArray
//! [`FilterArray`]: crate::arrays::FilterArray
//! [`SliceArray`]: crate::arrays::SliceArray
//! [`ScalarFnArray`]: crate::arrays::ScalarFnArray
extern crate self as vortex_array;
use LazyLock;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use smallvec;
pub use array_slots;
use SessionExt;
use VortexSession;
use Context;
use crateAggregateFnSession;
use crateArrowSession;
use crateDTypeSession;
use crateMemorySession;
use crateKernelSession;
use crateScalarFnSession;
use crateArraySession;
use crateStatsSession;
/// Register vortex-array's built-in session-scoped kernels into the active
/// [`ArrayKernels`](crate::optimizer::kernels::ArrayKernels) registry.
///
/// If the session contains a [`KernelSession`], this registers into its registry. Sessions that use
/// [`KernelSession::default`] already receive these built-in kernels.
/// Builds a fresh [`VortexSession`] registered with all of vortex-array's built-in session
/// variables: arrays, dtypes, scalar functions, stats, optimizer kernels, aggregate functions,
/// Arrow conversion, and memory.
///
/// Each call returns an independent session (with its own registries), so callers may register
/// additional encodings or kernels into it without affecting any other session. This does not
/// register file, layout, or runtime state — those live in higher-level crates.
// TODO(ngates): canonicalize doesn't currently take a session, therefore we cannot invoke execute
// from the new array encodings to support back-compat for legacy encodings. So we hold a session
// here...
pub static LEGACY_SESSION: = new;
pub type ArrayContext = ;