| Title: | Harvest Byte-References of Compressed Array Data Chunks Native to HDF5-Accessible Files |
|---|---|
| Description: | Generate byte-reference stores from chunked array storage, on disk, on s3 storage or at urls. Array sources are logically mosaiced with gdal multidimensional tool 'mdim mosaic' and this is used to extract and organize raw byte references (path, offset, size) written to Parquet with semantic grouping of manually-sharded, positionally-indexed parquet reference store. The structure is a directory of parquet files, manually partitioned by variable (subdirectory) and by flat-chunk-index range ('refs.N.parq', 'record_size' rows each), with the partition keys implied positionally rather than stored as columns (i.e. _not_ hive-encoded). This is compatible with "kerchunk-parquet Zarr", and is used as an generic and intermediate convenience before generating 'icechunk' versions. |
| Authors: | Michael Sumner [aut, cre] (ORCID: <https://orcid.org/0000-0002-2471-7511>) |
| Maintainer: | Michael Sumner <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.1.9002 |
| Built: | 2026-10-15 00:45:56 UTC |
| Source: | https://github.com/hypertidy/blocklist |
virtualize_mosaic()
Pairs each source file's access path (what gdal mdim mosaic is given and
what rhdf5 opens to scan) with its public URL (what is written into the
reference store). Chunk byte offsets are identical in any byte-identical copy
of a file, so the two may differ freely: scan a cheap local or NFS path while
referencing a durable remote URL.
mosaic_sources(public, access = public)mosaic_sources(public, access = public)
public |
Character vector of durable URLs to record in the references
(e.g. |
access |
Character vector, same order as |
A data.frame with columns access and public, one row per source.
## Not run: mosaic_sources( public = c("https://host/day01.nc", "https://host/day02.nc"), access = c("/nfs/day01.nc", "/nfs/day02.nc")) ## End(Not run)## Not run: mosaic_sources( public = c("https://host/day01.nc", "https://host/day02.nc"), access = c("/nfs/day01.nc", "/nfs/day02.nc")) ## End(Not run)
Reads the logical manifest produced by gdal mdim mosaic: dimension sizes,
and for each data array its C-order dimension names, dtype, shape, GDAL block
size, CF scale/offset/nodata/unit, and the ordered list of sources
(each with SourceFilename, SourceArray, and DestSlab offset).
Coordinate arrays are returned with their composed values (from the VRT's
InlineValues or RegularlySpacedValues). No data or chunk bytes are read.
parse_mosaic_vrt(vrt)parse_mosaic_vrt(vrt)
vrt |
Path to a |
A list with dim_size (named integer vector of dimension extents),
arrays (named list of data-variable descriptions, each with dim_names,
dtype, shape, chunks, scale, offset, nodata, unit, sources),
and coords (named list with dim, dtype, values).
Opens source_array in scan_path read-only and walks its HDF5 chunk index
(h5getAllChunkInfo) to recover, per chunk, the grid coordinate (C order) and
the byte address and length of the stored, compressed data. Coordinates are
local to the source; the caller shifts them to global position using the
mosaic DestSlab offset. A non-zero filter mask on any chunk aborts with an
error - it means the chunk does not share the array-level codec and cannot be
virtualised uniformly.
scan_source_chunks(scan_path, source_array, ref_path, A, contiguous)scan_source_chunks(scan_path, source_array, ref_path, A, contiguous)
scan_path |
Path opened to read the chunk index (the source's |
source_array |
Array name within the file, e.g. |
ref_path |
Durable URL written into the |
A |
Array description from |
contiguous |
Logical; if |
A data.frame, one row per chunk: ndim integer coordinate columns
(c1..cN), offset (byte address), size (byte length), path.
End-to-end driver. Parses a gdal mdim mosaic VRT for the logical layout,
probes each array's codec and storage chunk shape once via rhdf5, scans every
source file for chunk byte references, composes them across files using the
VRT DestSlab offsets, inlines coordinate variables (values from the VRT, CF
attributes read from a source), and writes the store. The output is both a
portable reference store and the input to a VirtualiZarr -> Icechunk step.
virtualize_mosaic(vrt, root, sources, record_size = 100000L)virtualize_mosaic(vrt, root, sources, record_size = 100000L)
vrt |
Path to a VRT written by |
root |
Output directory for the store. |
sources |
A |
record_size |
Integer chunk references per parquet shard (default 1e5). |
The store root, invisibly.
mosaic_sources(), parse_mosaic_vrt(), write_kerchunk_parquet()
## Not run: src <- mosaic_sources(public = urls, access = nfs_paths) system(sprintf("gdal mdim mosaic %s mosaic.vrt", paste(src$access, collapse = " "))) virtualize_mosaic("mosaic.vrt", "oisst.zarr", sources = src) ## End(Not run)## Not run: src <- mosaic_sources(public = urls, access = nfs_paths) system(sprintf("gdal mdim mosaic %s mosaic.vrt", paste(src$access, collapse = " "))) virtualize_mosaic("mosaic.vrt", "oisst.zarr", sources = src) ## End(Not run)
LazyReferenceMapper layout (Zarr v2): a root .zmetadata
holding consolidated array/group metadata plus record_size, and a
<var>/refs.<N>.parq shard per array. Each row is either a chunk reference
(path/offset/size) or inline data (raw); rows are placed at the
C-order flat chunk index and padded to record_size. The result is readable
by VirtualiZarr (KerchunkParquetParser), the GDAL Zarr driver, and any
fsspec reference filesystem.Writes the fsspec LazyReferenceMapper layout (Zarr v2): a root .zmetadata
holding consolidated array/group metadata plus record_size, and a
<var>/refs.<N>.parq shard per array. Each row is either a chunk reference
(path/offset/size) or inline data (raw); rows are placed at the
C-order flat chunk index and padded to record_size. The result is readable
by VirtualiZarr (KerchunkParquetParser), the GDAL Zarr driver, and any
fsspec reference filesystem.
write_kerchunk_parquet( root, vars_meta, ref_tables, inline = list(), record_size = 100000L, root_attrs = list() )write_kerchunk_parquet( root, vars_meta, ref_tables, inline = list(), record_size = 100000L, root_attrs = list() )
root |
Output directory for the store (created, overwriting any existing). |
vars_meta |
Named list of per-variable metadata; each entry has |
ref_tables |
Named list (matching |
inline |
Named list of variables stored inline; each entry has |
record_size |
Integer chunk references per parquet shard (default 1e5). |
root_attrs |
Named list of group-level attributes for the root |
The store root, invisibly.