Skip to content

[core] Expose Avro header and physical block locations - #9835

Merged
JingsongLi merged 4 commits into
apache:masterfrom
leaves12138:codex/avro-block-metadata
Sep 15, 2026
Merged

JingsongLi merged 4 commits into
apache:masterfrom
leaves12138:codex/avro-block-metadata

Conversation

@leaves12138

@leaves12138 leaves12138 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Purpose

Expose the original Avro object-container header and physical block offsets/lengths through RawBlockReader, AvroBlockReader, and ManifestAvroReader. These locations allow callers to index existing manifest blocks and reconstruct valid Avro streams from selected blocks. Encoded lengths include the block header and sync marker.

The reader chain accepts SeekableInputStream and computes positions from getPos() with Avro decoder read-ahead deducted. Reading starts at the stream's current position. The original header bytes are captured during construction and stored in a final byte array; the underlying stream position is restored before block reading continues. Header getters return defensive copies without I/O. ByteArraySeekableStream permits seeking to EOF so position restoration also works for small in-memory Avro files after read-ahead reaches their end.

This is the first standalone prerequisite extracted from the manifest sidecar work in #9743. Sidecar generation, scan pruning, and sidecar/block caching will follow separately.

Tests

  • Checked physical boundaries against DataFileWriter.sync() for null, deflate, Snappy, and Zstandard codecs, including large headers, one-byte/short reads, repeated look-ahead, borrowed-block reuse, and empty files.
  • Reconstructed individual blocks with the original header and verified their records using the standard Avro reader.
  • Covered header capture during construction, defensive copies without further seeks, input closure when header capture fails, non-zero initial stream positions, and in-memory streams positioned at EOF.
  • Extended manifest integration coverage to verify header preservation and contiguous physical block coverage.
  • Passed 128 tests on Java 8, with normal Maven validation checks enabled:
mvn -B -ntp -nsu -pl paimon-core -am \
  -DwildcardSuites=none -DfailIfNoTests=false \
  -Dtest=ByteArraySeekableStreamTest,OffsetSeekableInputStreamTest,AvroBlockReaderTest,AvroFileFormatTest,ManifestFileTest clean test

@leaves12138
leaves12138 marked this pull request as draft September 15, 2026 07:07
@leaves12138
leaves12138 marked this pull request as ready for review September 15, 2026 07:48
@leaves12138
leaves12138 marked this pull request as draft September 15, 2026 07:54
@leaves12138
leaves12138 marked this pull request as ready for review September 15, 2026 07:56
@XiaoHongbo-Hope

Copy link
Copy Markdown
Contributor

+1

@JingsongLi
JingsongLi merged commit ed88de3 into apache:master Sep 15, 2026
15 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants