File tree Expand file tree Collapse file tree
vortex-array/src/aggregate_fn/fns/is_constant Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: Apache-2.0
2+ // SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+ use vortex_error:: VortexResult ;
5+
6+ use super :: is_constant;
7+ use crate :: ExecutionCtx ;
8+ use crate :: arrays:: ExtensionArray ;
9+
10+ /// Check if an extension array is constant by delegating to its storage array.
11+ pub ( super ) fn check_extension_constant (
12+ e : & ExtensionArray ,
13+ ctx : & mut ExecutionCtx ,
14+ ) -> VortexResult < bool > {
15+ is_constant ( e. storage_array ( ) , ctx)
16+ }
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: Apache-2.0
2+ // SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+ use vortex_error:: VortexResult ;
5+
6+ use super :: arrays_value_equal;
7+ use crate :: ExecutionCtx ;
8+ use crate :: arrays:: FixedSizeListArray ;
9+
10+ /// Check if a fixed-size list array is constant by comparing each list's elements.
11+ ///
12+ /// Uses `binary(Operator::Eq)` for element-wise value comparison with null-safe equality.
13+ pub ( super ) fn check_fixed_size_list_constant (
14+ f : & FixedSizeListArray ,
15+ ctx : & mut ExecutionCtx ,
16+ ) -> VortexResult < bool > {
17+ if f. len ( ) <= 1 {
18+ return Ok ( true ) ;
19+ }
20+
21+ let first_elements = f. fixed_size_list_elements_at ( 0 ) ?;
22+ for i in 1 ..f. len ( ) {
23+ let current_elements = f. fixed_size_list_elements_at ( i) ?;
24+ if !arrays_value_equal ( & first_elements, & current_elements, ctx) ? {
25+ return Ok ( false ) ;
26+ }
27+ }
28+
29+ Ok ( true )
30+ }
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: Apache-2.0
2+ // SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+ use vortex_error:: VortexResult ;
5+
6+ use super :: arrays_value_equal;
7+ use crate :: ExecutionCtx ;
8+ use crate :: arrays:: ListViewArray ;
9+
10+ /// Check if a list view array is constant by comparing each list's elements.
11+ ///
12+ /// A list view array is constant if all lists have the same size and the same elements.
13+ /// Uses `binary(Operator::Eq)` for element-wise value comparison with null-safe equality.
14+ pub ( super ) fn check_listview_constant (
15+ l : & ListViewArray ,
16+ ctx : & mut ExecutionCtx ,
17+ ) -> VortexResult < bool > {
18+ if l. len ( ) <= 1 {
19+ return Ok ( true ) ;
20+ }
21+
22+ let first_size = l. size_at ( 0 ) ;
23+ let first_elements = l. list_elements_at ( 0 ) ?;
24+
25+ for i in 1 ..l. len ( ) {
26+ if l. size_at ( i) != first_size {
27+ return Ok ( false ) ;
28+ }
29+ if first_size == 0 {
30+ continue ;
31+ }
32+ let current_elements = l. list_elements_at ( i) ?;
33+ if !arrays_value_equal ( & first_elements, & current_elements, ctx) ? {
34+ return Ok ( false ) ;
35+ }
36+ }
37+
38+ Ok ( true )
39+ }
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: Apache-2.0
2+ // SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+ use vortex_error:: VortexResult ;
5+
6+ use super :: is_constant;
7+ use crate :: ExecutionCtx ;
8+ use crate :: arrays:: StructArray ;
9+
10+ /// Check if a struct array is constant by checking each field independently.
11+ pub ( super ) fn check_struct_constant ( s : & StructArray , ctx : & mut ExecutionCtx ) -> VortexResult < bool > {
12+ for field in s. unmasked_fields ( ) . iter ( ) {
13+ if !is_constant ( field, ctx) ? {
14+ return Ok ( false ) ;
15+ }
16+ }
17+ Ok ( true )
18+ }
You can’t perform that action at this time.
0 commit comments