Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .changeset/numcodecs-namespace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
"zarrita": minor
---

Add `numcodecs.` namespace for v2 codec registry and built-in shuffle/delta codecs

V2 filters and compressors are now registered under a `numcodecs.` prefix
(e.g., `numcodecs.blosc`, `numcodecs.zlib`) matching zarr-python's convention.
This separates v2-specific codecs from the v3 codec namespace.

Adds built-in `numcodecs.shuffle` and `numcodecs.delta` codecs for reading v2
data that uses these common numcodecs filters. Both are pure JS with no WASM
dependencies.

Custom v2 codecs can be registered under the same namespace:

```ts
zarr.registry.set("numcodecs.my-filter", async () => ({
fromConfig(config) {
return {
kind: "bytes_to_bytes",
encode(data) { /* ... */ },
decode(data) { /* ... */ },
};
},
}));
```
72 changes: 72 additions & 0 deletions fixtures/v2/data.zarr/.zmetadata
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,56 @@
],
"zarr_format": 2
},
"1d.contiguous.delta.i2/.zarray": {
"chunks": [
4
],
"compressor": {
"id": "zlib",
"level": 1
},
"dtype": "<i2",
"fill_value": 0,
"filters": [
{
"astype": "<i2",
"dtype": "<i2",
"id": "delta"
}
],
"order": "C",
"shape": [
4
],
"zarr_format": 2
},
"1d.contiguous.delta.shuffle.i2/.zarray": {
"chunks": [
4
],
"compressor": {
"id": "zlib",
"level": 1
},
"dtype": "<i2",
"fill_value": 0,
"filters": [
{
"astype": "<i2",
"dtype": "<i2",
"id": "delta"
},
{
"elementsize": 2,
"id": "shuffle"
}
],
"order": "C",
"shape": [
4
],
"zarr_format": 2
},
"1d.contiguous.f4.be/.zarray": {
"chunks": [
4
Expand Down Expand Up @@ -277,6 +327,28 @@
],
"zarr_format": 2
},
"1d.contiguous.shuffle.i2/.zarray": {
"chunks": [
4
],
"compressor": {
"id": "zlib",
"level": 1
},
"dtype": "<i2",
"fill_value": 0,
"filters": [
{
"elementsize": 2,
"id": "shuffle"
}
],
"order": "C",
"shape": [
4
],
"zarr_format": 2
},
"1d.contiguous.u1/.zarray": {
"chunks": [
4
Expand Down
23 changes: 23 additions & 0 deletions fixtures/v2/data.zarr/1d.contiguous.delta.i2/.zarray
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"chunks": [
4
],
"compressor": {
"id": "zlib",
"level": 1
},
"dtype": "<i2",
"fill_value": 0,
"filters": [
{
"astype": "<i2",
"dtype": "<i2",
"id": "delta"
}
],
"order": "C",
"shape": [
4
],
"zarr_format": 2
}
Binary file added fixtures/v2/data.zarr/1d.contiguous.delta.i2/0
Binary file not shown.
27 changes: 27 additions & 0 deletions fixtures/v2/data.zarr/1d.contiguous.delta.shuffle.i2/.zarray
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"chunks": [
4
],
"compressor": {
"id": "zlib",
"level": 1
},
"dtype": "<i2",
"fill_value": 0,
"filters": [
{
"astype": "<i2",
"dtype": "<i2",
"id": "delta"
},
{
"elementsize": 2,
"id": "shuffle"
}
],
"order": "C",
"shape": [
4
],
"zarr_format": 2
}
Binary file not shown.
22 changes: 22 additions & 0 deletions fixtures/v2/data.zarr/1d.contiguous.shuffle.i2/.zarray
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"chunks": [
4
],
"compressor": {
"id": "zlib",
"level": 1
},
"dtype": "<i2",
"fill_value": 0,
"filters": [
{
"elementsize": 2,
"id": "shuffle"
}
],
"order": "C",
"shape": [
4
],
"zarr_format": 2
}
Binary file added fixtures/v2/data.zarr/1d.contiguous.shuffle.i2/0
Binary file not shown.
Loading