Skip to content

Commit 24f57f6

Browse files
authored
ScalarFn VTable (#6679)
The vtable itself describes the behavior of a scalar function. I envisage us turning Expression into an enum in the future where ScalarFn is but one variant. This PR addresses the naming confusion (and prepares us to add AggregateFn VTable in the near future), as well as unifies the vtable names as per #6093 --------- Signed-off-by: Nicholas Gates <nick@nickgates.com>
1 parent ee29169 commit 24f57f6

File tree

251 files changed

+5594
-5466
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

251 files changed

+5594
-5466
lines changed

docs/developer-guide/internals/session.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Each Vortex crate defines a session variable that holds a registry for its exten
2929
|-------------------|------------------|----------------------------------------------|
3030
| `DTypeSession` | `vortex-array` | Extension dtype vtables (Date, Time, ...) |
3131
| `ArraySession` | `vortex-array` | Array encoding vtables (ALP, FSST, ...) |
32-
| `ExprSession` | `vortex-array` | Scalar expression vtables |
32+
| `ScalarFnSession` | `vortex-array` | Scalar function vtables |
3333
| `LayoutSession` | `vortex-layout` | Layout encoding vtables (Flat, Chunked, ...) |
3434
| `RuntimeSession` | `vortex-io` | Async runtime handle |
3535
| `CudaSession` | `vortex-cuda` | CUDA context, kernels, and stream pool |
@@ -50,8 +50,8 @@ session.arrays().register(MyEncoding::ID, &MyEncoding);
5050
// Register a custom layout
5151
session.layouts().register(MyLayout::encoding());
5252

53-
// Register a custom expression
54-
session.expressions().register(MyExprVTable);
53+
// Register a custom scalar function
54+
session.scalar_fns().register(MyScalarFnVTable);
5555
```
5656

5757
Crates that bundle multiple plugins typically expose an `initialize` function that registers
@@ -102,6 +102,6 @@ the `.with::<T>()` builder:
102102
let session = VortexSession::empty()
103103
.with::<ArraySession>()
104104
.with::<LayoutSession>()
105-
.with::<ExprSession>()
105+
.with::<ScalarFnSession>()
106106
.with::<RuntimeSession>();
107107
```

docs/developer-guide/internals/vtables.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,12 @@ The reference implementation. All components follow the convention:
138138
- File layout: `vtable.rs`, `plugin.rs`, `typed.rs`, `erased.rs`, `matcher.rs`
139139
- `ExtDTypeMetadata` wrapper removed; methods inlined on `ExtDTypeRef`
140140

141-
### Expr -- Not started
141+
### ScalarFn -- Done
142142

143-
Currently uses `VTable` (unqualified), `VTableAdapter`, `DynExprVTable` (sealed trait),
144-
and `ExprVTable` (confusingly, the erased ref). Needs renaming to `ExprVTable`, `ExprInner`,
145-
`DynExpr`, `ExprRef`. Typed wrapper `Expr<V>` does not exist yet.
143+
Follows the convention with `ScalarFnVTable`, `ScalarFnPlugin`, `ScalarFnInner`, `DynScalarFn`,
144+
`ScalarFn<V>`, `ScalarFnRef`. File layout: `vtable.rs`, `plugin.rs`, `typed.rs`, `erased.rs`.
145+
Vtable types and reduce/execute adaptors live in `scalar_fn/fns/`.
146+
Factory functions (e.g. `root()`, `lit()`, `eq()`) live in `expr/exprs.rs`.
146147

147148
### Layout -- Not started
148149

encodings/alp/public-api.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,11 @@ impl vortex_array::arrays::slice::SliceKernel for vortex_alp::ALPRDVTable
160160

161161
pub fn vortex_alp::ALPRDVTable::slice(array: &Self::Array, range: core::ops::range::Range<usize>, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<vortex_array::array::ArrayRef>>
162162

163-
impl vortex_array::expr::exprs::cast::kernel::CastReduce for vortex_alp::ALPRDVTable
163+
impl vortex_array::scalar_fn::fns::cast::kernel::CastReduce for vortex_alp::ALPRDVTable
164164

165165
pub fn vortex_alp::ALPRDVTable::cast(array: &vortex_alp::ALPRDArray, dtype: &vortex_array::dtype::DType) -> vortex_error::VortexResult<core::option::Option<vortex_array::array::ArrayRef>>
166166

167-
impl vortex_array::expr::exprs::mask::kernel::MaskReduce for vortex_alp::ALPRDVTable
167+
impl vortex_array::scalar_fn::fns::mask::kernel::MaskReduce for vortex_alp::ALPRDVTable
168168

169169
pub fn vortex_alp::ALPRDVTable::mask(array: &vortex_alp::ALPRDArray, mask: &vortex_array::array::ArrayRef) -> vortex_error::VortexResult<core::option::Option<vortex_array::array::ArrayRef>>
170170

@@ -256,23 +256,23 @@ impl vortex_array::compute::nan_count::NaNCountKernel for vortex_alp::ALPVTable
256256

257257
pub fn vortex_alp::ALPVTable::nan_count(&self, array: &vortex_alp::ALPArray) -> vortex_error::VortexResult<usize>
258258

259-
impl vortex_array::expr::exprs::between::kernel::BetweenReduce for vortex_alp::ALPVTable
259+
impl vortex_array::scalar_fn::fns::between::kernel::BetweenReduce for vortex_alp::ALPVTable
260260

261-
pub fn vortex_alp::ALPVTable::between(array: &vortex_alp::ALPArray, lower: &dyn vortex_array::array::Array, upper: &dyn vortex_array::array::Array, options: &vortex_array::expr::exprs::between::BetweenOptions) -> vortex_error::VortexResult<core::option::Option<vortex_array::array::ArrayRef>>
261+
pub fn vortex_alp::ALPVTable::between(array: &vortex_alp::ALPArray, lower: &dyn vortex_array::array::Array, upper: &dyn vortex_array::array::Array, options: &vortex_array::scalar_fn::fns::between::BetweenOptions) -> vortex_error::VortexResult<core::option::Option<vortex_array::array::ArrayRef>>
262262

263-
impl vortex_array::expr::exprs::binary::compare::CompareKernel for vortex_alp::ALPVTable
263+
impl vortex_array::scalar_fn::fns::binary::compare::CompareKernel for vortex_alp::ALPVTable
264264

265-
pub fn vortex_alp::ALPVTable::compare(lhs: &vortex_alp::ALPArray, rhs: &dyn vortex_array::array::Array, operator: vortex_array::expr::exprs::operators::CompareOperator, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<vortex_array::array::ArrayRef>>
265+
pub fn vortex_alp::ALPVTable::compare(lhs: &vortex_alp::ALPArray, rhs: &dyn vortex_array::array::Array, operator: vortex_array::scalar_fn::fns::operators::CompareOperator, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<vortex_array::array::ArrayRef>>
266266

267-
impl vortex_array::expr::exprs::cast::kernel::CastReduce for vortex_alp::ALPVTable
267+
impl vortex_array::scalar_fn::fns::cast::kernel::CastReduce for vortex_alp::ALPVTable
268268

269269
pub fn vortex_alp::ALPVTable::cast(array: &vortex_alp::ALPArray, dtype: &vortex_array::dtype::DType) -> vortex_error::VortexResult<core::option::Option<vortex_array::array::ArrayRef>>
270270

271-
impl vortex_array::expr::exprs::mask::kernel::MaskKernel for vortex_alp::ALPVTable
271+
impl vortex_array::scalar_fn::fns::mask::kernel::MaskKernel for vortex_alp::ALPVTable
272272

273273
pub fn vortex_alp::ALPVTable::mask(array: &vortex_alp::ALPArray, mask: &vortex_array::array::ArrayRef, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<vortex_array::array::ArrayRef>>
274274

275-
impl vortex_array::expr::exprs::mask::kernel::MaskReduce for vortex_alp::ALPVTable
275+
impl vortex_array::scalar_fn::fns::mask::kernel::MaskReduce for vortex_alp::ALPVTable
276276

277277
pub fn vortex_alp::ALPVTable::mask(array: &vortex_alp::ALPArray, mask: &vortex_array::array::ArrayRef) -> vortex_error::VortexResult<core::option::Option<vortex_array::array::ArrayRef>>
278278

encodings/alp/src/alp/compute/between.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ use vortex_array::builtins::ArrayBuiltins;
1111
use vortex_array::dtype::NativeDType;
1212
use vortex_array::dtype::NativePType;
1313
use vortex_array::dtype::Nullability;
14-
use vortex_array::expr::BetweenOptions;
15-
use vortex_array::expr::BetweenReduce;
16-
use vortex_array::expr::StrictComparison;
1714
use vortex_array::scalar::Scalar;
15+
use vortex_array::scalar_fn::fns::between::BetweenOptions;
16+
use vortex_array::scalar_fn::fns::between::BetweenReduce;
17+
use vortex_array::scalar_fn::fns::between::StrictComparison;
1818
use vortex_error::VortexResult;
1919

2020
use crate::ALPArray;
@@ -98,8 +98,8 @@ mod tests {
9898
use vortex_array::arrays::PrimitiveArray;
9999
use vortex_array::assert_arrays_eq;
100100
use vortex_array::dtype::Nullability;
101-
use vortex_array::expr::BetweenOptions;
102-
use vortex_array::expr::StrictComparison;
101+
use vortex_array::scalar_fn::fns::between::BetweenOptions;
102+
use vortex_array::scalar_fn::fns::between::StrictComparison;
103103

104104
use crate::ALPArray;
105105
use crate::alp::compute::between::between_impl;

encodings/alp/src/alp/compute/cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use vortex_array::ArrayRef;
55
use vortex_array::IntoArray;
66
use vortex_array::builtins::ArrayBuiltins;
77
use vortex_array::dtype::DType;
8-
use vortex_array::expr::CastReduce;
98
use vortex_array::patches::Patches;
9+
use vortex_array::scalar_fn::fns::cast::CastReduce;
1010
use vortex_error::VortexResult;
1111

1212
use crate::alp::ALPArray;

encodings/alp/src/alp/compute/compare.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ use vortex_array::IntoArray;
1010
use vortex_array::arrays::ConstantArray;
1111
use vortex_array::builtins::ArrayBuiltins;
1212
use vortex_array::dtype::NativePType;
13-
use vortex_array::expr::CompareKernel;
14-
use vortex_array::expr::CompareOperator;
15-
use vortex_array::expr::Operator;
1613
use vortex_array::scalar::Scalar;
14+
use vortex_array::scalar_fn::fns::binary::CompareKernel;
15+
use vortex_array::scalar_fn::fns::operators::CompareOperator;
16+
use vortex_array::scalar_fn::fns::operators::Operator;
1717
use vortex_error::VortexResult;
1818
use vortex_error::vortex_bail;
1919
use vortex_error::vortex_err;
@@ -160,9 +160,9 @@ mod tests {
160160
use vortex_array::dtype::DType;
161161
use vortex_array::dtype::Nullability;
162162
use vortex_array::dtype::PType;
163-
use vortex_array::expr::CompareOperator;
164-
use vortex_array::expr::Operator;
165163
use vortex_array::scalar::Scalar;
164+
use vortex_array::scalar_fn::fns::operators::CompareOperator;
165+
use vortex_array::scalar_fn::fns::operators::Operator;
166166

167167
use super::*;
168168
use crate::alp_encode;

encodings/alp/src/alp/compute/mask.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
use vortex_array::ArrayRef;
55
use vortex_array::ExecutionCtx;
66
use vortex_array::builtins::ArrayBuiltins;
7-
use vortex_array::expr::MaskKernel;
8-
use vortex_array::expr::MaskReduce;
7+
use vortex_array::scalar_fn::fns::mask::MaskKernel;
8+
use vortex_array::scalar_fn::fns::mask::MaskReduce;
99
use vortex_array::validity::Validity;
1010
use vortex_error::VortexResult;
1111

encodings/alp/src/alp/rules.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
use vortex_array::arrays::FilterExecuteAdaptor;
55
use vortex_array::arrays::SliceExecuteAdaptor;
66
use vortex_array::arrays::TakeExecuteAdaptor;
7-
use vortex_array::expr::BetweenReduceAdaptor;
8-
use vortex_array::expr::CastReduceAdaptor;
9-
use vortex_array::expr::CompareExecuteAdaptor;
10-
use vortex_array::expr::MaskExecuteAdaptor;
11-
use vortex_array::expr::MaskReduceAdaptor;
127
use vortex_array::kernel::ParentKernelSet;
138
use vortex_array::optimizer::rules::ParentRuleSet;
9+
use vortex_array::scalar_fn::fns::between::BetweenReduceAdaptor;
10+
use vortex_array::scalar_fn::fns::binary::CompareExecuteAdaptor;
11+
use vortex_array::scalar_fn::fns::cast::CastReduceAdaptor;
12+
use vortex_array::scalar_fn::fns::mask::MaskExecuteAdaptor;
13+
use vortex_array::scalar_fn::fns::mask::MaskReduceAdaptor;
1414

1515
use crate::ALPVTable;
1616

encodings/alp/src/alp_rd/compute/cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use vortex_array::ArrayRef;
55
use vortex_array::IntoArray;
66
use vortex_array::builtins::ArrayBuiltins;
77
use vortex_array::dtype::DType;
8-
use vortex_array::expr::CastReduce;
8+
use vortex_array::scalar_fn::fns::cast::CastReduce;
99
use vortex_error::VortexResult;
1010

1111
use crate::alp_rd::ALPRDArray;

encodings/alp/src/alp_rd/compute/mask.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
use vortex_array::ArrayRef;
55
use vortex_array::IntoArray;
66
use vortex_array::arrays::ScalarFnArrayExt;
7-
use vortex_array::expr::EmptyOptions;
8-
use vortex_array::expr::Mask as MaskExpr;
9-
use vortex_array::expr::MaskReduce;
7+
use vortex_array::scalar_fn::EmptyOptions;
8+
use vortex_array::scalar_fn::fns::mask::Mask as MaskExpr;
9+
use vortex_array::scalar_fn::fns::mask::MaskReduce;
1010
use vortex_error::VortexResult;
1111

1212
use crate::ALPRDArray;

0 commit comments

Comments
 (0)