This class implements the basic ancestor for chunking the data of Zarr arrays. It provides the mechanism for chunk access in the Zarr store that is independent of the geometry of the chunk grid: addressing chunks by their grid index through the chunk key encoding, caching chunk I/O objects, raw chunk access and relocating chunks in the store.
The geometry of the chunk grid - how the array is partitioned into chunks
along each dimension - is the responsibility of descendant classes. The
"regular" chunk grid that is a required component of Zarr v.3 is
implemented by the chunk_grid_regular class. Zarr arrays that use
sharding are managed by the chunk_grid_sharded class, a descendant of
chunk_grid_regular because the sharding codec requires a regular grid of
shards. Sharding is treated as a chunking scheme rather than as a codec
because it has to do the same topological operations as a regular chunk
manager to map a user request for data to ranges across multiple chunks
(and shards) and then apply the set of codecs that apply. These codecs for
sharded data are embedded in the sharding configuration.
A descendant class must set the private field .grid and implement the
private method max_chunk_length() and the public methods resize(),
read() and, if supported, write().
There is no point instantiating this class directly, other than in the
initialize() method of a descendant class.
Super class
zarr_extension -> chunking
Active bindings
array_shape(read-only) The shape of the array,
NULLfor a scalar array.grid(read-only) The number of chunks along each dimension of the array. This is an empty integer vector for a scalar array.
chunk_encodingSet or retrieve the chunk key encoding to be used for creating store keys for chunks.
data_typeThe data type of the array using the chunking scheme. This is set by the array when starting to use chunking for file I/O.
storeThe store of the array using the chunking scheme. This is set by the array when starting to use chunking for file I/O.
array_prefixThe prefix of the array using the chunking scheme. This is set by the array when starting to use chunking for file I/O.
Methods
Inherited methods
chunking$new()
Initialize a new chunking scheme for an array. This should only be called by descendant classes, which must also set the grid of chunks of a non-scalar array.
Usage
chunking$new(class_name, array_shape)chunking$resize()
Resize the array by growing or shrinking any combination of dimensions at either end, updating the chunks in the store accordingly. How a requested change maps onto the chunk grid is determined by the descendant class.
chunking$insert_dimension()
Move the chunks in the store to the grid of an array whose rank is one higher, by inserting a new dimension that holds exactly one chunk. A scalar array has its single chunk moved to the first chunk of a rank-1 grid. Chunk payload is never touched. The chunking scheme itself is not updated: the caller must create a new chunking scheme for the promoted array.
chunking$chunk_keys()
Generate the keys of all chunks in the chunk grid, or of all shards for a sharded array. Keys are derived from the grid and the chunk key encoding, not by listing the store, so this works for stores that cannot list their keys. Chunks need not exist in the store.
chunking$read_raw()
Read the bytes of a chunk (or shard) as they are held in the store, without decoding. Any pending edits to the chunk are flushed to the store first.
chunking$write_raw()
Write the bytes of a chunk (or shard) to the store, without
encoding. Any cached copy of the chunk is dropped. The caller is
responsible for value being consistent with the codecs of the array.