Skip to main content

waratah_stats/
lib.rs

1//! Mergeable statistics for SPARQL selectivity estimation (Phase 7 / 9a2).
2//!
3//! Storage shards observe writes into [`StatsProfile`] sketches. On MemTable
4//! flush a table-properties collector writes the same sketches into SST
5//! `user_collected_properties` (`waratah.stats`). `OnFlushBegin` copies the
6//! write-path overlay aside for in-progress flushes; `GetStatsProfile` reloads
7//! live SST blobs when stale and drops that aside once absorbed. Compute
8//! merges shard profiles into a local cache and reorders BGP scans without
9//! plan-time storage RPCs.
10//!
11//! Phase 9a2: [`estimate_pattern`] consults predicate HLL fan-out;
12//! [`estimate_join_key_domain`] / [`JoinStrategy::from_cardinalities_and_domains`]
13//! drive broadcast vs shuffle hints from distinct join-key sizes.
14//!
15//! **Replica roll-up:** writes fan out to S/P/O, so each axis sees the same
16//! logical quads. [`rollup_cluster`] therefore prefers a single axis profile
17//! (O, then P, then S) rather than summing three replicas. Named-graph count
18//! is S-axis only and is copied onto the preferred profile.
19
20#![deny(unused_must_use)]
21#![warn(missing_docs)]
22
23mod cms;
24mod error;
25mod geo_cell_histogram;
26mod hll;
27mod observe;
28mod profile;
29mod serde_bin;
30mod shard;
31mod sst;
32mod text_seed_sketch;
33mod tick_histogram;
34
35pub use cms::CountMinSketch;
36pub use error::StatsError;
37pub use geo_cell_histogram::{
38    EstimateRangesBreakdown, GEO_COARSE_WIRE_ENTRY_BYTES, GEO_FINE_WIRE_ENTRY_BYTES,
39    GEO_REMAINDER_WIRE_ENTRY_BYTES, GeoCellHistogram, RemainderBucket,
40};
41pub use hll::HyperLogLog;
42pub use observe::{named_node_hash, observe_catalog_sst_key, observe_quad, term_key};
43pub use profile::{
44    ExtraBoundSlots, GEO_COARSE_FRAME_BUDGET_BYTES, GEO_FINE_FRAME_BUDGET_BYTES,
45    GEO_REMAINDER_WIRE_BUDGET_BYTES, GRAPH_FILTER_TERM_CAP, JoinKeySlot, JoinStrategy,
46    LiveQuadsProfile, PUSHDOWN_TERMS_LIMIT, STATS_WIRE_BUDGET_BYTES, StatsProfile,
47    VOCABULARY_OVERLAP_FULL_MILLI, bound_slots, estimate_join_key_domain, estimate_join_rows,
48    estimate_join_rows_multi, estimate_pattern, estimate_pattern_with_bound_slots,
49    estimate_vocabulary_overlap, pattern_is_point_lookup, rollup_cluster,
50};
51pub use serde_bin::{from_bytes, to_bytes};
52pub use shard::{
53    STATS_USER_PROPERTY_KEY, ShardStats, SstInvalidationFlags, merge_sst_property_blobs,
54};
55pub use sst::{
56    attach_catalog_stats_collector, attach_geo_stats_collector, attach_stats_collector,
57    attach_stats_event_listener, attach_temporal_stats_collector,
58};
59pub use text_seed_sketch::{
60    TEXT_SEED_SKETCH_DEPTH, TEXT_SEED_SKETCH_ROWS, TEXT_SEED_SKETCH_WIDTH, TextSeedSketch,
61};
62pub use tick_histogram::{MAX_BUCKETS, MAX_REFINE_LEVEL, SPLIT_THRESHOLD, TickHistogram};