Skip to main content

TextSeedSketch

Struct TextSeedSketch 

Source
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: u64

The build epoch this sketch was collected at; 0 = collected for an unstamped (untrusted) build and must not price.

§begin: DirectionSketch

Forward-seed levels (the text_begin field’s populations).

§end: DirectionSketch

Reversed trailing-seed levels (the text_end field’s).

Implementations§

Source§

impl TextSeedSketch

Source

pub fn empty() -> Self

The empty sketch (no levels, no epoch): prices nothing.

Source

pub fn collector(seed_chars: usize) -> Self

A collecting sketch for a build with seed_chars, no epoch yet.

Source

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.

Source

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.

Source

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

Source

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

Source

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.

Source

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.

Source

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

Source

pub fn is_empty(&self) -> bool

Whether this sketch can price anything at all (an epoch was stamped): the empty default has none.

Source

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.

Source

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

Source§

fn clone(&self) -> TextSeedSketch

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TextSeedSketch

Source§

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

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

impl Default for TextSeedSketch

Source§

fn default() -> Self

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

impl PartialEq for TextSeedSketch

Source§

fn eq(&self, other: &TextSeedSketch) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for TextSeedSketch

Source§

impl StructuralPartialEq for TextSeedSketch

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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,