XiangpengHao commented on code in PR #8756:
URL: https://github.com/apache/arrow-rs/pull/8756#discussion_r2481477396
##########
parquet/src/file/serialized_reader.rs:
##########
@@ -471,6 +455,47 @@ pub(crate) fn decode_page(
Ok(result)
}
+/// Decompressed the specified buffer, starting from the specified offset,
using
+/// the provided decompressor if available and applicable. If the buffer is not
+/// compressed, it will be returned as is.
+fn decompress_buffer(
+ buffer: Bytes,
+ offset: usize,
+ mut decompressor: Option<&mut Box<dyn Codec>>,
+ uncompressed_page_size: i32,
+) -> Result<Bytes> {
+ let Some(decompressor) = decompressor.as_mut() else {
+ return Ok(buffer);
+ };
+
+ let uncompressed_page_size = usize::try_from(uncompressed_page_size)?;
+ if offset > buffer.len() || offset > uncompressed_page_size {
+ return Err(general_err!("Invalid page header"));
+ }
+
+ let decompressed_size = uncompressed_page_size - offset;
+
+ if decompressed_size == 0 {
Review Comment:
Makes sense to me 👍
--
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]