This class implements the regular chunk grid for Zarr arrays, in which all chunks have the same shape. Chunks along the high end of a dimension extend beyond the array when the array shape is not a multiple of the chunk shape. It manages reading from and writing to Zarr stores, using the codecs for data transformation.
Super classes
zarr_extension -> chunking -> chunk_grid_regular
Active bindings
chunk_shape(read-only) The dimensions of each chunk in the chunk grid of the associated array.
codecsThe list of codecs used by the chunking scheme. These are set by the array when starting to use chunking for file I/O. Upon reading, the list of registered codecs.
Methods
chunk_grid_regular$new()
Initialize a new chunking scheme for an array.
Usage
chunk_grid_regular$new(array_shape, chunk_shape)chunk_grid_regular$metadata_fragment()
Return the metadata fragment that describes this chunking scheme.
chunk_grid_regular$resize()
Resize the array, growing or shrinking any combination of dimensions at either end in one pass. Chunks are renamed in the store when their grid index moves and erased when they fall outside the new grid. No chunk payload is re-encoded except for a chunk left straddling a shrinking, non-chunk-aligned high-end boundary, whose excess elements are set to the fill value.
Because chunks have a fixed position on the grid, low can only move
in whole chunks: values are rounded outward to the nearest chunk (more
space added when growing, less removed when shrinking). high is not
constrained this way.
Arguments
low, highInteger vectors, one element per array dimension. Positive grows that end, negative shrinks it,
0leaves it unchanged.
chunk_grid_regular$read()
Read data from the Zarr array into an R object. The read can
span multiple chunks. Reads will be parallelised if
future::plan(multisession) is set; by default the reading is
sequential.
chunk_grid_regular$write()
Write data to the array. Writing data always uses a sequential plan.
Arguments
dataAn R object with the same dimensionality as the Zarr array.
start, stopInteger vectors of the same length as the dimensionality of the Zarr array, indicating the starting and ending (inclusive) indices of the data along each axis. Ignored for a scalar array.
flushLogical, default is
TRUE. Should the chunks that have been written to be flushed to the store (TRUE), or should they be left stale for further writes to the same chunk (FALSE). Leaving the chunks stale for further writing leads to better performance when chunks are written to multiple times. Call theflush()method to persist data in stale chunks.