Ted-Jiang commented on code in PR #2044:
URL: https://github.com/apache/arrow-rs/pull/2044#discussion_r918987470


##########
parquet/src/file/serialized_reader.rs:
##########
@@ -560,12 +606,53 @@ impl<T: Read + Send> PageReader for 
SerializedPageReader<T> {
         Ok(None)
     }
 
-    fn peek_next_page(&self) -> Result<Option<PageMetadata>> {
-        Err(nyi_err!("https://github.com/apache/arrow-rs/issues/1792";))
+    fn peek_next_page(&mut self) -> Result<Option<PageMetadata>> {
+        if let Some(page_offset_index) = &self.page_offset_index {
+            if self.seen_num_data_pages == page_offset_index.len() {
+                Ok(None)
+            } else if self.seen_num_data_pages == 0 && 
self.has_dictionary_page_to_read {
+                self.has_dictionary_page_to_read = false;
+                Ok(Some(PageMetadata {
+                    num_rows: usize::MIN,
+                    is_dict: true,
+                }))
+            } else {
+                let row_count = calculate_row_count(
+                    page_offset_index,
+                    self.seen_num_data_pages,
+                    self.total_num_values,
+                )?;
+                Ok(Some(PageMetadata {
+                    num_rows: row_count,
+                    is_dict: false,
+                }))
+            }
+        } else {
+            Err(general_err!("Must set page_offset_index when using 
peek_next_page in SerializedPageReader."))
+        }
     }
 
     fn skip_next_page(&mut self) -> Result<()> {
-        Err(nyi_err!("https://github.com/apache/arrow-rs/issues/1792";))
+        if let Some(page_offset_index) = &self.page_offset_index {
+            let location = &page_offset_index[self.seen_num_data_pages];
+            let compressed_page_size = location.compressed_page_size;
+            //skip page bytes
+            let skip_size = io::copy(
+                self.buf.by_ref().take(compressed_page_size as u64).by_ref(),

Review Comment:
   @tustvold 
[62f9bbc](https://github.com/apache/arrow-rs/pull/2044/commits/62f9bbc42071c32533cd49d5e847a151b3aa4d43)
 PTAL 😊



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to