SteNicholas commented on code in PR #1469:
URL: https://github.com/apache/paimon-rust/pull/1469#discussion_r4675364693


##########
crates/paimon/src/arrow/format/parquet.rs:
##########
@@ -88,9 +130,110 @@ impl ParquetFormatReader {
             page_index_enabled: 
core_options.parquet_filter_column_index_enabled()?,
             // Format-table files may be replaced in place.
             metadata_cache_enabled: !core_options.is_format_table(),
+            merged_metadata: None,
+        })
+    }
+
+    pub(crate) fn with_merged_read_metadata(mut self, metadata: 
MergedReadMetadata) -> Self {
+        self.merged_metadata = Some(metadata);
+        self
+    }
+
+    fn reader_options(&self, has_predicate: bool, has_selection: bool) -> 
ArrowReaderOptions {
+        let mut options = ArrowReaderOptions::new();
+        if self.page_index_enabled {
+            if has_predicate {
+                options = 
options.with_column_index_policy(PageIndexPolicy::Optional);
+            }
+            if has_predicate || has_selection {
+                options = 
options.with_offset_index_policy(PageIndexPolicy::Optional);
+            }
+        }
+        options
+    }
+
+    pub(crate) async fn load_merged_read_metadata(
+        &self,
+        reader: Box<dyn FileRead>,
+        file_size: u64,
+        selected_filter: Option<SelectedRowsFilter<'_>>,
+    ) -> parquet::errors::Result<MergedReadMetadata> {
+        let mut reader = ArrowFileReader::new(file_size, reader.into())
+            .with_metadata_cache_enabled(self.metadata_cache_enabled);
+        let mut fetch = ParquetMetadataFetch::new(&mut reader);
+        let row_group_match = match selected_filter.as_ref().filter(|_| 
self.page_index_enabled) {
+            Some(filter) => 
selected_row_group_match(fetch.load(None).await?.as_ref(), filter),
+            None => RowGroupMatch::Unknown,
+        };
+        let options = self.reader_options(
+            row_group_match == RowGroupMatch::Unknown,

Review Comment:
   A single selected row now takes the offset-only path when the row-group 
footer is inconclusive. The merged residual checks the row after decoding. The 
footer can still reject the point before any data pages are read. [Commit 
`942195a3`](https://github.com/apache/paimon-rust/pull/1469/commits/942195a3c8912d726ba79b10cd22b6ec1fac160f)
   
   The regression selects `_ROW_ID = 102117` in the 100,000-row fixture with a 
49-column rating provider and 64 rows per page. It returns `(id=2117, 
_ROW_ID=102117)` for `rating >= 2117` and no rows for `rating >= 2118`. Both 
predicates read the same data-page bytes and total cold bytes with pushdown on 
and off. [Counting-I/O 
regression](https://github.com/SteNicholas/paimon-rust/blob/942195a3c8912d726ba79b10cd22b6ec1fac160f/crates/paimon/src/table/data_evolution_reader/candidate_ranges_tests.rs#L536)
   



-- 
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]

Reply via email to