pub struct TextSeedSketch {
pub epoch: u64,
pub begin: DirectionSketch,
pub end: DirectionSketch,
}Expand description
Both directions for one text index build, stamped with that build’s
epoch. A consumer (the planner’s candidate_estimate) prices from
this sketch only while epoch matches the index’s trusted epoch — a
stale sketch is the unpriced path, never a stale answer.
Fields§
§epoch: u64The build epoch this sketch was collected at; 0 = collected for an unstamped (untrusted) build and must not price.
begin: DirectionSketchForward-seed levels (the text_begin field’s populations).
end: DirectionSketchReversed trailing-seed levels (the text_end field’s).
Implementations§
Source§impl TextSeedSketch
impl TextSeedSketch
Sourcepub fn collector(seed_chars: usize) -> Self
pub fn collector(seed_chars: usize) -> Self
A collecting sketch for a build with seed_chars, no epoch yet.
Sourcepub fn prices_at(&self, index_epoch: Option<u64>) -> bool
pub fn prices_at(&self, index_epoch: Option<u64>) -> bool
Whether this sketch can price at index_epoch: trusted (non-zero
epoch) and stamped by the same build that stamped the index.
Sourcepub fn estimate_prefix(
&self,
pattern: &str,
index_epoch: Option<u64>,
) -> Option<u64>
pub fn estimate_prefix( &self, pattern: &str, index_epoch: Option<u64>, ) -> Option<u64>
Candidate population estimate for a prefix pattern. A pattern
longer than the sketch’s depth prices from its deepest stored
prefix — an upper bound on the drain’s population (the drain
resolves at the index’s full seed width), the conservative
direction for every consumer. None = this sketch must not price
(empty, untrusted, or epoch mismatch); the caller keeps its
unpriced stamp.
Sourcepub fn estimate_suffix(
&self,
pattern: &str,
index_epoch: Option<u64>,
) -> Option<u64>
pub fn estimate_suffix( &self, pattern: &str, index_epoch: Option<u64>, ) -> Option<u64>
Candidate population estimate for a suffix pattern: the pattern is
reversed first (the end direction stores reversed trailing
seeds, the same convention as the index’s text_end field — see
waratah_text_index::doc::suffix_seed_reversed).
Sourcepub fn record(&mut self, lexical: &str)
pub fn record(&mut self, lexical: &str)
Record one indexed document’s seeds (posting count 1 each; the collection loop calls this per walked document).
Sourcepub fn merge_delta(&mut self, delta: &Self)
pub fn merge_delta(&mut self, delta: &Self)
Fold a delta sketch into this one (the additive-rebuild merge): cell-wise sums, the shallower effective depth governs.
Sourcepub fn fold_delta(base: Option<Self>, delta: Self) -> Option<Self>
pub fn fold_delta(base: Option<Self>, delta: Self) -> Option<Self>
The additive-finish fold policy: merge an additive rebuild’s delta
into the surviving base sketch. A None base — the sidecar was
never written, deleted mid-write, or undecodable — folds to
None: the delta alone prices only the NEW documents, and stamping
that partial population with the fresh build epoch would present it
as trusted (an under-estimate for every pre-existing term that no
gate can catch, because the epoch looks current). The caller writes
nothing on None, leaving the store unpriced until the next full
(wipe) rebuild collects every term — the same observable state as
“never built”, including a first-ever additive rebuild on a brand
new index, which the same full rebuild heals.
Sourcepub fn merge(&mut self, other: &Self)
pub fn merge(&mut self, other: &Self)
Shard merge: cell-wise sums in both directions, the newer epoch governs the freshness gate (a shard without a sketch contributes nothing — the empty sketch is the merge identity in BOTH orders: populated ⋈ empty keeps the accumulator intact, empty ⋈ populated adopts it).
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether this sketch can price anything at all (an epoch was stamped): the empty default has none.
Sourcepub fn encode_body(&self, out: &mut Vec<u8>)
pub fn encode_body(&self, out: &mut Vec<u8>)
Encode a self-versioned section (see the geo histogram’s
encode_body for the frame convention). Fixed size by
construction; raw little-endian counters.
Sourcepub fn decode_body(buf: &mut &[u8]) -> Result<Self, StatsError>
pub fn decode_body(buf: &mut &[u8]) -> Result<Self, StatsError>
Decode a section produced by Self::encode_body; consumes
exactly its own bytes (trailing input belongs to the caller).
Trait Implementations§
Source§impl Clone for TextSeedSketch
impl Clone for TextSeedSketch
Source§fn clone(&self) -> TextSeedSketch
fn clone(&self) -> TextSeedSketch
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more