|
libzarr
Header-only C++17 Zarr v2/v3, WASM-compatible
|
Classes | |
| struct | Extent |
| struct | Placement |
Functions | |
| Placement | place (const ArrayMeta &meta, const std::string &path, const std::vector< std::uint64_t > &inner_index, std::size_t level=0) |
| Extent | extent (const ArrayMeta &meta, const Bytes &index_bytes, std::uint64_t slot, std::size_t level=0) |
| Bytes | pack (const ArrayMeta &meta, const std::vector< std::optional< Bytes > > &entries, std::size_t level=0) |
Pure shard-index resolution for consumers that own their own I/O (e.g. a browser fetching HTTP ranges). No Store, no fetch loop: the caller drives a two-phase handshake — resolve the shard and where its index sits, fetch that index, then resolve the chunk's extent — so the drift-prone index math stays in libzarr while the fetches stay in the consumer. A complete pure-sync read is place() -> fetch index bytes -> extent() -> fetch chunk bytes -> CodecPipeline::resolve(meta).decode(bytes).
|
inline |
Decodes index_bytes (the Placement::index_size bytes the caller fetched at the index location) and returns slot slot's extent. level must match the place() call. Pure: no I/O. Throws on a malformed or wrong-size index.
|
inline |
Assembles the shard object for shard level (0 = outermost) from its slot-ordered inner chunks. entries[i] is the ENCODED bytes of the chunk at C-order slot i, or std::nullopt for a fill slot (whose index entry becomes the sentinel). Returns the shard bytes — concatenated chunk bodies plus the checksummed [offset, nbytes] index, laid out per the level's index_location — or an empty buffer if every slot is absent (an all-fill shard is not written; the caller simply skips or erases that key). Pure: no I/O. The inverse of extent(): pack() then extent() round-trips each slot's extent. Throws if level is not a shard level or entries.size() != the shard's slot count.
|
inline |
Resolves which shard holds inner chunk inner_index (an inner-chunk grid coordinate) for the array at path ("" = store root). level selects the shard level (0 = outermost) for nested sharding. Pure: reads only meta. Throws if level is not a shard level or inner_index is out of range.