This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch 
gh-readonly-queue/main/pr-11687-0e4a50115584adee2852e33eadb68d0a0ccd4094
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git

commit 513c92d5f12cbef5da09e30c144f2dcf857cdf91
Author: Huaijin <[email protected]>
AuthorDate: Tue Oct 27 01:32:48 2026 +0000

    refactor(parquet): simplify row selection normalization and page scanning 
(#11687)
    
    # Which issue does this PR close?
    
    <!--
    It is not necessary to raise an issue, but it is encouraged if it is a
    non-trivial
    enhancement/bug.
    
    If this PR relates to an existing issue, but does not fully resolve it,
    please change
    the wording below from "Closes #NNN" to "Relates to #NNN" or "Part of
    #NNN" to avoid
    false closing an issue.
    -->
    
    
    
    - Closes #NNN
    
    # Rationale for this change
    
    <!--
    Why are you proposing this change? If this is already explained clearly
    in the
    issue then this section is not needed. Explaining clearly why changes
    are proposed
    helps reviewers understand your changes and offer better suggestions for
    fixes.
    
    Please try to explain the problem you are trying to solve in terms of
    the user-visible
    behavior, rather than the implementation.
    -->
    Row selection construction duplicates existing normalization logic,
    while page-range scanning contains a redundant final-page check. Reusing
    the existing helper and removing unreachable code simplifies both paths.
    
    
    # What changes are included in this PR?
    
    <!--
    There is no need to duplicate the description in the issue here but it
    is
    sometimes worth providing a summary of the individual changes in this
    PR.
    -->
    - Reuse `append_normalized_selector` in `FromIterator<RowSelector>`,
    preserving zero-length filtering and checked merging of adjacent
    selectors.
    - Remove the unreachable page-append block in
    `scan_ranges_from_selectors`. The current page has already been handled
    at the beginning of the loop.
    
    # Are these changes tested?
    
    <!--
    We typically require tests for all PRs in order to:
    1. Prevent the code from being accidentally broken by subsequent changes
    2. Serve as another way to document the expected behavior of the code
    
    If tests are not included in your PR, please explain why (for example,
    are they
    covered by existing tests, if so identify these tests)?
    
    If this PR claims a performance improvement, please include evidence
    such as
    benchmark results.
    
    DO NOT simply paste a list of commands ran to verify the code; this is
    what our
    CI is for and it pollutes the PR. ONLY explain if testing was included
    with this
    PR, or why it wasn't.
    -->
    
    # Are there any significant user-facing changes?
    
    <!--
    Significant user-facing changes include:
    - Breaking public API change
    - Significant change to existing functionality (e.g. function returns
    something different)
    
    These need to be explicitly called out to ensure we have proper
    documentation if
    required and to ensure we follow proper semantic versioning.
    
    DO NOT restate the changes of this PR; if a bug was fixed and already
    explained
    above, we don't need this to be restated as a user-facing change.
    -->
---
 parquet/src/arrow/arrow_reader/selection/mod.rs    | 20 ++------------------
 parquet/src/arrow/arrow_reader/selection/ranges.rs |  5 -----
 2 files changed, 2 insertions(+), 23 deletions(-)

diff --git a/parquet/src/arrow/arrow_reader/selection/mod.rs 
b/parquet/src/arrow/arrow_reader/selection/mod.rs
index bd1fe2b913..a54d06863f 100644
--- a/parquet/src/arrow/arrow_reader/selection/mod.rs
+++ b/parquet/src/arrow/arrow_reader/selection/mod.rs
@@ -852,26 +852,10 @@ impl FromIterator<RowSelector> for RowSelection {
     fn from_iter<T: IntoIterator<Item = RowSelector>>(iter: T) -> Self {
         let iter = iter.into_iter();
 
-        // Capacity before filter
         let mut selectors = Vec::with_capacity(iter.size_hint().0);
 
-        let mut filtered = iter.filter(|x| x.row_count != 0);
-        if let Some(x) = filtered.next() {
-            selectors.push(x);
-        }
-
-        for s in filtered {
-            if s.row_count == 0 {
-                continue;
-            }
-
-            // Combine consecutive selectors
-            let last = selectors.last_mut().unwrap();
-            if last.skip == s.skip {
-                last.row_count = 
last.row_count.checked_add(s.row_count).unwrap();
-            } else {
-                selectors.push(s)
-            }
+        for selector in iter {
+            append_normalized_selector(&mut selectors, selector);
         }
 
         Self::from_selectors(selectors)
diff --git a/parquet/src/arrow/arrow_reader/selection/ranges.rs 
b/parquet/src/arrow/arrow_reader/selection/ranges.rs
index 9fa65c3b9d..1069398601 100644
--- a/parquet/src/arrow/arrow_reader/selection/ranges.rs
+++ b/parquet/src/arrow/arrow_reader/selection/ranges.rs
@@ -103,11 +103,6 @@ where
                 current_selector = selectors.next();
             }
         } else {
-            if !(selector.skip || current_page_included) {
-                let start = page.offset as u64;
-                let end = start + page.compressed_page_size as u64;
-                ranges.push(start..end);
-            }
             current_selector = selectors.next()
         }
     }

Reply via email to