vortex_array/vtable/operations.rs
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use vortex_scalar::Scalar;
5
6use crate::ArrayRef;
7use crate::vtable::VTable;
8
9pub trait OperationsVTable<V: VTable> {
10 /// Perform a constant-time slice of the array.
11 ///
12 /// If an encoding cannot perform this slice in constant time, it should internally
13 /// store an offset and length in order to defer slicing until the array is accessed.
14 ///
15 /// This function returns [`ArrayRef`] since some encodings can return a simpler array for
16 /// some slices, for example a [`crate::arrays::ChunkedArray`] may slice into a single chunk.
17 ///
18 /// ## Preconditions
19 ///
20 /// Bounds-checking has already been performed by the time this function is called.
21 fn slice(array: &V::Array, start: usize, stop: usize) -> ArrayRef;
22
23 /// Fetch the scalar at the given index.
24 ///
25 /// ## Preconditions
26 ///
27 /// Bounds-checking has already been performed by the time this function is called,
28 /// and the index is guaranteed to be non-null.
29 fn scalar_at(array: &V::Array, index: usize) -> Scalar;
30}