From dffcd237c32aae6b2ac6ec7d934c1b838a5bd0b8 Mon Sep 17 00:00:00 2001 From: Huaijin Date: Tue, 28 Jul 2026 17:18:39 +0800 Subject: [PATCH] fix(parquet): restore opaque return type for `RowSelection::iter` #10141 changed `RowSelection::iter` from `impl Iterator` to a named type, `RowSelectionIter<'_>`. Restore the opaque return type so we stay free to change the implementation later. Both match arms are already `std::slice::Iter<'_, RowSelector>`, so `RowSelectionIter` is not needed at all and is removed rather than made private. No behaviour change. --- parquet/src/arrow/arrow_reader/mod.rs | 3 +- .../src/arrow/arrow_reader/selection/mod.rs | 11 ++-- .../arrow/arrow_reader/selection/selector.rs | 53 ------------------- 3 files changed, 7 insertions(+), 60 deletions(-) diff --git a/parquet/src/arrow/arrow_reader/mod.rs b/parquet/src/arrow/arrow_reader/mod.rs index a9cd82b3a3de..e4a7b3d135f5 100644 --- a/parquet/src/arrow/arrow_reader/mod.rs +++ b/parquet/src/arrow/arrow_reader/mod.rs @@ -25,8 +25,7 @@ use arrow_select::filter::filter_record_batch; pub use filter::{ArrowPredicate, ArrowPredicateFn, RowFilter}; use selection::MaskCursor; pub use selection::{ - MaskRunIter, RowSelection, RowSelectionCursor, RowSelectionIter, RowSelectionPolicy, - RowSelector, + MaskRunIter, RowSelection, RowSelectionCursor, RowSelectionPolicy, RowSelector, }; use std::fmt::{Debug, Formatter}; use std::sync::Arc; diff --git a/parquet/src/arrow/arrow_reader/selection/mod.rs b/parquet/src/arrow/arrow_reader/selection/mod.rs index b8a5bc0f2a74..41a59c048e2b 100644 --- a/parquet/src/arrow/arrow_reader/selection/mod.rs +++ b/parquet/src/arrow/arrow_reader/selection/mod.rs @@ -55,7 +55,7 @@ use boolean::{ pub(crate) use cursor::{LoadedRowRanges, MaskCursor, RowSelectionStrategy}; pub use cursor::{RowSelectionCursor, RowSelectionPolicy}; use ranges::{expand_to_batch_boundaries_from_selectors, scan_ranges_from_selectors}; -pub use selector::{RowSelectionIter, RowSelector}; +pub use selector::RowSelector; use selector::{limit_selectors, offset_selectors, split_off_selectors}; /// [`RowSelection`] represents selecting a subset of rows @@ -605,7 +605,8 @@ impl RowSelection { } } - /// Returns a borrowed iterator yielding the [`RowSelector`]s for this selection. + /// Returns an iterator over the [`RowSelector`]s for this + /// [`RowSelection`]. /// /// Mask-backed selections materialize a `Vec` cache on first /// call (one allocation, `O(set_slices)` work) so the iterator can hand out @@ -613,10 +614,10 @@ impl RowSelection { /// over mask-backed selections, prefer streaming directly via /// [`Self::as_mask`] + [`MaskRunIter::new`] — that path is allocation-free /// and avoids populating the cache. - pub fn iter(&self) -> RowSelectionIter<'_> { + pub fn iter(&self) -> impl Iterator { match &self.inner { - RowSelectionInner::Selectors(s) => RowSelectionIter::new(s), - RowSelectionInner::Mask(m) => RowSelectionIter::new(m.selectors()), + RowSelectionInner::Selectors(s) => s.iter(), + RowSelectionInner::Mask(m) => m.selectors().iter(), } } diff --git a/parquet/src/arrow/arrow_reader/selection/selector.rs b/parquet/src/arrow/arrow_reader/selection/selector.rs index 15261a5c7a89..a7ba939ae49a 100644 --- a/parquet/src/arrow/arrow_reader/selection/selector.rs +++ b/parquet/src/arrow/arrow_reader/selection/selector.rs @@ -55,59 +55,6 @@ impl RowSelector { } } -/// Borrowed iterator over the [`RowSelector`]s of a -/// [`RowSelection`](crate::arrow::arrow_reader::RowSelection). -#[derive(Debug)] -pub struct RowSelectionIter<'a>(std::slice::Iter<'a, RowSelector>); - -impl<'a> RowSelectionIter<'a> { - pub(super) fn new(selectors: &'a [RowSelector]) -> Self { - Self(selectors.iter()) - } -} - -impl<'a> Iterator for RowSelectionIter<'a> { - type Item = &'a RowSelector; - - #[inline] - fn next(&mut self) -> Option { - self.0.next() - } - - #[inline] - fn size_hint(&self) -> (usize, Option) { - self.0.size_hint() - } - - #[inline] - fn count(self) -> usize { - self.0.count() - } - - #[inline] - fn nth(&mut self, n: usize) -> Option { - self.0.nth(n) - } - - #[inline] - fn last(self) -> Option { - self.0.last() - } - - #[inline] - fn fold(self, init: B, f: F) -> B - where - F: FnMut(B, Self::Item) -> B, - { - self.0.fold(init, f) - } -} - -impl ExactSizeIterator for RowSelectionIter<'_> {} - -// once it returns None, it will continue returning None -impl std::iter::FusedIterator for RowSelectionIter<'_> {} - /// Splits `selectors` at the first `row_count` rows, returning `(head, tail)`. pub(super) fn split_off_selectors( mut selectors: Vec,