vortex_runend/compute/
is_constant.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use vortex_array::Array;
5use vortex_array::compute::IsConstantKernel;
6use vortex_array::compute::IsConstantKernelAdapter;
7use vortex_array::compute::IsConstantOpts;
8use vortex_array::compute::is_constant_opts;
9use vortex_array::expr::stats::Stat;
10use vortex_array::register_kernel;
11use vortex_error::VortexResult;
12
13use crate::RunEndVTable;
14
15impl IsConstantKernel for RunEndVTable {
16    fn is_constant(
17        &self,
18        array: &Self::Array,
19        opts: &IsConstantOpts,
20    ) -> VortexResult<Option<bool>> {
21        // If there are known to be me 0 len runs then we can check if constant on the values.
22        debug_assert_eq!(
23            array
24                .ends()
25                .statistics()
26                .compute_as::<bool>(Stat::IsStrictSorted),
27            Some(true)
28        );
29        is_constant_opts(array.values(), opts)
30    }
31}
32
33register_kernel!(IsConstantKernelAdapter(RunEndVTable).lift());