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