Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

read footer using 1 call readFully(byte[8]) instead of 5 calls ( 4 x read() for footer length + 1 x read(byte[4]) for magic marker )

Open
#3,074 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
java

Research direction

In parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetFileReader.java, inspect readFooter() and its current footer-length and magic reads first. Verify that a single readFully(byte[8]) preserves both standard and encrypted-footer magic handling, then run the relevant project tests; done means footer parsing remains correct with fewer read calls.

Written by the indexing model from the issue text.

Description

Type: enhancement
Describe the enhancement requested

This is a minor performance improvement, but worth when reading many files.
read footer using 1 call readFully(byte[8]) instead of 5 calls ( 4 x read() for footer length + 1 x read(byte[4]) for magic marker )

in summary the patch is for file ParquetFileReader.java, method "readFooter()" :

--- a/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetFileReader.java
+++ b/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetFileReader.java
@@ -585,14 +585,18 @@ public class ParquetFileReader implements Closeable {
     }

     // Read footer length and magic string - with a single seek
-    byte[] magic = new byte[MAGIC.length];
-    long fileMetadataLengthIndex = fileLen - magic.length - FOOTER_LENGTH_SIZE;
+    long fileMetadataLengthIndex = fileLen - MAGIC.length - FOOTER_LENGTH_SIZE;
     LOG.debug("reading footer index at {}", fileMetadataLengthIndex);
     f.seek(fileMetadataLengthIndex);
-    int fileMetadataLength = readIntLittleEndian(f);
-    f.readFully(magic);
+    byte[] magicAndLengthBytes = new byte[FOOTER_LENGTH_SIZE + MAGIC.length];
+    f.readFully(magicAndLengthBytes);
+    int fileMetadataLength = readIntLittleEndian(magicAndLengthBytes, 0);

     boolean encryptedFooterMode;
+    // using JDK >= 9: if (Arrays.equals(MAGIC, 0, MAGIC.length, magicAndLengthBytes, FOOTER_LENGTH_SIZE, FOOTER_LENGTH_SIZE + MAGIC.length)) {
+    // using JDK <= 8: need extract sub array then compare
+    byte[] magic = new byte[MAGIC.length];
+    System.arraycopy(magicAndLengthBytes, FOOTER_LENGTH_SIZE, magic, 0, MAGIC.length);
     if (Arrays.equals(MAGIC, magic)) {
       encryptedFooterMode = false;
     } else if (Arrays.equals(EFMAGIC, magic)) {
Component(s)

Core

Dominant language
Java
Stars
3.1k
Forks
1.6k
Avg merge
6d 16h
Merged PRs (30d)
36

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/parquet-java

All issues in apache/parquet-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.