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