Skip to main content

Module zarrstore

Module zarrstore 

Source
Available on crate feature encoder only.
Expand description

Xue bundles as Zarr v3 stores, written straight from their codes.

Two layouts, both normative in docs/zarr-profile.md, and both mirroring xuebuild/zarrstore.py, the reference, byte for byte. A shared store (profile 2, bundles[.<tier>].zarr) holds every bundle of one resolution tier: write_bundle_arrays writes one bundle’s arrays and the coordinates its dimension names name into it, write_part the partial group document over the bundles one build wrote. The store’s zarr.json itself is never written here: the reference’s finalize_store merges the parts into it, so the group document has one implementation. A one-bundle store (profile 1, write_store) is what a series store is.

Documents are serialized the way Python’s json.dumps(..., indent=2, ensure_ascii=False) does, plus a trailing newline; inner chunks are padded and compressed by the same one-shot zstd call, with the same shard index and CRC-32C. A bundle’s arrays are a function of its metadata, its codes, its tile, each variable’s predictor and its dimension names, so nothing here reads a container. Every chunk is decompressed again right after it is compressed and compared with what went in, and every document written is parsed back by the decoder’s own store validators (crate::zarr), the store’s counterpart of the container’s full read-back.

Structs§

BundleWrite
One bundle written into a shared store (BundleWrite in the reference).
StoreCodes
A bundle’s codes as the writer reads them.
StoreReport
What one store write produced: the manifest descriptor’s three values plus the report fields ExportReport.to_dict carries.
StoreVariable
One variable’s codes: its planes in axis order, each width * height.
WidePlanes
Sixteen-bit planes held in memory, in axis order.
WideVariable
One widened variable of a series store: its codes, by the id its StoreVariable (whose byte planes are then empty) names.

Constants§

DIMENSIONS
The primary dimension names, which are also the store’s primary coordinate arrays.
PART_PREFIX
File name prefix of a partial group document inside a shared store (zarr.part.<first bundle id>.json).
SERIES_BLOCK
The spatial block of a series store, (width, height).
SHARED_PROFILE_VERSION
The xue_profile of a shared store (bundles[.<tier>].zarr).
SHARED_STORE_STEM
The reserved stem of a shared store; no bundle may be named it.
TIME_CHUNK
Frames per time chunk of a map store: the bundle’s own group length, on a regular grid.
ZSTD_LEVEL
The inner chunks’ zstd level, which the array documents declare.

Traits§

WideCodes
A widened variable’s sixteen-bit codes, which a series store reads a band of rows at a time rather than holding the whole axis: planes in memory (WidePlanes), or a build’s spool on disk.

Functions§

code_data_type
A code array’s data_type: uint16 exactly when the codebook’s nodata code does not fit a byte, which only a series codebook’s does (docs/zarr-profile.md, “Series store”); uint8 otherwise. The reference’s code_data_type.
compression_pool
The compression pool a caller outside the crate hands to write_store.
group_document
A shared store’s group document over bundles, in manifest order (group_document in the reference).
is_coordinate_suffix
^[a-z][a-z0-9]*$: a bundle id, and the suffix of a coordinate named for a grid family.
part_path
<store>/zarr.part.<first bundle id>.json: a build’s bundles are disjoint from every other build’s of the same run, so the first one names the part uniquely.
series_metadata
A series store’s metadata: the bundle’s, with each variable named in quantizations holding that block as its quantization, the codes the store holds for it. The key keeps its place, so everything else, key order included, is the bundle’s, and a series store with no widened variable carries the bundle’s metadata exactly. The reference’s series_metadata.
shared_store_name
bundles.zarr for the full tier, bundles.<tier>.zarr for a rung of the resolution ladder.
write_bundle_arrays
Write one bundle’s variable arrays and the coordinate arrays its dimensions name into the shared store store, which is created if absent and otherwise left as it is: other bundles’ arrays, written before or concurrently, stay. The group document is not touched.
write_part
The partial group document over the bundles one build wrote into store, in manifest order: group_document over them alone, at part_path of the first. Returns its path and its CRC-32, which the build’s entries carry until the reference’s finalize_store writes the store’s group document from the parts.
write_store
Write one bundle’s store at store (replaced whole). series cuts the series layout over that block instead of the map layout; delta puts xue.delta in front of bytes on every previous-predicted variable.
write_store_widened
write_store for a series store whose wide variables hold sixteen-bit codes: the metadata names their series codebooks (series_metadata), their StoreVariables carry no byte planes, and their arrays are uint16.