You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/06/07 16:08:39 UTC

[GitHub] [arrow-rs] alamb commented on a diff in pull request #1804: Add public API for decoding parquet footer

alamb commented on code in PR #1804:
URL: https://github.com/apache/arrow-rs/pull/1804#discussion_r891423381


##########
parquet/src/arrow/async_reader.rs:
##########
@@ -140,24 +138,13 @@ impl<T: AsyncRead + AsyncSeek + Unpin + Send> AsyncFileReader for T {
             let mut buf = [0_u8; 8];
             self.read_exact(&mut buf).await?;
 
-            if buf[4..] != PARQUET_MAGIC {
-                return Err(general_err!("Invalid Parquet file. Corrupt footer"));
-            }
-
-            let metadata_len = LittleEndian::read_i32(&buf[..4]) as i64;
-            if metadata_len < 0 {
-                return Err(general_err!(
-                    "Invalid Parquet file. Metadata length is less than zero ({})",
-                    metadata_len
-                ));
-            }
-
-            self.seek(SeekFrom::End(-8 - metadata_len)).await?;
+            let metadata_len = decode_footer(&buf)?;
+            self.seek(SeekFrom::End(-8 - metadata_len as i64)).await?;

Review Comment:
   I wonder if we can make this magic `8` a `const` somewhere to help readablility -- or maybe it is already `FOOTER_SIZE`



-- 
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-unsubscribe@arrow.apache.org

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