You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Zstd compression does not encode content size in header #182
The Zstd writer implemented here is based on the Zstd streaming API. When encoding a chunk, set pledged size is not used. This means the frame content size is not encoded in the Zstd frame header.
Some Zstd decoding implementations such as numcodecs.js and Zarr numcodecs rely upon ZSTD_getFrameContentSize() to allocate a decompression buffer.
Here's an illustration of saving a zarr array with tensorstore using zstd compression. python-zstandard is unable to open the chunk unless max_output_size is provided.
We can probably ensure that tensorstore includes the uncompressed size in the header in this case, but in general there could be multiple variable-output-size codecs chained and it is desirable to be able to do streaming encoding.
Therefore in addition to that, other implementations should still support decoding without the size in the header.
Activity
[-]Zstd compression does not encode content size in[/-][+]Zstd compression does not encode content size in header[/+]mkitti commentedon Jul 26, 2024
Here's an illustration of saving a zarr array with tensorstore using zstd compression. python-zstandard is unable to open the chunk unless
max_output_sizeis provided.For an example of being unable to open the dataset with zarr-python see zarr-developers/zarr-python#2056
jbms commentedon Jul 26, 2024
Thanks for investigating this so thoroughly!
We can probably ensure that tensorstore includes the uncompressed size in the header in this case, but in general there could be multiple variable-output-size codecs chained and it is desirable to be able to do streaming encoding.
Therefore in addition to that, other implementations should still support decoding without the size in the header.
jbms commentedon Jan 10, 2025
For zarr v3 the pledged size is specified but not for zarr v2. It might be fixed by a later refactor of the zarr v2 codec handling.
mkitti commentedon Jul 10, 2025
Python's numcodecs can now decompress without a pledge size since zarr-developers/numcodecs#707 has been merged.
README: document TensorStore/numcodecs root cause and fix
mkitti commentedon Jun 18, 2026
My AI engineers are still running into this problem despite fixing the latest numcodecs. They are stuck on an older numcodecs. In response, I created https://github.com/JaneliaSciComp/zstd_recompress
Add optional uncompressed size hint to compression