1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use vortex_error::VortexResult;

use crate::array::varbin::VarBinArray;
use crate::array::VarBinEncoding;
use crate::compute::{slice, SliceFn};
use crate::{ArrayDType, ArrayData, IntoArrayData};

impl SliceFn<VarBinArray> for VarBinEncoding {
    fn slice(&self, array: &VarBinArray, start: usize, stop: usize) -> VortexResult<ArrayData> {
        VarBinArray::try_new(
            slice(array.offsets(), start, stop + 1)?,
            array.bytes(),
            array.dtype().clone(),
            array.validity().slice(start, stop)?,
        )
        .map(|a| a.into_array())
    }
}