Expand description
Mergeable statistics for SPARQL selectivity estimation (Phase 7 / 9a2).
Storage shards observe writes into StatsProfile sketches. On MemTable
flush a table-properties collector writes the same sketches into SST
user_collected_properties (waratah.stats). OnFlushBegin copies the
write-path overlay aside for in-progress flushes; GetStatsProfile reloads
live SST blobs when stale and drops that aside once absorbed. Compute
merges shard profiles into a local cache and reorders BGP scans without
plan-time storage RPCs.
Phase 9a2: estimate_pattern consults predicate HLL fan-out;
estimate_join_key_domain / JoinStrategy::from_cardinalities_and_domains
drive broadcast vs shuffle hints from distinct join-key sizes.
Replica roll-up: writes fan out to S/P/O, so each axis sees the same
logical quads. rollup_cluster therefore prefers a single axis profile
(O, then P, then S) rather than summing three replicas. Named-graph count
is S-axis only and is copied onto the preferred profile.
Structs§
- Count
MinSketch - Count-Min Sketch over 128-bit item keys.
- Estimate
Ranges Breakdown - Per-rung accounting of one
GeoCellHistogram::estimate_rangescall — the census--windowdecomposition.estimate_rangesdelegates toGeoCellHistogram::estimate_ranges_breakdown, so the ladder logic has one home and the report can name where an over-count sits. - Extra
Bound Slots - S/P/O slots treated as bound for costing without a ground term.
- GeoCell
Histogram - Sparse level-11 cell-count histogram (see the module docs).
- Hyper
LogLog - HyperLogLog sketch (distinct-count).
- Live
Quads Profile - The write-path (
open/flushing) profile of one shard: exactly the stats the canonical hexastore write stream produces. - Remainder
Bucket - Dropped-mass summary of one level-8 parent bucket.
- Shard
Stats - Write-path estimate plus cached merge of live SST
waratah.statsblobs. - SstInvalidation
Flags - Flags set from RocksDB flush/compaction callbacks without taking a mutex.
- Stats
Profile - Mergeable statistical profile for one shard or the whole cluster.
- Text
Seed Sketch - Both directions for one text index build, stamped with that build’s
epoch. A consumer (the planner’s
candidate_estimate) prices from this sketch only whileepochmatches the index’s trusted epoch — a stale sketch is the unpriced path, never a stale answer. - Tick
Histogram - Sparse dyadic histogram over the tick axis.
Enums§
- Join
KeySlot - Which unbound term slot carries a join key for HLL domain lookup.
- Join
Strategy - Physical join hint chosen at plan time (Phase 9b executes broadcast/shuffle).
- Stats
Error - Failures while serializing or parsing stats payloads.
Constants§
- GEO_
COARSE_ FRAME_ BUDGET_ BYTES - The geo histogram COARSE frame’s own budget (
GetGeoHistogramsection COARSE: the native-id count-once map, levels 0–8 post-2026-10). At 12 bytes per kept entry this buys ~149k coarse postings — an order of headroom over the census-measured population (~40k entries on bellendena-geo-10m, levels 0–8 inclusive). Over budget the map rank-keeps (count descending, id ascending) and the dropped tail reads EMPTY — the ONE down-biased trim in the package; see [GeoCellHistogram::capped_coarse_map] for the caveat and the coarse-side-summary escape hatch if a corpus ever saturates this. - GEO_
COARSE_ WIRE_ ENTRY_ BYTES - Wire size of one kept coarse entry: native u64 cell id + u64 count.
- GEO_
FINE_ FRAME_ BUDGET_ BYTES - The geo histogram FINE frame’s budget for its fine map (
GetGeoHistogramsection FINE). At 8 bytes per kept entry this buys ~229k buckets; heavier occupancy degrades through the remainder summary (parent averages), not through missing estimates. The remainder summary rides the SAME message under its OWN budget (GEO_REMAINDER_WIRE_BUDGET_BYTES) — the two budgets are INDEPENDENT and ADDITIVE, so a saturated FINE message is 1.75 MiB + 512 KiB = 2.25 MiB (an earlier “remainder carved inside / 3.5 MiB total” reading was wrong;geo_frames_at_saturation_stay_under_the_message_ceilingpins the real bound). Every message stays individually under the shared 4 MiB gRPC ceiling: worst case across the stat messages is FINE 2.25 MiB, COARSE 1.75 MiB, core 3 MiB, temporal ~100 KiB. - GEO_
FINE_ WIRE_ ENTRY_ BYTES - Wire size of one kept fine entry: a packed
u64(bucket << 32 | count). - GEO_
REMAINDER_ WIRE_ BUDGET_ BYTES - Budget for the geo histogram’s remainder summary — the per-L8-parent
dropped-mass entries. INDEPENDENT of and ADDITIVE to the fine-map
budget:
capped_for_wire(fine, remainder)enforces each separately, so a saturated FINE frame carries 1.75 MiB of fine map PLUS up to 512 KiB of remainder (2.25 MiB total, still under the 4 MiB per-message gRPC ceiling). The remainder’s key space is the FULL L8 parent grid (6 × 4^8 = 393,216 ≈ 6.3 MB untrimmed at global density), so it obeys the same rank-and-keep discipline as the fine map: largest-total parents first, and beyond this budget the smallest-mass parents are dropped and read EMPTY — a bounded under-estimate on the advisory path (§10: estimates order plans, never prune; SPARQL results are unaffected). - GEO_
REMAINDER_ WIRE_ ENTRY_ BYTES - Wire size of one remainder entry: u32 parent + u64 total + u32 cells.
- GRAPH_
FILTER_ TERM_ CAP - Maximum encoded graphs in a scan
graph_filterallow-list. - MAX_
BUCKETS - Maximum buckets in one cut (memory + wire budget).
- MAX_
REFINE_ LEVEL - Bucket width floor: finest allowed bucket level (width
2^(128-110) ≈ 2^18ticks ≈ 0.26 picoseconds). - PUSHDOWN_
TERMS_ LIMIT - The wire/terms limit of the pushdown family: the maximum number of
distinct terms one broadcast allow-list may carry in a single request
or admission decision. Historically this doubled as the driver page
cut (the eager left-chunk size
driver_chunk_rowsclamps to, the driver’s rows-per-page pacing), which is why the name still reads as a row bound — see the coupling note atJoinStrategyand the sites that share the value. - SPLIT_
THRESHOLD - Postings observed in one bucket before it splits into its two halves.
- STATS_
USER_ PROPERTY_ KEY - SST
user_collected_propertieskey for a serializedStatsProfile. - STATS_
WIRE_ BUDGET_ BYTES - Serialized-size ceiling for one profile crossing the wire
(
GetStatsProfile), with headroom under the 4 MiB gRPC message limit for response framing. - TEXT_
SEED_ SKETCH_ DEPTH - Prefix depths per direction. The sketch’s depth must not exceed the
index’s
seed_chars(enforced by carrying the build’s effective depth in the section and capping inserts and queries at it) so an estimate is always an upper bound on the drain the index can actually resolve. - TEXT_
SEED_ SKETCH_ ROWS - Hash rows per level (the CMS depth
d; failure probability per point query ≈ e^−d, and the min over levels compounds it further). - TEXT_
SEED_ SKETCH_ WIDTH - Counters per row (the CMS width
w; additive error ≈ inserts/w). Landed so both directions fit one gRPC frame under tonic’s default 4 MiB decode limit: 2 × 8 × 3 × 19,000 × 4 B = 3,648,000. - VOCABULARY_
OVERLAP_ FULL_ MILLI - The milli scale for vocabulary containment: 1000 = full overlap, so a
consumer passing this constant reduces every containment-aware formula
to its pre-containment (count-only) form.
estimate_vocabulary_overlapdegrades to exactly this value on every unknown — missing sketches, unbound predicates, therdf:typefamily — which is what makes the feature regression-free by construction.
Functions§
- attach_
catalog_ stats_ collector - Attach a named-graph catalog stats collector to
options(*mut rocksdb_options_t). - attach_
geo_ stats_ collector - Attach the geo cell-count collector to
options(*mut rocksdb_options_t; used for the O-axisgeo_indexCF). - attach_
stats_ collector - Attach a stats collector to
options(*mut rocksdb_options_t) forperm. - attach_
stats_ event_ listener - Register an event listener that rotates
open→flushingon flush begin and setsSstInvalidationFlagson flush/compaction completed. - attach_
temporal_ stats_ collector - Attach the temporal histogram collector to
options(*mut rocksdb_options_t; used for the O-axistemporal_indexCF). - bound_
slots - Bound-slot count — fallback when the profile is empty.
- estimate_
join_ key_ domain - Distinct-value domain for a join variable in
slot, from predicate HLLs. - estimate_
join_ rows - Equijoin intermediate cardinality from row counts and optional key domains.
- estimate_
join_ rows_ multi - Multi-key equijoin intermediate cardinality:
|L| · |R| / Π_v max(dom_L(v), dom_R(v))over the join keys, assuming key independence. - estimate_
pattern - Selectivity estimate for
patternfromprofile. - estimate_
pattern_ with_ bound_ slots estimate_patternwith extra S/P/O slots treated as bound without a term.- estimate_
vocabulary_ overlap - Vocabulary containment between the two arms of one join key, milli-scaled
|A ∩ B| / |A|(A = the driver arm’s key vocabulary, B = the probe arm’s). - from_
bytes - Parse a blob produced by
to_bytes. - merge_
sst_ property_ blobs - Merge
waratah.statsblobs from live SSTs into one profile. - named_
node_ hash - Named-node IRI hash, if
termis a named node. - observe_
catalog_ sst_ key - Count a catalog CF version if it is the newest for its graph in this SST.
- observe_
quad - Update
profilefor one versioned write. - pattern_
is_ point_ lookup - Whether S, P, O, and G are all ground (at most one visible quad).
- rollup_
cluster - Roll shard profiles into one cluster profile.
- term_
key - Stable 128-bit frequency key for an encoded term (SipHash of wire bytes).
- to_
bytes - Serialize
profileto a self-describing byte blob.