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