Skip to content

feat: puffin zstd compression/decompression - #1198

Open
proost wants to merge 10 commits into
apache:mainfrom
proost:feat-puffin-zstd-serde
Open

proost wants to merge 10 commits into
apache:mainfrom
proost:feat-puffin-zstd-serde

Conversation

@proost

@proost proost commented Nov 30, 2026

Copy link
Copy Markdown
Member

issue: #1192

This is first step. Adding zstd compression and decompression logic.

disclosure: I got helps from opus 5.5 for writing test code.

Comment thread src/iceberg/puffin/puffin_format.cc Resolved
Comment thread src/iceberg/test/puffin_format_test.cc Resolved
EXPECT_EQ(blob_result.second, ToBytes("hello puffin"));
}

TEST(PuffinRoundTripTest, ZstdCompressedBlobs) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The Java fixtures cover Java writer → C++ reader compatibility. Could we preserve a reverse-direction check for C++ writer →
Java reader as well? I verified it locally for empty, binary, repetitive, and incompressible payloads. The check should compare decoded payloads and metadata, since different zstd implementations can produce different valid compressed bytes.

@proost proost Dec 1, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Idea is good, But i don't expect including this PR. If we checks c++ -> java reader here, then we should cover go, python, rust also and other language have to do same ways vice-versa. I don't think that is realistic.

In datasketches, we have tck repo(https://github.com/apache/datasketches-tck) for that. iceberg has iceberg-verification for same reason.

I think iceberg also handles binary compatability checks there.

how do you think? I will send serialized file generation PR later.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ack

Comment thread src/iceberg/puffin/puffin_format.cc Outdated

std::vector<std::byte> output(frame_size);
const size_t decompressed_size =
ZSTD_decompress(output.data(), output.size(), input.data(), input.size());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The Puffin spec requires one Zstd frame. An extra empty frame still passes this size check. Can we check that a single standard frame spans the entire blob and add a regression test?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Can you show me which case? Because i already have "frame_then_skippable_frame" and "frame_then_empty_frame" case.

@wgtmac wgtmac Dec 2, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry, my comment was on the previous commit. I think these cases are perfect!

Comment thread src/iceberg/puffin/puffin_format.cc Outdated
return NotSupported("LZ4 decompression is not yet supported");
case PuffinCompressionCodec::kZstd:
return NotSupported("Zstd decompression is not yet supported");
case PuffinCompressionCodec::kZstd: {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we move the zstd code into two small internal functions, like we do for gzip? That would keep the Puffin switch focused on choosing the codec. Perhaps we can also abstract out a CompressionCodec class?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I refactored to util: 6172bfd

making abstract class looks good to me, but how about handling next PR?

@proost
proost requested a review from wgtmac December 2, 2026 11:20
Comment thread src/iceberg/CMakeLists.txt Resolved
@proost
proost requested a review from wgtmac December 4, 2026 17:29

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants