1use std::ops::Range;
5
6use vortex_array::ArrayRef;
7use vortex_array::IntoArray;
8use vortex_array::arrays::SliceReduce;
9use vortex_array::arrays::VarBinVTable;
10use vortex_error::VortexResult;
11use vortex_error::vortex_err;
12
13use crate::FSSTArray;
14use crate::FSSTVTable;
15
16impl SliceReduce for FSSTVTable {
17 fn slice(array: &Self::Array, range: Range<usize>) -> VortexResult<Option<ArrayRef>> {
18 Ok(Some(
20 unsafe {
21 FSSTArray::new_unchecked(
22 array.dtype().clone(),
23 array.symbols().clone(),
24 array.symbol_lengths().clone(),
25 VarBinVTable::_slice(array.codes().as_::<VarBinVTable>(), range.clone())?
26 .try_into::<VarBinVTable>()
27 .map_err(|_| vortex_err!("cannot fail conversion"))?,
28 array.uncompressed_lengths().slice(range)?,
29 )
30 }
31 .into_array(),
32 ))
33 }
34}