feat: Add suffix chunk key encoding - #28
Conversation
This document outlines the `suffix` chunk key encoding for Zarr v3, which allows appending user-defined file extensions to chunk keys, enhancing interoperability with traditional file-based tools.
| The configuration for this encoding is a JSON object with one required and one optional member. | ||
|
|
||
| * `"suffix"`: **(Required)** A string that will be appended to the encoded chunk key. | ||
| * `"base-encoding"`: **(Optional)** A chunk key encoding configuration object. This specifies the "base" encoding to be used *before* the suffix is appended. If omitted, the store's `default` chunk key encoding is used. |
There was a problem hiding this comment.
| * `"base-encoding"`: **(Optional)** A chunk key encoding configuration object. This specifies the "base" encoding to be used *before* the suffix is appended. If omitted, the store's `default` chunk key encoding is used. | |
| * `"base_encoding"`: **(Optional)** A chunk key encoding configuration object. This specifies the "base" encoding to be used *before* the suffix is appended. If omitted, the store's `default` chunk key encoding is used. |
Zarr uses snake_case in the JSON metadata.
I would make this required, because it is also required in the top-level array metadata. It helps implementations to make this explicit.
|
Cool, I wrote something similar here https://docs.rs/zarrs/latest/zarrs/array/chunk_key_encoding/default_suffix/struct.DefaultSuffixChunkKeyEncoding.html, but this is much better because it can compose over other chunk key encodings.
Stores don't have a default chunk key encoding? |
Combining the two comments: * Change to snake case. * Refer to the default chunk key encoding.
|
i love this! do we care at all about suffixes that ascend the directory tree on local file systems, e.g. `"../foo.tif"? |
I think the base key would need to be a directory first for this to work on a local file system. I'm not sure how I'm thinking that we do not care about this. If something needs to be contained within a directory, it would not be Zarr's responsibilty to maintain that containment. Someone would probably want to use a chroot jail. |
|
A complimentary chunk key encoding might be something to ascend directories to assist in mapping from a high dimensionality arrays to a squeezed lower dimensionality array. Imagine an array with dimensions |
|
Implemented here: zarrs/zarrs#286 I question the |
|
|
normanrz
left a comment
There was a problem hiding this comment.
This PR meets the requirements for being merged. However, there still seems to be some discussion.
Let me know when you're ready to.
Co-authored-by: Norman Rzepka <code@normanrz.com>
Co-authored-by: Norman Rzepka <code@normanrz.com>
Co-authored-by: Norman Rzepka <code@normanrz.com>
Co-authored-by: Norman Rzepka <code@normanrz.com>
|
Should I put something in place of "Identifier: (A unique URI to be assigned upon formal adoption)" ? |
|
I will add a JSON schema here and then we can consider merging. |
|
Should we instead focus on #67? |
|
yes IMO #67 looks better than this. closing |
|
oops, I confused this with |
|
The implementation of #67 looks much more complicated than this. Considering that a chunk key encoding needs to be evaluated for every chunk I would like to see some benchmark numbers before saying that is obviated by a full blown string interpolation engine. Naive string interpolation could quickly lead to considerable memory thrashing considering 10³ to 10⁶ chunks. |
|
That seems like an implementation detail and not a spec concern. I can imagine a number of approaches to get good performance. For example, implementations could detect simple suffix or prefix cases when opening the array and then using optimized implementations. Alternatively, they could JIT a function to generate the chunk keys. |
|
I suspect that one string interpolation op per chunk index would be negligible compared to the IO cost, but you're right that if you're not using a language's native string interpolation machinery, it could be awkward to write and optimise. I'll have a fiddle. Also agreed with Norman that it would be easy to detect a |
This document outlines the
suffixchunk key encoding for Zarr v3, which allows appending user-defined file extensions to chunk keys, enhancing interoperability with traditional file-based tools.