pub struct StatsProfile {Show 13 fields
pub total_puts: u64,
pub predicate_counts: BTreeMap<StrHash, u64>,
pub class_counts: BTreeMap<StrHash, u64>,
pub subject_cms: CountMinSketch,
pub object_cms: CountMinSketch,
pub subjects_per_predicate: BTreeMap<StrHash, HyperLogLog>,
pub objects_per_predicate: BTreeMap<StrHash, HyperLogLog>,
pub subject_domains_per_predicate: BTreeMap<StrHash, u64>,
pub object_domains_per_predicate: BTreeMap<StrHash, u64>,
pub named_graph_count: u64,
pub temporal_histogram: TickHistogram,
pub geo_cell_histogram: GeoCellHistogram,
pub text_seed_sketch: TextSeedSketch,
}Expand description
Mergeable statistical profile for one shard or the whole cluster.
§Equality caveat
The derived PartialEq / Eq compares the HLL cardinality cache maps
too. Those maps are derived state (see Self::derive_hll_domains), so two
profiles with identical sketches but different cache states compare
unequal — for example, a serde_bin round trip (empty caches) versus a
refresh_stats profile (derived caches). For “same statistics” checks,
compare the sketch/count fields or derive both sides first; do not treat a
whole-profile == across a decode/derive boundary as statistical equality.
Fields§
§total_puts: u64Approximate total Put observations in this profile.
predicate_counts: BTreeMap<StrHash, u64>Exact predicate frequencies (named-node predicates).
class_counts: BTreeMap<StrHash, u64>Exact rdf:type class instance counts (named-node classes only).
subject_cms: CountMinSketchSubject frequency CMS.
object_cms: CountMinSketchObject frequency CMS.
subjects_per_predicate: BTreeMap<StrHash, HyperLogLog>Distinct subjects per predicate (joint S–P cardinality).
objects_per_predicate: BTreeMap<StrHash, HyperLogLog>Distinct objects per predicate (joint P–O cardinality).
subject_domains_per_predicate: BTreeMap<StrHash, u64>HLL cardinality cache for Self::subjects_per_predicate:
cardinality().max(1) per sketch, materialized by
Self::derive_hll_domains at the compute boundary
(waratah_compute’s stats rollup). NOT serialized: profiles decoded
from bytes or built by hand carry empty maps, and the
Self::subject_domain / Self::object_domain helpers fall back
to computing on the fly (correct, just uncached). Cleared by
Self::merge, rollup_cluster, and
Self::capped_for_wire_with_budget — a merged or trimmed sketch is
not the sketch the cached number came from, so an inherited value
would be silently wrong. Direct mutation of
Self::subjects_per_predicate or Self::objects_per_predicate
likewise invalidates these maps; call Self::derive_hll_domains
after such edits.
object_domains_per_predicate: BTreeMap<StrHash, u64>Precomputed distinct counts for Self::objects_per_predicate —
see Self::subject_domains_per_predicate.
named_graph_count: u64Exact count of named graphs whose newest catalog version is Present.
S-axis only (named_graphs_catalog CF). P/O profiles leave this at 0.
rollup_cluster copies the S value onto the preferred axis profile.
temporal_histogram: TickHistogramSparse dyadic histogram over the temporal tick axis (postings of the
O-axis temporal_index CF). Collected on the O partition only; the
estimator consumes it for temporal_scan window row counts —
advisory, never pruning (see [crate::tick_histogram]).
geo_cell_histogram: GeoCellHistogramSparse level-11 cell-count histogram over the geo index (postings of
the O-axis geo_index CF). Collected on the O partition only; the
estimator consumes it for GeoCandidateScan covering row counts —
advisory, never pruning (see [crate::geo_cell_histogram]).
text_seed_sketch: TextSeedSketchPruned count tries over the text index’s seed fields (posting
counts of first-seed_chars and reversed last-seed_chars
characters per indexed literal). Collected on the O partition only,
at text rebuild finish, stamped with the index’s build epoch; the
text planner consumes it for candidate-drain estimates — advisory,
never pruning (see crate::text_seed_sketch::TextSeedSketch).
Implementations§
Source§impl StatsProfile
impl StatsProfile
Sourcepub fn has_predicate_sketch(&self, pattern: &EncodedTriplePattern) -> bool
pub fn has_predicate_sketch(&self, pattern: &EncodedTriplePattern) -> bool
Whether the profile carries a row sketch for pattern’s bound named
predicate — the evidence estimate_pattern consults for such a
pattern. A never-observed predicate estimates as 1 (see that
function’s doc), not unknown, so fetch-once pricing must not treat a
non-empty profile that lacks this key as evidence for the arm’s size.
A pattern without a bound named predicate prices from the store-level
uniform model (StatsProfile::total_puts), which any non-empty
profile carries.
Sourcepub fn capped_for_wire(&self) -> StatsProfile
pub fn capped_for_wire(&self) -> StatsProfile
Copy truncated to serialize within STATS_WIRE_BUDGET_BYTES.
CORE-ONLY since the frame split: the geo cell-count histogram and
the temporal histogram sections arrive EMPTY (they travel in their
own frames — see Self::capped_geo_histogram_for_wire), and the
per-predicate HLL pairs are ranked-trimmed: the LARGEST predicates
by exact count are kept first (the ranking is free —
predicate_counts is in the same profile) until the budget, and the
smallest are dropped. The estimator’s absent-entry contract makes
this safe: a dropped HLL skips the fan-out candidate and degrades the
join domain to the existing fallbacks, and because distinct counts
never exceed row counts, the single-pattern estimate can only
overestimate — bounded by the predicate’s own (small) count. Fixed
parts are always kept; SST blobs and shard merges stay
full-fidelity, so nothing here is lossy for merging — trim only at
transport boundaries.
Sourcepub fn capped_geo_histogram_for_wire(&self) -> GeoCellHistogram
pub fn capped_geo_histogram_for_wire(&self) -> GeoCellHistogram
The geo cell-count histogram trimmed for its TWO transport frames
(GetGeoHistogram): the fine map under
GEO_FINE_FRAME_BUDGET_BYTES PLUS the remainder summary under its
own GEO_REMAINDER_WIRE_BUDGET_BYTES — independent, ADDITIVE
budgets, so a saturated FINE message is 2.25 MiB (1.75 fine + 0.5
remainder); coarse under GEO_COARSE_FRAME_BUDGET_BYTES
(rank-and-keep, drop-tail reads empty — the package’s one
down-biased trim; see [GeoCellHistogram::capped_coarse_map]).
Every message stays individually under the shared 4 MiB gRPC
ceiling.
ONE canonical trim both transport sides share: the partition handlers slice the FINE / COARSE frames out of this, and the compute rollup re-trims the merged frames with the same budgets — the same double-trim discipline the core profile has always had.
Sourcepub fn capped_for_wire_with_budget(&self, budget: usize) -> StatsProfile
pub fn capped_for_wire_with_budget(&self, budget: usize) -> StatsProfile
Self::capped_for_wire under an explicit byte budget (tests).
CORE-ONLY since the frame split: the geo cell-count histogram and
the temporal histogram arrive EMPTY — they travel in their own
frames with their own budgets (see
Self::capped_geo_histogram_for_wire); the whole core budget
spends on fixed parts + CMS + exact maps + the HLL pairs.
Sourcepub fn derive_hll_domains(&mut self)
pub fn derive_hll_domains(&mut self)
Materialize the HLL cardinality cache from the sketch maps.
Cost: one HyperLogLog::cardinality per surviving sketch — bounded
by the wire cap (~3 MiB / ~8.5 KB per subject+object pair ≈ 370
predicates) regardless of dataset size, i.e. low single-digit
milliseconds once per refresh. Callers: compute’s stats rollup
(waratah_compute::query::refresh_stats), right after
Self::capped_for_wire, before the profile becomes visible to any
query — never on the query path. Self::merge, rollup_cluster,
and the cap clear the maps so a stale cardinality can never survive a
merge or trim.
Sourcepub fn subject_domain(&self, hash: &StrHash) -> Option<u64>
pub fn subject_domain(&self, hash: &StrHash) -> Option<u64>
Distinct subjects of the predicate hash, from the HLL cardinality
cache when the profile carries one, else computed on the fly.
The fallback keeps hand-built and decoded profiles (empty caches —
the maps are not serialized) correct at today’s per-call cost;
refresh-derived profiles answer from a u64 map hit. None when
the profile has no subject sketch for this predicate — identical to
the sketch maps’ own missing-entry contract.
Sourcepub fn object_domain(&self, hash: &StrHash) -> Option<u64>
pub fn object_domain(&self, hash: &StrHash) -> Option<u64>
Self::subject_domain for the objects-per-predicate sketch.
Sourcepub fn merge(&mut self, other: &StatsProfile) -> Result<(), StatsError>
pub fn merge(&mut self, other: &StatsProfile) -> Result<(), StatsError>
Algebraic merge (CMS add, HLL register-max, exact maps sum).
Sourcepub fn estimate(&self, pattern: &EncodedTriplePattern) -> u64
pub fn estimate(&self, pattern: &EncodedTriplePattern) -> u64
Estimated matches for an encoded triple pattern.
Sourcepub fn estimate_with_bound_slots(
&self,
pattern: &EncodedTriplePattern,
extra: ExtraBoundSlots,
) -> u64
pub fn estimate_with_bound_slots( &self, pattern: &EncodedTriplePattern, extra: ExtraBoundSlots, ) -> u64
Self::estimate with extra S/P/O slots treated as bound (no ground term).
Sourcepub fn join_key_domain(
&self,
pattern: &EncodedTriplePattern,
slot: JoinKeySlot,
) -> Option<u64>
pub fn join_key_domain( &self, pattern: &EncodedTriplePattern, slot: JoinKeySlot, ) -> Option<u64>
Distinct join-key domain for slot under a bound named-node predicate.
Uses subjects_per_predicate / objects_per_predicate HLL cardinality.
Trait Implementations§
Source§impl Clone for StatsProfile
impl Clone for StatsProfile
Source§fn clone(&self) -> StatsProfile
fn clone(&self) -> StatsProfile
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StatsProfile
impl Debug for StatsProfile
Source§impl Default for StatsProfile
impl Default for StatsProfile
Source§fn default() -> StatsProfile
fn default() -> StatsProfile
Source§impl From<&LiveQuadsProfile> for StatsProfile
impl From<&LiveQuadsProfile> for StatsProfile
Source§fn from(live: &LiveQuadsProfile) -> StatsProfile
fn from(live: &LiveQuadsProfile) -> StatsProfile
Source§impl From<LiveQuadsProfile> for StatsProfile
impl From<LiveQuadsProfile> for StatsProfile
Source§fn from(live: LiveQuadsProfile) -> StatsProfile
fn from(live: LiveQuadsProfile) -> StatsProfile
Source§impl PartialEq for StatsProfile
impl PartialEq for StatsProfile
impl Eq for StatsProfile
impl StructuralPartialEq for StatsProfile
Auto Trait Implementations§
impl Freeze for StatsProfile
impl RefUnwindSafe for StatsProfile
impl Send for StatsProfile
impl Sync for StatsProfile
impl Unpin for StatsProfile
impl UnsafeUnpin for StatsProfile
impl UnwindSafe for StatsProfile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].