This is an automated email from the ASF dual-hosted git repository.
tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/master by this push:
new 7c8080c67 Trim parquet row selection (#2705)
7c8080c67 is described below
commit 7c8080c6752a55256630f6f6e6c82bf8a540d20b
Author: Raphael Taylor-Davies <[email protected]>
AuthorDate: Sat Sep 24 17:20:49 2022 +0100
Trim parquet row selection (#2705)
---
parquet/src/arrow/arrow_reader/mod.rs | 2 +-
parquet/src/arrow/arrow_reader/selection.rs | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/parquet/src/arrow/arrow_reader/mod.rs
b/parquet/src/arrow/arrow_reader/mod.rs
index b00afc475..59abf9ad8 100644
--- a/parquet/src/arrow/arrow_reader/mod.rs
+++ b/parquet/src/arrow/arrow_reader/mod.rs
@@ -570,7 +570,7 @@ impl ParquetRecordBatchReader {
batch_size,
array_reader,
schema: Arc::new(schema),
- selection: selection.map(Into::into),
+ selection: selection.map(|s| s.trim().into()),
}
}
}
diff --git a/parquet/src/arrow/arrow_reader/selection.rs
b/parquet/src/arrow/arrow_reader/selection.rs
index 495e346e0..6a965dc9b 100644
--- a/parquet/src/arrow/arrow_reader/selection.rs
+++ b/parquet/src/arrow/arrow_reader/selection.rs
@@ -285,6 +285,14 @@ impl RowSelection {
pub fn selects_any(&self) -> bool {
self.selectors.iter().any(|x| !x.skip)
}
+
+ /// Trims this [`RowSelection`] removing any trailing skips
+ pub(crate) fn trim(mut self) -> Self {
+ while self.selectors.last().map(|x| x.skip).unwrap_or(false) {
+ self.selectors.pop();
+ }
+ self
+ }
}
impl From<Vec<RowSelector>> for RowSelection {