Skip to main content

Crate waratah_stats

Crate waratah_stats 

Source
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§

CountMinSketch
Count-Min Sketch over 128-bit item keys.
EstimateRangesBreakdown
Per-rung accounting of one GeoCellHistogram::estimate_ranges call — the census --window decomposition. estimate_ranges delegates to GeoCellHistogram::estimate_ranges_breakdown, so the ladder logic has one home and the report can name where an over-count sits.
ExtraBoundSlots
S/P/O slots treated as bound for costing without a ground term.
GeoCellHistogram
Sparse level-11 cell-count histogram (see the module docs).
HyperLogLog
HyperLogLog sketch (distinct-count).
LiveQuadsProfile
The write-path (open/flushing) profile of one shard: exactly the stats the canonical hexastore write stream produces.
RemainderBucket
Dropped-mass summary of one level-8 parent bucket.
ShardStats
Write-path estimate plus cached merge of live SST waratah.stats blobs.
SstInvalidationFlags
Flags set from RocksDB flush/compaction callbacks without taking a mutex.
StatsProfile
Mergeable statistical profile for one shard or the whole cluster.
TextSeedSketch
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 while epoch matches the index’s trusted epoch — a stale sketch is the unpriced path, never a stale answer.
TickHistogram
Sparse dyadic histogram over the tick axis.

Enums§

JoinKeySlot
Which unbound term slot carries a join key for HLL domain lookup.
JoinStrategy
Physical join hint chosen at plan time (Phase 9b executes broadcast/shuffle).
StatsError
Failures while serializing or parsing stats payloads.

Constants§

GEO_COARSE_FRAME_BUDGET_BYTES
The geo histogram COARSE frame’s own budget (GetGeoHistogram section 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 (GetGeoHistogram section 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_ceiling pins 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_filter allow-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^18 ticks ≈ 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_rows clamps to, the driver’s rows-per-page pacing), which is why the name still reads as a row bound — see the coupling note at JoinStrategy and 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_properties key for a serialized StatsProfile.
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_overlap degrades to exactly this value on every unknown — missing sketches, unbound predicates, the rdf:type family — 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-axis geo_index CF).
attach_stats_collector
Attach a stats collector to options (*mut rocksdb_options_t) for perm.
attach_stats_event_listener
Register an event listener that rotates open → flushing on flush begin and sets SstInvalidationFlags on flush/compaction completed.
attach_temporal_stats_collector
Attach the temporal histogram collector to options (*mut rocksdb_options_t; used for the O-axis temporal_index CF).
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 pattern from profile.
estimate_pattern_with_bound_slots
estimate_pattern with 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.stats blobs from live SSTs into one profile.
named_node_hash
Named-node IRI hash, if term is 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 profile for 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 profile to a self-describing byte blob.