vortex_array/arrays/list/compute/
mod.rs

1mod filter;
2mod mask;
3
4use vortex_error::VortexResult;
5
6use crate::arrays::{ListArray, ListVTable};
7use crate::compute::{
8    IsConstantKernel, IsConstantKernelAdapter, IsConstantOpts, IsSortedKernel,
9    IsSortedKernelAdapter, MinMaxKernel, MinMaxKernelAdapter, MinMaxResult,
10};
11use crate::register_kernel;
12
13impl IsConstantKernel for ListVTable {
14    fn is_constant(
15        &self,
16        _array: &ListArray,
17        _opts: &IsConstantOpts,
18    ) -> VortexResult<Option<bool>> {
19        // TODO(adam): Do we want to fallback to arrow here?
20        Ok(None)
21    }
22}
23
24register_kernel!(IsConstantKernelAdapter(ListVTable).lift());
25
26impl MinMaxKernel for ListVTable {
27    fn min_max(&self, _array: &ListArray) -> VortexResult<Option<MinMaxResult>> {
28        // TODO(joe): Implement list min max
29        Ok(None)
30    }
31}
32
33register_kernel!(MinMaxKernelAdapter(ListVTable).lift());
34
35// TODO(ngates): why do we report the wrong thing?
36impl IsSortedKernel for ListVTable {
37    fn is_sorted(&self, _array: &ListArray) -> VortexResult<bool> {
38        Ok(false)
39    }
40
41    fn is_strict_sorted(&self, _array: &ListArray) -> VortexResult<bool> {
42        Ok(false)
43    }
44}
45
46register_kernel!(IsSortedKernelAdapter(ListVTable).lift());
47
48#[cfg(test)]
49mod test {
50    use crate::IntoArray;
51    use crate::arrays::{ListArray, PrimitiveArray};
52    use crate::compute::conformance::mask::test_mask;
53    use crate::validity::Validity;
54
55    #[test]
56    fn test_mask_list() {
57        let elements = PrimitiveArray::from_iter(0..35);
58        let offsets = PrimitiveArray::from_iter([0, 5, 11, 18, 26, 35]);
59        let validity = Validity::AllValid;
60        let array =
61            ListArray::try_new(elements.into_array(), offsets.into_array(), validity).unwrap();
62
63        test_mask(array.as_ref());
64    }
65}