vortex_array/arrays/struct_/compute/
is_constant.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use vortex_error::VortexResult;
5
6use crate::arrays::{StructArray, StructVTable};
7use crate::compute::{self, IsConstantKernel, IsConstantKernelAdapter, IsConstantOpts};
8use crate::register_kernel;
9
10impl IsConstantKernel for StructVTable {
11    fn is_constant(
12        &self,
13        array: &StructArray,
14        opts: &IsConstantOpts,
15    ) -> VortexResult<Option<bool>> {
16        let children = array.children();
17        if children.is_empty() {
18            return Ok(Some(true));
19        }
20
21        for child in children.iter() {
22            match compute::is_constant_opts(child, opts)? {
23                // Un-determined
24                None => return Ok(None),
25                Some(false) => return Ok(Some(false)),
26                Some(true) => {}
27            }
28        }
29
30        Ok(Some(true))
31    }
32}
33
34register_kernel!(IsConstantKernelAdapter(StructVTable).lift());