Skip to main content

vortex_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::scalar::Scalar;
9use crate::vtable::NotSupported;
10use crate::vtable::VTable;
11
12pub trait OperationsVTable<V: VTable> {
13    /// Fetch the scalar at the given index.
14    ///
15    /// ## Preconditions
16    ///
17    /// Bounds-checking has already been performed by the time this function is called,
18    /// and the index is guaranteed to be non-null.
19    fn scalar_at(array: &V::Array, index: usize, ctx: &mut ExecutionCtx) -> VortexResult<Scalar>;
20}
21
22impl<V: VTable> OperationsVTable<V> for NotSupported {
23    fn scalar_at(array: &V::Array, _index: usize, _ctx: &mut ExecutionCtx) -> VortexResult<Scalar> {
24        vortex_bail!(
25            "Legacy scalar_at operation is not supported for {} arrays",
26            array.encoding_id()
27        )
28    }
29}