Skip to content

Registration system for chunk key encoding - #242

Merged
mkitti merged 2 commits into
JuliaIO:mkitti-abstract-chunk-key-encodingfrom
mkitti:mkitti-chunk-key-registration
Mar 13, 2026
Merged

Registration system for chunk key encoding#242
mkitti merged 2 commits into
JuliaIO:mkitti-abstract-chunk-key-encodingfrom
mkitti:mkitti-chunk-key-registration

Conversation

@mkitti

@mkitti mkitti commented Mar 11, 2026

Copy link
Copy Markdown
Member

This is a pull request with a base of mkitti-abstract-chunk-key-encoding which is currently #234 .

This introduces register_chunk_key_encoding as a method to add additional chunk key encodings. The intention is to abstract away some of the implementation details while mapping chunk key encoding names in JSON to constructor invocations.

@mkitti

mkitti commented Mar 11, 2026

Copy link
Copy Markdown
Member Author

See also https://github.com/mkitti/Zarr.jl/pull/2/changes for a similar registration system for codecs.

…tration

Introduce `ChunkKeyEncodingEntry` struct pairing
`return_type::Type{<:AbstractChunkKeyEncoding}` with `parser::Function`,
replacing the bare `Dict{String, Function}` registry.

- `register_chunk_key_encoding(parser, name, ::Type{T}=AbstractChunkKeyEncoding)`
  now stores a `ChunkKeyEncodingEntry` with the declared return type; the type
  is the last (optional) argument to work naturally with do-block syntax
- `parse_chunk_key_encoding` asserts the result against `entry.return_type`
  at runtime
- All built-in registrations updated with their specific concrete types
  (`ChunkKeyEncoding` for "default" and "v2", `SuffixChunkKeyEncoding` for
  "suffix")

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mkitti

mkitti commented Mar 13, 2026

Copy link
Copy Markdown
Member Author

We discussed the design at the March 12th meeting.

@mkitti
mkitti merged commit a54b2c9 into JuliaIO:mkitti-abstract-chunk-key-encoding Mar 13, 2026
16 checks passed
mkitti added a commit that referenced this pull request Mar 13, 2026
* Add AbstractChunkKeyEncoding, rename ChunkEncoding

* Add constraint

Co-authored-by: Anshul Singhvi <anshulsinghvi@gmail.com>

* chore: Update to new master

* feat: Add SuffixChunkKeyEncoding

* Registration system for chunk key encoding (#242)

* Implement a registration system for chunk key encoding

* refactor: Add typed ChunkKeyEncodingEntry to chunk key encoding registration

Introduce `ChunkKeyEncodingEntry` struct pairing
`return_type::Type{<:AbstractChunkKeyEncoding}` with `parser::Function`,
replacing the bare `Dict{String, Function}` registry.

- `register_chunk_key_encoding(parser, name, ::Type{T}=AbstractChunkKeyEncoding)`
  now stores a `ChunkKeyEncodingEntry` with the declared return type; the type
  is the last (optional) argument to work naturally with do-block syntax
- `parse_chunk_key_encoding` asserts the result against `entry.return_type`
  at runtime
- All built-in registrations updated with their specific concrete types
  (`ChunkKeyEncoding` for "default" and "v2", `SuffixChunkKeyEncoding` for
  "suffix")

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Anshul Singhvi <anshulsinghvi@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant