From 91657995845049859e3196378a1ec5b718c4e7de Mon Sep 17 00:00:00 2001 From: kamille Date: Thu, 31 Oct 2024 02:11:53 +0800 Subject: [PATCH] use zip to simplify codes. --- .../aggregates/group_values/group_column.rs | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/datafusion/physical-plan/src/aggregates/group_values/group_column.rs b/datafusion/physical-plan/src/aggregates/group_values/group_column.rs index 31ca3ebbb89e0..8ac59d88a97b0 100644 --- a/datafusion/physical-plan/src/aggregates/group_values/group_column.rs +++ b/datafusion/physical-plan/src/aggregates/group_values/group_column.rs @@ -169,6 +169,7 @@ impl GroupColumn .iter() .zip(rhs_rows.iter()) .zip(equal_to_results.iter_mut()); + for ((&lhs_row, &rhs_row), equal_to_result) in iter { // Has found not equal to, don't need to check if !*equal_to_result { @@ -344,14 +345,18 @@ where { let array = array.as_bytes::(); - for (idx, &lhs_row) in lhs_rows.iter().enumerate() { + let iter = lhs_rows + .iter() + .zip(rhs_rows.iter()) + .zip(equal_to_results.iter_mut()); + + for ((&lhs_row, &rhs_row), equal_to_result) in iter { // Has found not equal to, don't need to check - if !equal_to_results[idx] { + if !*equal_to_results[idx] { continue; } - let rhs_row = rhs_rows[idx]; - equal_to_results[idx] = self.do_equal_to_inner(lhs_row, array, rhs_row); + *equal_to_results = self.do_equal_to_inner(lhs_row, array, rhs_row); } } @@ -729,14 +734,18 @@ impl ByteViewGroupValueBuilder { ) { let array = array.as_byte_view::(); - for (idx, &lhs_row) in group_indices.iter().enumerate() { + let iter = lhs_rows + .iter() + .zip(rhs_rows.iter()) + .zip(equal_to_results.iter_mut()); + + for ((&lhs_row, &rhs_row), equal_to_result) in iter { // Has found not equal to, don't need to check - if !equal_to_results[idx] { + if !*equal_to_results { continue; } - let rhs_row = rows[idx]; - equal_to_results[idx] = self.do_equal_to_inner(lhs_row, array, rhs_row); + *equal_to_results = self.do_equal_to_inner(lhs_row, array, rhs_row); } }