Skip to content

Add shared raster storage, RF tools, and envelope content hashes - #40

Open
adam-ce wants to merge 92 commits into
AlpineMapsOrg:mainfrom
adam-ce:main
Open

adam-ce wants to merge 92 commits into
AlpineMapsOrg:mainfrom
adam-ce:main

Conversation

@adam-ce

@adam-ce adam-ce commented Sep 30, 2026

Copy link
Copy Markdown
Member

This adds persistent raster storage and tools to import, merge, and inspect attributed raster snapshots, while moving existing SF and DAG applications onto a shared storage foundation.

  • Extract shared hierarchy indices, runtime layouts and codecs, storage access, and compressed envelopes; migrate existing applications and strengthen storage validation and concurrent access.
  • Add rf-builder for GDAL datasets and online tiles, with attribution and validity handling, NoData filling, parallel preparation, reusable caches, checkpoints, cancellation, and progress reporting.
  • Add raster views, composable pixel algorithms, validity-aware resampling, and tile halo extraction; share image I/O and export RF previews with rf-tile2image.
  • Add rf-merger with attribution priorities, topology-based output partitioning, halo-aware upscaling, hard-link reuse, recovery, and per-category statistics.
  • Add XXH3-64 envelope payload hashes, bounded header-only reads, and hash-based merger input fingerprints; standardize byte buffers on std::byte.
  • Unify error propagation, add stack traces and exception helpers, and document the three-tier error convention. Extend regression coverage, CI RF suites, and sanitizer configuration.

Compatibility: the new envelope magic and renumbered hash/compression fields make envelopes written before this change unreadable; existing envelope-backed data must be regenerated.

Validation: repository status documents record Linux GCC Debug builds and all CI suites passing for the envelope-hash implementation, plus focused RF merger and sanitizer checks. The five GitHub Actions jobs for the current head are still running. No new build was run while preparing this PR; the latest history cleanup changed only commit messages, with every rewritten commit's file tree and merge structure verified unchanged.

adam-ce added 30 commits August 14, 2026 15:44
# Conflicts:
#	src/sf_merger/cut.h
#	src/sf_merger/main.cpp
#	unittests/sf_merger/mask.cpp
Partition merger output from input index topology alone, so production
reads each supplier once and never downscales. Define recovery
fingerprints, require matching output codecs, add an optional
compression setting, and report per-category output statistics that
are checkpointed for recovery. Prepare resampled suppliers with the
halo reader.
Add rf-merger, which merges two published RF snapshots by attribution
priority. The output partition follows both input indices, coarse
suppliers are upscaled with the shared halo reader and paired scaler,
and unchanged tiles are hard-linked. Checkpoints record per-category
statistics for recovery and the final report.

Move TilePool to raster_store so the RF builder and merger share it,
and run the merger suite in CI.
Error records a stack trace where it is made and gains Error::Exception,
raise, throwing_unwrap and asserting_unwrap. The code style now separates
bugs (assertions), recoverable failures (Expected, including all of
terrainlib) and unrecoverable failures in tools (exceptions).

rf-merger throws for invalid input and production failures, asserts bug-only
results, and keeps Expected in its reusable functions. Preflight rejects
sRGB on scalar payloads and zoom gaps above 30 levels. A statistics guard
keeps a failed merge recoverable, and cancellation saves active tiles before
throwing Cancelled. The priority list is parsed with CPLJSON.
Add rf-merger with topology partitioning, statistics and recovery, share TilePool between the RF builder and merger, and add Error exceptions, stack traces and unwrap helpers.
Envelopes get a new magic and a Header with a binary hash of the
uncompressed payload, verified on read. Hash and compression enumerators
are renumbered from zero: hash::Algorithm { None, Xxh3_64 } and
CompressionAlgorithm { None, ZstdBestCompression, ZstdDefaultCompression }.
CRC-32C and the Zstandard frame-checksum variants are removed, and Xxh3_64
with ZstdDefaultCompression is the default for every envelope writer.

io/hash.h provides hash::data over byte spans; only io/hash.cpp includes
the vendored xxHash v0.8.3. io/compression.h only compresses and
decompresses. read_header decodes a header from a file prefix of at most
222 bytes without reading the payload; class names are limited to 128
bytes and hashes to 64. Invalid enumerators from files are Unsupported,
and invalid ones passed by callers PANIC.

The RF merger fingerprints its inputs with the header hashes of their
metadata and index files and has no checksum option. Byte buffers of file
I/O, image encoding and decoding and the RF builder HTTP client are
std::byte. ADR 0005 records the decision and the measured 18.3 GB/s.
Hash envelope payloads with XXH3-64, expose envelope headers without reading the payload, fingerprint RF merger inputs with the header hashes, and switch byte buffers to std::byte.
…wn bespoke reader

- merger doesn't need downscaling,
- tb builder needs reading the already the generated level from below (tb) and the rf source
  (if reading ancestors/same level)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant