pub struct SampledStatistics { /* private fields */ }Expand description
Approximate statistics computed from a random sample of the triple store.
Useful for large graphs where computing exact statistics is too expensive.
Uses reservoir sampling semantics — the caller feeds triples and the structure
maintains a representative sample of size sample_size.
Implementations§
Source§impl SampledStatistics
impl SampledStatistics
Sourcepub fn new(sample_size: usize) -> Self
pub fn new(sample_size: usize) -> Self
Create a new sampler that will keep at most sample_size triples.
Sourcepub fn observe(&mut self, subject: &str, predicate: &str, object: &str)
pub fn observe(&mut self, subject: &str, predicate: &str, object: &str)
Feed a triple to the sampler. Uses reservoir sampling to decide whether to keep it.
Because true reservoir sampling requires a PRNG, this implementation uses a deterministic hash-based pseudo-random selection so that tests are reproducible without an external RNG.
Sourcepub fn total_seen(&self) -> u64
pub fn total_seen(&self) -> u64
Number of triples seen so far (population size).
Sourcepub fn sample_size(&self) -> usize
pub fn sample_size(&self) -> usize
Number of triples in the sample.
Sourcepub fn estimated_total(&self) -> u64
pub fn estimated_total(&self) -> u64
Estimated total triples (same as total_seen, since each observe is one triple).
Sourcepub fn estimated_distinct_predicates(&self) -> u64
pub fn estimated_distinct_predicates(&self) -> u64
Estimated number of distinct predicates, extrapolated from the sample.
Sourcepub fn estimate_cardinality(
&self,
subject: Option<&str>,
predicate: Option<&str>,
object: Option<&str>,
) -> u64
pub fn estimate_cardinality( &self, subject: Option<&str>, predicate: Option<&str>, object: Option<&str>, ) -> u64
Estimated cardinality for a triple pattern using sample-based selectivity.
Sourcepub fn graph_stats(&self) -> &GraphStatistics
pub fn graph_stats(&self) -> &GraphStatistics
Access the underlying sample-based GraphStatistics.
Trait Implementations§
Source§impl Clone for SampledStatistics
impl Clone for SampledStatistics
Source§fn clone(&self) -> SampledStatistics
fn clone(&self) -> SampledStatistics
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SampledStatistics
impl RefUnwindSafe for SampledStatistics
impl Send for SampledStatistics
impl Sync for SampledStatistics
impl Unpin for SampledStatistics
impl UnsafeUnpin for SampledStatistics
impl UnwindSafe for SampledStatistics
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more