Skip to content

Hadoop uses a blockHeaderSize of 8 instead of the normal 4 - #768

Merged
xerial merged 2 commits into
xerial:mainfrom
tomjshore:hadoopBlockHeaderSize
Oct 10, 2026
Merged

xerial merged 2 commits into
xerial:mainfrom
tomjshore:hadoopBlockHeaderSize

Conversation

@tomjshore

Copy link
Copy Markdown
Contributor

Fixes a bug in the Hadoop compression where sometime you get the error IllegalArgumentException("not enough space for output: need %,d bytes, but only %,d remaining"); see this issue #767

Fixed by changing how on hadoop what the buffer size should be.

{
int maxCompressedSize = Snappy.maxCompressedLength(inputSize);
return maxCompressedSize < outputBuffer.length - outputCursor - 4;
return maxCompressedSize < outputBuffer.length - outputCursor - blockHeaderSize();

@pan3793 pan3793 Oct 10, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be <= ?

< is conservative by 1 byte and can't trigger the exception; <= is the exact bound and saves a separate header flush on the first block. Not blocking.

}

@Override
protected int blockHeaderSize() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like this repo prefers to put the { on the next line

@pan3793

pan3793 commented Oct 10, 2026

Copy link
Copy Markdown

can you add a UT which has been mentioned in your issue

Writes a full incompressible block followed by trailing blocks of every
size and decodes the Hadoop block format, covering the case where the
output buffer had only 4-8 bytes of slack for the 8-byte block header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xerial
xerial merged commit 71683f7 into xerial:main Oct 10, 2026
13 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