mcshawn10 commented on code in PR #45384:
URL: https://github.com/apache/arrow/pull/45384#discussion_r1941491449
##########
cpp/src/arrow/compare.cc:
##########
@@ -381,23 +381,49 @@ class RangeDataEqualsImpl {
const int8_t* right_codes = right_.GetValues<int8_t>(1);
// Unions don't have a null bitmap
+ int64_t run_start = 0; // Start index of the current run
+
for (int64_t i = 0; i < range_length_; ++i) {
- const auto type_id = left_codes[left_start_idx_ + i];
- if (type_id != right_codes[right_start_idx_ + i]) {
+ const auto current_type_id = left_codes[left_start_idx_ + i];
+
+ if (current_type_id != right_codes[right_start_idx_ + i]) {
result_ = false;
break;
}
- const auto child_num = child_ids[type_id];
- // XXX can we instead detect runs of same-child union values?
- RangeDataEqualsImpl impl(
- options_, floating_approximate_, *left_.child_data[child_num],
- *right_.child_data[child_num], left_start_idx_ + left_.offset + i,
- right_start_idx_ + right_.offset + i, 1);
- if (!impl.Compare()) {
- result_ = false;
- break;
+ // Check if the current element breaks the run
+ if (i > 0 && current_type_id != left_codes[left_start_idx_ + i - 1]) {
+ // Compare the previous run
+ const auto previous_child_num = child_ids[left_codes[left_start_idx_ +
i - 1]];
+ int64_t run_length = i - run_start;
+
+ RangeDataEqualsImpl impl(
+ options_, floating_approximate_,
*left_.child_data[previous_child_num],
+ *right_.child_data[previous_child_num],
+ left_start_idx_ + left_.offset + run_start,
+ right_start_idx_ + right_.offset + run_start, run_length);
+
+ if (!impl.Compare()) {
+ result_ = false;
+ return Status::OK();
Review Comment:
thank you for the feedback! just implemented the suggestions
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]