Skip to content

HIVE-30104: LLAP: read a Parquet footer in one round trip - #6979

Open
deniskuzZ wants to merge 5 commits into
apache:masterfrom
deniskuzZ:HIVE-30104
Open

deniskuzZ wants to merge 5 commits into
apache:masterfrom
deniskuzZ:HIVE-30104

Conversation

@deniskuzZ

@deniskuzZ deniskuzZ commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

  • On a footer cache miss, LlapParquetIoImpl reads the last 64 KB of the file once (S3A's default readahead) and
    caches the footer from that buffer. A footer larger than that is read on its own.
  • When the cache key is a SyntheticFileId, as it is on object stores and for Iceberg tables, the file length comes
    from the key and the file is opened with fs.option.openfile.length, so the miss looks up no status. An Iceberg
    table's key takes the size from the table metadata, so a wrong file_size_in_bytes now fails the footer read
    instead of being hidden by the status lookup.
  • Under an HDFS inode key the miss still looks up the status for the length, which is a NameNode call.
  • The length, magic and footer index are checked as ParquetFileReader.readFooter checks them, before anything is
    cached.
  • ParquetEncodedDataReader builds the footer ParquetReadOptions once instead of once per split.
  • The TODO in HiveVectorizedReader about Iceberg's missing modification time is replaced with a comment on the key
    it builds.

Why are the changes needed?

  • A miss used to cost a status lookup, a read of the footer length, a second read for the footer, and the HEAD that
    open() issues: two HEADs and two GETs on S3A. It now costs one GET.
  • Plain tables on S3 still pay one HEAD per split to build their synthetic key (HdfsUtils.getFileId). Avoiding it
    needs the split to carry the file status, as OrcSplit does, and is left for a follow-up.
  • ParquetFileReader.readFooter(InputFile, filter) builds read options for a non-Hadoop file on every call, which
    parses the Hadoop default configuration. At TPC-DS 10 TB that was 18.5% of q28's LLAP task time (51,134 splits).
    A footer read of a local file goes from 631 to 43 us.

Does this PR introduce any user-facing change?

No

How was this patch tested?

TestParquetEncodedDataReader:

  • a footer within the tail costs one read; a larger one costs two and matches ParquetFileReader's footer
  • under a SyntheticFileId key the miss makes no status lookup of its own and caches the same footer
  • a file too short for Parquet, a missing magic, and a footer index outside the file are refused and not cached

parquet_llap_counters.q masks HDFS_BYTES_READ, as orc_ppd_basic.q does: a cold miss now reads up to 64 KB of the
file's tail instead of the footer alone.

The Iceberg LLAP Parquet q-tests llap_iceberg_read_parquet, vectorized_iceberg_read_parquet and
vectorized_iceberg_read_mixed pass, with their footers read under Iceberg's synthetic keys.

- A footer miss read the footer length from the last 8 bytes, then the footer: two reads, plus the HEAD S3A's
  open() issues to learn the length
- getFooterBuffersFromCache reads the last 64 KB (S3A's default readahead) once and caches the footer from it; a
  footer larger than that is read on its own
- The file is opened with the status already fetched, so S3A skips the HEAD
- The length, magic and footer index are checked as ParquetFileReader.readFooter checks them, before caching
- ParquetEncodedDataReader builds the footer read options once: readFooter(InputFile, filter) built them per split,
  parsing the Hadoop default configuration each time (18.5% of q28's LLAP task time at 10 TB, 51,134 splits); a
  footer read of a local file 631 -> 43 us
- TestParquetEncodedDataReader: one read for a footer within the tail, two for a larger one; a short file, a missing
  magic and a footer index outside the file are refused and not cached
A footer miss now reads up to 64 KB from the end of the file, so the bytes read depend on the file size.
Also seek to the computed footer index, and clean up a comment and a test helper.
A SyntheticFileId holds the file's length, so a footer miss under one opens the file with that length and
looks up no status, which is a HEAD on S3A. Iceberg tables get such a key from the table metadata.
Also use Parquet's message for a missing magic number, and move the miss path into readAndCacheFooter.
Only HDFS inode keys reach the status lookup in readAndCacheFooter, and HDFS opens a file without using a
status passed to openFile, so the lookup now supplies just the length.
@deniskuzZ
deniskuzZ requested a review from abstractdog December 4, 2026 15:31
@sonarqubecloud

sonarqubecloud Bot commented Dec 4, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants