Skip to content

Decode Zstandard chunks in the HDF5 reader - #576

Merged
prete merged 1 commit into
mainfrom
claude/hdf5-zstandard-chunks-90f9cc
Dec 4, 2026
Merged

prete merged 1 commit into
mainfrom
claude/hdf5-zstandard-chunks-90f9cc

Conversation

@prete

@prete prete commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #569 (Phase 38). The app's own HDF5 reader (src/hdf5/, which BigDataViewer datasets use) now decodes chunks compressed with Zstandard. Before, those datasets failed with "HDF5 Zstandard chunks cannot be decoded".

What's in it

  • Zstandard filter. HDF Group plugin filter 32015, the one hdf5plugin.Zstd() and H5Zzstd write. decodeHdf5Chunk decompresses it with fzstd, alone or with other filters such as shuffle. FILTER_ZSTD is in SUPPORTED_HDF5_FILTERS, so the BDV open check accepts it.
  • fzstd is pure JavaScript and synchronous like the other filters, and needs no WebAssembly or 'unsafe-eval'. It was already in the bundle through hyparquet-compressors. It is now a direct dependency, pinned to the same 0.1.1, so there is one copy. In the build it lands in the Zarr decode worker, where BDV chunks are decoded.
  • Fixture. zstd.h5 is written by make_bdv_fixtures.py with h5py and hdf5plugin 7.1.0. It has two setups and no XML: one with Zstandard alone, one with shuffle then Zstandard. Each chunk is 160 KiB, so it spans two Zstandard blocks. Only this file was added. Re-running the script rewrites latest.h5 with different bytes; the other fixtures come out the same.
  • Docs. A decision and a delivered item in Phase 38, and the BigDataViewer filter list in docs/modalities/image.md.

Worth knowing

  • Optional filters skip the open check. h5py marks plugin filters as optional (flags 1), and the BDV open check skips optional filters. So a plugin filter that still can't be decoded (LZF or Blosc, say) is not refused when the dataset opens. It fails chunk by chunk in the workers instead. This PR doesn't change that.
  • h5wasm paths unchanged. H5AD, 10x .h5 and the HDF5 structure browser read through h5wasm and still can't read Zstandard datasets, as the user guide already says.

Checked

  • The new reader and loader tests fail without the decoder and pass with it.
  • The full vitest suite (566 files, 6,663 tests), tsc -b, ESLint on the changed files, Prettier and check:docs pass locally.
  • In the dev app (browser pane), zstd.h5 served by Vite opens through the real Zarr decode workers: 2 channels, 4 z planes, no console errors. Auto-contrast ranges are 5077–5606 and 15077–15606, inside the fixture's values on that plane (5050–5623 and 15050–15623).

The app's HDF5 reader (src/hdf5/, used for BigDataViewer datasets) now
decodes chunks compressed with Zstandard: the HDF Group's registered plugin
filter 32015, which hdf5plugin.Zstd() and H5Zzstd write. Before, such
datasets failed with "HDF5 Zstandard chunks cannot be decoded".

- decodeHdf5Chunk decompresses them with fzstd, alone or with other
  filters such as shuffle; FILTER_ZSTD is in SUPPORTED_HDF5_FILTERS.
- fzstd is pure JavaScript and synchronous like the other filters, needs
  no WebAssembly or 'unsafe-eval', and was already in the bundle through
  hyparquet-compressors; it is now a direct dependency at the same 0.1.1.
- zstd.h5 fixture (h5py with hdf5plugin): one setup with Zstandard alone,
  one with shuffle then Zstandard, chunks of 160 KiB (two Zstandard
  blocks). Reader and loader tests read it.
- Docs: Phase 38 decision and delivered item, the BigDataViewer filter
  list in docs/modalities/image.md.
@prete
prete merged commit fd42c99 into main Dec 4, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant