Skip to main content

vortex_array/array/vtable/
operations.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use vortex_error::VortexResult;
5use vortex_error::vortex_bail;
6
7use crate::ExecutionCtx;
8use crate::array::ArrayView;
9use crate::array::VTable;
10use crate::scalar::Scalar;
11use crate::vtable::NotSupported;
12
13pub trait OperationsVTable<V: VTable> {
14    /// Fetch the scalar at the given index.
15    ///
16    /// ## Preconditions
17    ///
18    /// Bounds-checking has already been performed by the time this function is called,
19    /// and the index is guaranteed to be non-null.
20    fn scalar_at(
21        array: ArrayView<'_, V>,
22        index: usize,
23        ctx: &mut ExecutionCtx,
24    ) -> VortexResult<Scalar>;
25}
26
27impl<V: VTable> OperationsVTable<V> for NotSupported {
28    fn scalar_at(
29        array: ArrayView<'_, V>,
30        _index: usize,
31        _ctx: &mut ExecutionCtx,
32    ) -> VortexResult<Scalar> {
33        vortex_bail!(
34            "Legacy scalar_at operation is not supported for {} arrays",
35            array.encoding_id()
36        )
37    }
38}