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