vortex_array/vtable/compute.rs
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use vortex_error::VortexResult;
5
6use crate::compute::{ComputeFn, InvocationArgs, Output};
7use crate::vtable::{NotSupported, VTable};
8
9pub trait ComputeVTable<V: VTable> {
10 /// Dynamically invokes the given compute function on the array.
11 ///
12 /// Returns `None` if the compute function is not supported by this array, otherwise attempts
13 /// to invoke the function.
14 ///
15 /// This can be useful to support compute functions based on some property of the function,
16 /// without knowing at compile-time what that function is. For example, any elementwise
17 /// function can be pushed-down over a dictionary array and evaluated only on the unique values.
18 fn invoke(
19 array: &V::Array,
20 compute_fn: &ComputeFn,
21 args: &InvocationArgs,
22 ) -> VortexResult<Option<Output>>;
23}
24
25impl<V: VTable> ComputeVTable<V> for NotSupported {
26 fn invoke(
27 _array: &V::Array,
28 _compute_fn: &ComputeFn,
29 _args: &InvocationArgs,
30 ) -> VortexResult<Option<Output>> {
31 Ok(None)
32 }
33}