pub struct ShardStats { /* private fields */ }Expand description
Write-path estimate plus cached merge of live SST waratah.stats blobs.
open tracks the current MemTable. OnFlushBegin moves it to flushing
(the frozen MemTable still being written to SST) and zeros open. Stats
RPCs during the flush use sealed ⊕ flushing ⊕ open. OnFlushCompleted
sets SstInvalidationFlags::open_absorbed; the next reload drops
flushing, not open.
Two counts are not stored on the write-path LiveQuadsProfile at all;
each rides its own CF-keyed overlay instead, because their SST blobs are
produced by a different CF than the canonical hexastore flush the generic
rotation listens to:
StatsProfile::named_graph_count: catalog adds/drops updatecatalog_open; catalog-CFOnFlushBeginmoves that aside tocatalog_flushing.StatsProfile::temporal_histogram: posting applies/rebuilds updatetemporal_open(observe_temporal_posting); temporal-CFOnFlushBeginmoves it aside totemporal_flushing. Without its own rotation, a postings-only stretch between canonical flushes counted every posting in bothopenand the SST blob (transient 2×).
Implementations§
Source§impl ShardStats
impl ShardStats
Sourcepub fn rocksdb(flags: Arc<SstInvalidationFlags>) -> Self
pub fn rocksdb(flags: Arc<SstInvalidationFlags>) -> Self
RocksDB backend: first GetStatsProfile reloads live SST blobs.
Sourcepub fn flags(&self) -> &Arc<SstInvalidationFlags>
pub fn flags(&self) -> &Arc<SstInvalidationFlags>
Shared invalidation flags (cloned into the RocksDB event listener).
Sourcepub fn open_profile_mut(&mut self) -> &mut LiveQuadsProfile
pub fn open_profile_mut(&mut self) -> &mut LiveQuadsProfile
Mutable write-path (memtable) profile.
Sourcepub fn open_profile(&self) -> &LiveQuadsProfile
pub fn open_profile(&self) -> &LiveQuadsProfile
Borrow the write-path profile.
Sourcepub fn flushing_profile(&self) -> &LiveQuadsProfile
pub fn flushing_profile(&self) -> &LiveQuadsProfile
Frozen-MemTable aside used for stats RPCs while a flush is in progress.
Sourcepub fn exact_scan_rows(
&self,
predicate: StrHash,
class_bound: Option<StrHash>,
class_filter: Option<&[StrHash]>,
early_exit: u64,
) -> Option<u64>
pub fn exact_scan_rows( &self, predicate: StrHash, class_bound: Option<StrHash>, class_filter: Option<&[StrHash]>, early_exit: u64, ) -> Option<u64>
Exact (or safely over-estimating) row count for a pattern with a
bound named predicate — the estimate behind the scan-dispatch gate
(SCAN_DISPATCH_ROW_THRESHOLD, see PartitionService:: scan_runs_on_caller).
Sources are exact maps only: predicate_counts for the bound
predicate, and — when the predicate is rdf:type — class_counts
for one bound named class (class_bound) or an object allow-list
(class_filter, a broadcast filter’s terms). Estimates sum the
live, flushing, and sealed contributions. The maps count net
observed rows (puts minus deletes, per logical quad, across
graphs), so re-puts and un-compacted history over-count: the
result is an upper bound on the rows a scan RETURNS, not the
version keys it VISITS — a delete-heavy uncompacted prefix can
still walk far more keys than the estimate admits.
Some(n) is the tight value for ?s :p ?o shapes and an upper
bound for narrower ones (a bound S or O can only shrink the scan);
over-estimates merely keep a scan on the blocking pool, which is
the safe direction for the gate. None means no statistical basis
(nothing ever observed) — the caller always dispatches.
Absent-vs-empty semantics: with a basis present, a key absent from a NON-EMPTY exact map is an observed zero. When every source map of a kind is empty there is no basis of that kind and the coarser bound stands.
early_exit bounds the allow-list verdict, not the work: the sum
stops as soon as it exceeds early_exit (past the boundary the
verdict can no longer become “runs on the caller”), but a list
whose terms are all absent sums the whole list — up to
terms.len() × 3 BTreeMap lookups under the stats mutex.
Sourcepub fn sealed_profile(&self) -> &StatsProfile
pub fn sealed_profile(&self) -> &StatsProfile
Cached SST merge (tests).
Sourcepub fn add_named_graphs(&mut self, n: u64)
pub fn add_named_graphs(&mut self, n: u64)
Increment the in-memory Present named-graph count (new catalog put).
Sourcepub fn drop_named_graphs(&mut self, n: u64)
pub fn drop_named_graphs(&mut self, n: u64)
Decrement the in-memory Present named-graph count (Dropped catalog put).
Sourcepub fn observe_temporal_posting(&mut self, node_key: u128)
pub fn observe_temporal_posting(&mut self, node_key: u128)
Observe one temporal posting into the live overlay (Put-only by
contract, like total_puts; the collector observes only Put keys).
Sourcepub fn reset_temporal_open(&mut self)
pub fn reset_temporal_open(&mut self)
Replace the live temporal overlay with an empty cut (the rebuild’s REPLACE semantics: the walk re-derives every posting, so stale observations must not survive alongside the re-applied ones).
Sourcepub fn observe_geo_posting(&mut self, cell_id: u64)
pub fn observe_geo_posting(&mut self, cell_id: u64)
Observe one geo posting (cell id) into the live overlay. Put-only by
contract — the caller filters on the op like total_puts.
Sourcepub fn reset_geo_open(&mut self)
pub fn reset_geo_open(&mut self)
Replace the live geo overlay with an empty map (the geo rebuild wipes the index CF and re-applies every posting; stale bucket counts must not survive alongside the re-applied ones).
Sourcepub fn rotate_on_flush_begin(&mut self)
pub fn rotate_on_flush_begin(&mut self)
OnFlushBegin: move open into flushing and reset open for the new MemTable.
Overlapping canonical flushes merge into flushing rather than dropping the first aside.
Does not touch the catalog or temporal overlays — a hexastore flush must not drop
counts whose SSTs are produced by their own CFs. The rotated profiles are
LiveQuadsProfiles precisely because a canonical flush must never carry
CF-keyed counts.
Sourcepub fn rotate_catalog_on_flush_begin(&mut self)
pub fn rotate_catalog_on_flush_begin(&mut self)
Catalog-CF OnFlushBegin: move catalog_open into catalog_flushing.
Sourcepub fn rotate_temporal_on_flush_begin(&mut self)
pub fn rotate_temporal_on_flush_begin(&mut self)
Temporal-CF OnFlushBegin: move temporal_open into temporal_flushing.
Sourcepub fn rotate_geo_on_flush_begin(&mut self)
pub fn rotate_geo_on_flush_begin(&mut self)
Geo-CF OnFlushBegin: move geo_open into geo_flushing.
Sourcepub fn apply_sealed_reload(&mut self, sealed: StatsProfile)
pub fn apply_sealed_reload(&mut self, sealed: StatsProfile)
Install a freshly merged SST profile; drop overlays only if that CF’s flush absorbed them.
Sourcepub fn merged(&self) -> Result<StatsProfile, StatsError>
pub fn merged(&self) -> Result<StatsProfile, StatsError>
sealed ⊕ flushing ⊕ open, with the catalog count from SST blobs plus
catalog overlays and the temporal histogram from SST blobs plus
temporal overlays. The live layers convert into the full profile at
their overlay-identity values, which the overlay folds then replace.