alamb commented on code in PR #8756:
URL: https://github.com/apache/arrow-rs/pull/8756#discussion_r2481456563
##########
parquet/src/file/serialized_reader.rs:
##########
@@ -389,31 +389,15 @@ pub(crate) fn decode_page(
// TODO: page header could be huge because of statistics. We should set a
// maximum page header size and abort if that is exceeded.
- let buffer = match decompressor {
- Some(decompressor) if can_decompress => {
- let uncompressed_page_size =
usize::try_from(page_header.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;
- let mut decompressed = Vec::with_capacity(uncompressed_page_size);
- decompressed.extend_from_slice(&buffer.as_ref()[..offset]);
- if decompressed_size > 0 {
Review Comment:
You can see here that if `decompressed_size` is 0, it returns `decompressed`
unmodified and `decompressed` was just the first `offset` bytes of the input
buffer
I changed the code to return `buffer.slice(..offset)` in this case
I can add it to this location directly to make the diff smaller, but the
logic was already hard to follow and highly indented to I moved it into its own
function while I was at it
--
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]