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:12:58 UTC

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

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


##########
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:
   It actually makes the code harder to read, as `FOOTER_SIZE` is `usize` but then `SeekFrom` wants `i64`... The compiler checks the array size, and I don't suppose it is likely to change, so I think we should be fine



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