Skip to main content

vortex_array/scalar_fn/
mod.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4//! Scalar function vtable machinery.
5//!
6//! This module contains the [`ScalarFnVTable`] trait, the machinery to bind, reduce and execute
7//! scalar functions, and in [`builtin`] the few functions vortex-array itself is built on. Other scalar
8//! functions live in the `vortex-functions` crate. Expressions (`vortex_expr::Expression`)
9//! reference scalar functions at each node.
10//!
11//! Strict functions with row-at-a-time kernels can implement `unstable::row::RowFn`. It handles
12//! decoding, constants, null propagation, output construction, and validity. This API requires the
13//! `unstable_row_fns` feature and has no compatibility guarantees. Implement [`ScalarFnVTable`]
14//! directly for columnar kernels and functions that alias an input or can produce null from valid
15//! inputs.
16
17use vortex_session::registry::Id;
18
19pub mod display;
20
21mod vtable;
22pub use vtable::*;
23
24mod plugin;
25pub use plugin::*;
26
27mod typed;
28pub use typed::*;
29
30mod erased;
31pub use erased::*;
32
33mod options;
34pub use options::*;
35
36mod signature;
37pub use signature::*;
38
39#[cfg(feature = "unstable_row_fns")]
40pub mod unstable;
41#[cfg(not(feature = "unstable_row_fns"))]
42#[allow(dead_code, unused_imports)]
43pub(crate) mod unstable;
44
45pub mod builtin;
46pub mod session;
47
48/// A unique identifier for a scalar function.
49pub type ScalarFnId = Id;
50
51/// Private module to seal [`typed::DynScalarFn`].
52mod sealed {
53    use crate::scalar_fn::ScalarFnVTable;
54    use crate::scalar_fn::typed::TypedScalarFnInstance;
55
56    /// Marker trait to prevent external implementations of [`super::typed::DynScalarFn`].
57    pub(crate) trait Sealed {}
58
59    /// This can be the **only** implementor for [`super::typed::DynScalarFn`].
60    impl<V: ScalarFnVTable> Sealed for TypedScalarFnInstance<V> {}
61}