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