Chunk shape¶
Terms¶
chunk_shapeA tuple of D positive floats, in the store’s coordinate units, giving the edge lengths of one chunk. The chunk at absolute coordinate
(i_0, …, i_{D-1})covers[i_d × chunk_shape[d], (i_d + 1) × chunk_shape[d])on each axisd.- Chunk coordinate
The absolute integer coordinate of a chunk:
floor(p[d] / chunk_shape[d])for a vertex at positionp. It can be negative.- Chunk grid
The block of chunk coordinates a level allocates, set by the store’s
bounds. Its first coordinate is the grid origin.- Storage key
The path of one chunk’s cell in a per-chunk array, for example
0/vertices/c/1/0/3. Its indices are the chunk coordinate minus the grid origin.
Introduction¶
A store cuts space into a regular grid of chunks. Each vertex is stored in the chunk that contains it, and reads and writes work on whole chunks. Large chunks mean fewer files and requests; small chunks suit small queries. Bins subdivide a chunk. Choose chunk and bin sizes covers picking values.
Technical reference¶
Declaration¶
chunk_shape is a required key of the root zarr_vectors object, for
example "chunk_shape": [200.0, 200.0, 200.0]. Its unit is the
vertices’ coordinate unit and its length is the spatial dimensionality
D. It need not be isotropic. If it is omitted, create_store uses one
chunk covering the bounds, and write_points one chunk covering the
data.
A level other than 0 may record its own chunk_shape in its zarr_vectors level object,
a positive integer multiple of the root value on each axis, so coarse
chunks nest over fine ones. build_pyramid(..., chunk_scale_factors=...)
writes these; see Pyramid construction.
Other levels use the root value.
Chunk grid and storage keys¶
The writer derives the grid from the root bounds, which are inclusive:
origin[d] = floor(lo[d] / chunk_shape[d])
shape[d] = floor(hi[d] / chunk_shape[d]) - origin[d] + 1
Writers compute chunk coordinates as numpy.floor(positions / chunk_shape)
in float64, so a vertex on a chunk boundary is in the upper chunk.
For bounds of about −150 to 450 on each axis and chunk_shape = 200:
origin = -1 and shape = 2 - (-1) + 1 = 4, so the grid covers chunk
coordinates −1 to 2.
Each per-chunk array (for example vertices) is one Zarr array whose
shape is the chunk grid and whose Zarr chunks are single cells. Its
zarr.json includes:
{
"shape": [4, 4, 4],
"data_type": "variable_length_bytes",
"chunk_grid": {"name": "regular", "configuration": {"chunk_shape": [1, 1, 1]}},
"attributes": {
"zarr_vectors": {
"kind": "vertices",
"nonempty_chunks": ["-1.-1.-1", "-1.-1.0", "-1.-1.1", "..."],
"chunk_grid_origin": [-1, -1, -1],
...
},
...
}
}
nonempty_chunks lists the absolute coordinates of chunks that hold
data. chunk_grid_origin is present only when the origin is not all
zeros. The Zarr chunk shape [1, 1, 1] counts array cells, unlike
chunk_shape. The chunk at absolute coordinate (-1, -1, 2) is
stored at 0/vertices/c/0/0/3. Empty chunks have no file.
Each non-empty cell of each array is one stored object, at a fixed cost
per write. When a grid has more than 100,000 cells, the writer emits a
RuntimeWarning suggesting a coarser chunk_shape or
sharding. A level
chunked by attribute has extra leading axes; see
Attribute chunking.
chunk_shape is fixed for a written store. To change it, write a new
store with rechunk_spatial; see Rechunking.
Validation¶
zarr_vectors.validate checks:
Level |
Check |
Result |
|---|---|---|
1 |
The root has a |
error |
2 |
|
error |
2 |
A per-level |
error |
3 |
Every chunk of a level decodes, and each fragment has D columns |
error |
Bin checks are in Bin shape.