Skip to main content

Module geo

Module geo 

Source
Expand description

waratah geo rebuild-index: recompute O-axis S2 postings from blobs.

Same class as waratah catalog rebuild but a different algorithm: the old covering must be wiped (Delete every posting of each term), not merged — catalog rebuild only inserts missing Present rows and is the wrong template for that part. Points are re-emitted at the same leaf cell (no blob); geometries re-cover under the current process coverer config. The O partition never runs the coverer and never opens blobs — this command is compute/offline-side by construction.

§Rebuild contract

  • Term collection is a HashMap keyed by the hash of the canonical term bytes (the same term identity waratah_storage::geo_lexical_key uses). Only the object slot is inspected: on the O axis, predicates are always IRIs and literals can never be subjects or graph names, so the other three slot checks can never match a geo term.
  • Per-quad liveness: inside each term’s entry the walk records the newest version row per REFERENCING QUAD (versions of one logical quad arrive contiguous in descending-commit_ts order in the scan, so the max-ts row is the quad’s latest version; keeping the max-ts entry is order-robust across permutations, which duplicate rdf:type quads at equal timestamps). A term is re-indexed when ANY quad referencing it has its own-latest version = a Put — deleting one quad that shares a literal with other live quads must not retract the term. The whole postings CF is wiped in ONE pass (wipe_geo_index) and only the live terms re-posted: the write path never mirrors deletes to the postings (waratah_compute/src/fanout.rs sends none on delete batches — the index stays a conservative superset at every snapshot), so a fully-dead term can still carry stale Put postings and this rebuild IS the garbage collector over them — including postings whose term no longer appears in the hexastore at all, which the per-term wipe this replaced could never see.
  • Epoch stamping: every rebuilt posting is stamped with commit_ts = epoch, where epoch = max commit_ts over the geo-contributing version rows seen by the scan — equal, never +1. The epoch derives from the data being indexed, never from the existing index (which is absent on first rebuild and untrusted afterwards). Zero geo terms found → epoch 0: the index is empty and incrementally maintained from then on, valid for every snapshot. Postings stamped at the epoch become visible exactly when the planner starts trusting the index (waratah_geo/src/plan.rs rewrites the geof:* FILTER only for snapshots ≥ the persisted epoch).
  • Persistence: the epoch is stored on the O partition (Storage::set_geo_index_epoch, geo_index_meta CF) together with its LIVENESS marker, and both reach compute through the hexastore Describe payload. This CLI stamps via the same setter the cluster rebuild’s finish uses, so the two cannot diverge.

Caveat: deriving the epoch from scanned data timestamps means a future-pinned import --timestamp above the wall clock can stamp an epoch above later online writes, so rebuilt postings sit below the planner trust gate (residual custom-fn answers) until the data clock catches up. The systemic fix (a monotonic cluster ts watermark) is out of scope here and is a pre-existing gap for all offline writes.

Remaining exposure: none from the wipe — this CLI wipes the whole postings CF in ONE pass (wipe_geo_index, the same primitive the cluster rebuild’s begin_geo_rebuild uses), and the LIVENESS marker drops in that same atomic batch, so an interrupted run reads UNTRUSTED instead of trusted-with-a-partial-index (the pre-2026-10-27 hole, when the CLI wiped per term and the marker survived).

Structs§

LevelTally 🔒
Per-level tallies of the census walk.
PostingCensus 🔒
Read-only census of one O-axis geo posting store, folded from decoded rows in walk (key) order. Answers the window-estimate decomposition questions at the source: which S2 levels the coverer actually produced, how much L9–L10 expansion mass the stats histogram carries, how large the envelope-bearing (AABB-skippable) population is, and the cells-per-term multiplicity the drain’s distinct seen-set collapses.
TermVersions 🔒
Per-term aggregation for the rebuild walk: the canonical term plus the newest version row seen for each referencing quad. The term is alive iff ANY of those per-quad latest versions is a Put.
WindowState 🔒
--window mode state: the postings-derived histogram (exact — the collector’s own observe_posting classification, no wire trims and no remainder) plus the drain-truth accounting against the window’s cell-id intervals.

Constants§

ORPHAN_LEXICAL_PREVIEW_BYTES 🔒

Functions§

census
waratah geo census: read-only per-level census of the O-axis S2 posting store ({data_dir}/main/o). The diagnostic behind geo window estimate over-counting: the level distribution the coverer actually produced, the L9–L10 expansion mass (the only expanding levels since the 2026-10 floor move — L8 and below ride the count-once coarse map), the envelope-bearing population, and cells-per-term multiplicity — all from the postings themselves, not the rolled-up profile.
configure_proj_env
Point PROJ at the vendored data tree and disable the network.
decode_identity_slot 🔒
Decode one encoded-term byte run from a quad identity triple. The default graph encodes to ZERO bytes (as in the storage keys).
format_orphan_error 🔒
Format a rebuild failure with enough information to locate the offending quad without embedding an arbitrarily large literal in the error.
geo_datatype_hashes 🔒
The two geo datatype hashes (the orphan-typed-literal discovery set — the same literals the write plugin would have encoded natively had it been enabled at ingest).
is_geo_term 🔒
is_orphan_geo_typed_literal 🔒
proj_data_dir
Where the vendored proj-data tree lives next to the binary / in-repo.
quad_identity 🔒
Quad identity inside one term’s aggregation: the encoded subject, predicate, and graph bytes (the object IS the aggregated term).
rebuild
Wipe and rebuild every geo posting under the current coverer config, upgrading orphaned typed literals (ingested while the plugin was disabled) to native terms across all three axis stores.
reindex_term 🔒
Rebuild postings for one NATIVE term via the shared core; geometries read their canonical CRS84 EWKB from the blob store.
resolve_orphan_lexical 🔒
Resolve an orphaned typed literal’s lexical form (inline for SmallTypedLiteral, the string registry for BigTypedLiteral).
status 🔒