Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is for an early prototype of sharding support in zarrita, as described in the original issue zarr-developers/zarr-python#877. It serves mainly to discuss the overall implementation approach for sharding. This PR is not meant to be merged.
This prototype
arr.zeros((20, 3), chunks=(3, 3), shards=(2, 2), …)
).One shard corresponds to one storage key, but can contain multiple chunks:
array.json
config and loaded when opening an array again, adding two entries:"shard_format": "indexed"
specifies the binary format of the shards and allows to extend sharding with other formats later"shards": [2, 2]
specifies how many chunks are contained in a shard,IndexedShardedStore
class that is used to wrap the chunk-store when sharding is enabled. This store handles the grouping of multiple chunks to one shard and transparently reads and writes them via the inner store in a binary format which is specified below. The original store API does not need to be adapted, it just stores shards instead of chunks, which are translated back to chunks by theIndexedShardedStore
.sharding_test.py
for demonstration purposes, this is not meant to be merged but servers to illustrate the changes.The currently implemented file format is still up for discussion. It implements "Format 2" @jbms describes in zarr-developers/zarr-python#876 (comment).
Chunks are written successively in a shard (unused space between them is allowed), followed by an index referencing them.
The index holding an
offset, length
pair of little-endian uint64 per chunk, the chunks-order in the index is row-major (C) order,e.g. for (2, 2) chunks per shard an index would look like:
Empty chunks are denoted by setting both offset and length to
2^64 - 1
. All the index always has the full shape of all possible chunks per shard, even if they are outside of the array size.For the default order of the actual chunk-content in a shard I'd propose to use C/F/Morton order, but this can easily be changed and customized, since any order can be read.