vortex_sequence/compute/
is_sorted.rs1use num_traits::zero;
5use vortex_array::compute::IsSortedKernel;
6use vortex_array::compute::IsSortedKernelAdapter;
7use vortex_array::register_kernel;
8use vortex_dtype::match_each_native_ptype;
9use vortex_error::VortexResult;
10
11use crate::SequenceArray;
12use crate::SequenceVTable;
13
14impl IsSortedKernel for SequenceVTable {
15 fn is_sorted(&self, array: &SequenceArray) -> VortexResult<Option<bool>> {
16 let m = array.multiplier();
17 match_each_native_ptype!(m.ptype(), |P| {
18 m.cast::<P>().map(|x| Some(x >= zero::<P>()))
19 })
20 }
21
22 fn is_strict_sorted(&self, array: &SequenceArray) -> VortexResult<Option<bool>> {
23 let m = array.multiplier();
24 match_each_native_ptype!(m.ptype(), |P| {
25 m.cast::<P>().map(|x| Some(x > zero::<P>()))
26 })
27 }
28}
29
30register_kernel!(IsSortedKernelAdapter(SequenceVTable).lift());