This is an automated email from the ASF dual-hosted git repository.
Jefffrey pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 4f96226d80 fix(parquet): restore opaque return type for
`RowSelection::iter` (#10450)
4f96226d80 is described below
commit 4f96226d80788cb9c0ba417b054b7902a9c0a742
Author: Huaijin <[email protected]>
AuthorDate: Tue Jul 28 19:17:34 2026 +0800
fix(parquet): restore opaque return type for `RowSelection::iter` (#10450)
# Which issue does this PR close?
- Follow-on to #10141, addressing
https://github.com/apache/arrow-rs/pull/10141#issuecomment-5100991012
# Rationale for this change
#10141 changed `RowSelection::iter` from `impl Iterator<Item =
&RowSelector>` to a named type, `RowSelectionIter<'_>`. As @Jefffrey
pointed out, the opaque return type is worth keeping so we stay free to
change the implementation later.
# What changes are included in this PR?
`RowSelection::iter` returns `impl Iterator<Item = &RowSelector>` again.
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.
# Are these changes tested?
Covered by the existing `RowSelection` tests, which call `iter()` on
both backings. `cargo test -p parquet --all-features` passes.
# Are there any user-facing changes?
No. `RowSelectionIter` was added in #10141 and never released, and
`iter()` keeps the `Iterator<Item = &RowSelector>` contract callers
already relied on.
---
parquet/src/arrow/arrow_reader/mod.rs | 3 +-
parquet/src/arrow/arrow_reader/selection/mod.rs | 11 +++--
.../src/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 a9cd82b3a3..e4a7b3d135 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 b8a5bc0f2a..41a59c048e 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<RowSelector>` 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<Item = &RowSelector> {
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 15261a5c7a..a7ba939ae4 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::Item> {
- self.0.next()
- }
-
- #[inline]
- fn size_hint(&self) -> (usize, Option<usize>) {
- self.0.size_hint()
- }
-
- #[inline]
- fn count(self) -> usize {
- self.0.count()
- }
-
- #[inline]
- fn nth(&mut self, n: usize) -> Option<Self::Item> {
- self.0.nth(n)
- }
-
- #[inline]
- fn last(self) -> Option<Self::Item> {
- self.0.last()
- }
-
- #[inline]
- fn fold<B, F>(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<RowSelector>,