vortex_runend/compute/
is_constant.rs

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