Skip to content

Add ZSTD_decompressScatter(): decompress into multiple output buffers - #4799

Open
ceedot-rock wants to merge 1 commit into
meta:devfrom
ceedot-rock:scatter-gather-2345
Open

ceedot-rock wants to merge 1 commit into
meta:devfrom
ceedot-rock:scatter-gather-2345

Conversation

@ceedot-rock

@ceedot-rock ceedot-rock commented Sep 28, 2026 •

Copy link
Copy Markdown

Related to #2345.

Adds ZSTD_decompressScatter(ZSTD_outBuffer* dsts, size_t nbDsts, const void* src, size_t srcSize): decompresses one input into an ordered array of output buffers, filling dst[0], then dst[1], and so on. Built on ZSTD_decompressStream, purely additive - the existing decompressor is untouched.

Scoping note: #2345's main ask is scatter-gather input for dictionary training; this PR covers the decompression-scatter half, which is the generally useful primitive (no gather copy on receive paths). Compression gather and dict-training gather are not attempted here.

The entry pos of each outBuffer is honored as the write offset, following the streaming-struct convention. Short total capacity -> dstSize_tooSmall; empty input is an error (unlike ZSTD_decompress returning 0 for it).

Tests: new tests/scatterGatherTest.c, 8/8 pass - odd-size buffers byte-identical to single-buffer decompress, nbDsts=1 equals ZSTD_decompress, zero-length middle buffer, 1-byte-short capacity, 2-frame concat, truncated input, bad params. ASan/UBSan clean, 300 fuzzer iterations clean.


Slid Phi Labs accepts donations to keep the lab independent.

@meta-cla

meta-cla Bot commented Sep 28, 2026

Copy link
Copy Markdown

Hi @ceedot-rock!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Sep 28, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed label Sep 28, 2026
@meta-cla

meta-cla Bot commented Sep 28, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

Decompresses one source buffer into an ordered array of ZSTD_outBuffer
destinations, filling them in order. Built on top of ZSTD_decompressStream,
so multiple concatenated frames are supported. Returns the total bytes
written, or ZSTD_error_dstSize_tooSmall when the combined destination
capacity falls short.

Adds tests/scatterGatherTest.c (8 tests) and a Makefile target.

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.

1 participant