etseidl commented on code in PR #10842:
URL: https://github.com/apache/arrow-rs/pull/10842#discussion_r3856584548


##########
parquet/src/file/metadata/mod.rs:
##########
@@ -399,18 +321,460 @@ impl PageIndex {
     /// Returns:
     /// * `Some(&Vec<PageLocation>)` - Vector of page locations if offset 
index exists
     /// * `None` - Offset index not available
-    pub fn page_locations(
+    fn page_locations(
         &self,
         row_group_idx: usize,
         column_idx: usize,
     ) -> Option<&Vec<PageLocation>> {
-        if let Some(offset_indexes) = self.offset_indexes.as_ref() {
-            let rg = offset_indexes.get(row_group_idx)?;
-            let off_idx = rg.get(column_idx)?.as_ref()?;
-            Some(off_idx.page_locations())
+        Some(
+            self.offset_index(row_group_idx, column_idx)?
+                .page_locations(),
+        )
+    }
+
+    /// Returns a reference to the trait object as `&dyn Any` for downcasting
+    ///
+    /// This allows downcasting to concrete types when needed (e.g., for 
serialization)
+    fn as_any(&self) -> &dyn std::any::Any;
+}
+
+/// Provides convenient access to page index data for a specific row group
+///
+/// This struct wraps a [`PageIndexProvider`] and automatically applies the 
row group
+/// index, simplifying access to column and offset indexes for a single row 
group.
+/// It is primarily used by readers to avoid repeatedly passing the row group 
index
+/// when accessing page-level metadata.
+///
+/// # Example
+///
+/// ```
+/// use parquet::file::metadata::ParquetMetaData;
+/// # use parquet::errors::Result;
+///
+/// fn process_row_group_pages(metadata: &ParquetMetaData, row_group_idx: 
usize) -> Result<()> {
+///     if let Some(page_index) = metadata.page_index() {
+///         // Create a row-group-specific view
+///         let rg_page_index = 
parquet::file::metadata::RowGroupPageIndex::new(
+///             row_group_idx,
+///             metadata.page_index().cloned(),
+///         );
+///
+///         // Now access column indexes without specifying row_group_idx each 
time
+///         for col_idx in 
0..metadata.file_metadata().schema_descr().num_columns() {
+///             if let Some(col_idx_data) = 
rg_page_index.column_index(col_idx) {
+///                 println!("Column {} has {} pages", col_idx, 
col_idx_data.num_pages());
+///             }
+///         }
+///     }
+///     Ok(())
+/// }
+/// ```
+#[derive(Debug)]
+pub struct RowGroupPageIndex {

Review Comment:
   this struct was my solution for how to replace the functions that returned a 
slice of indexes for a given row group. After using it some I'm wondering if it 
should also carry the number of columns.



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