Skip to main content

ShardStats

Struct ShardStats 

Source
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 update catalog_open; catalog-CF OnFlushBegin moves that aside to catalog_flushing.
  • StatsProfile::temporal_histogram: posting applies/rebuilds update temporal_open (observe_temporal_posting); temporal-CF OnFlushBegin moves it aside to temporal_flushing. Without its own rotation, a postings-only stretch between canonical flushes counted every posting in both open and the SST blob (transient 2×).

Implementations§

Source§

impl ShardStats

Source

pub fn memory() -> Self

Memory backend: open is the whole profile; SST flags stay clear.

Source

pub fn rocksdb(flags: Arc<SstInvalidationFlags>) -> Self

RocksDB backend: first GetStatsProfile reloads live SST blobs.

Source

pub fn flags(&self) -> &Arc<SstInvalidationFlags>

Shared invalidation flags (cloned into the RocksDB event listener).

Source

pub fn open_profile_mut(&mut self) -> &mut LiveQuadsProfile

Mutable write-path (memtable) profile.

Source

pub fn open_profile(&self) -> &LiveQuadsProfile

Borrow the write-path profile.

Source

pub fn flushing_profile(&self) -> &LiveQuadsProfile

Frozen-MemTable aside used for stats RPCs while a flush is in progress.

Source

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.

Source

pub fn sealed_profile(&self) -> &StatsProfile

Cached SST merge (tests).

Source

pub fn add_named_graphs(&mut self, n: u64)

Increment the in-memory Present named-graph count (new catalog put).

Source

pub fn drop_named_graphs(&mut self, n: u64)

Decrement the in-memory Present named-graph count (Dropped catalog put).

Source

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).

Source

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).

Source

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.

Source

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).

Source

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.

Source

pub fn rotate_catalog_on_flush_begin(&mut self)

Catalog-CF OnFlushBegin: move catalog_open into catalog_flushing.

Source

pub fn rotate_temporal_on_flush_begin(&mut self)

Temporal-CF OnFlushBegin: move temporal_open into temporal_flushing.

Source

pub fn rotate_geo_on_flush_begin(&mut self)

Geo-CF OnFlushBegin: move geo_open into geo_flushing.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for ShardStats

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ShardStats

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,