Skip to main content

LexicalIndex

Struct LexicalIndex 

Source
pub struct LexicalIndex { /* private fields */ }
Expand description

The store-wide lexical index across every segment.

§Segments here are SEALED

push_segment encodes the active segment into the persisted posting layout and keeps only that. There is therefore exactly one scoring path in the engine — over bytes — rather than an in-memory one that ships and a persisted one that is only ever tested.

Implementations§

Source§

impl LexicalIndex

Source

pub fn new() -> Self

Creates an empty index.

Source

pub fn push_segment(&mut self, segment: SegmentIndex) -> Result<(), IndexError>

Seals one active segment and appends it.

§Errors

Returns IndexError::Postings when the encoder rejects the segment’s geometry or refuses to read back what it just wrote. Both are broken-writer conditions, and they surface here rather than becoming a decode fault inside a later query.

Source

pub fn push_sealed(&mut self, segment: SealedSegment)

Appends an already-sealed segment.

Source

pub fn push_sealed_with_live_rows( &mut self, segment: SealedSegment, live_rows: &DocBitmap, ) -> Result<(), IndexError>

Appends an already-sealed segment with exact live-row counters.

The row set is the segment tombstone state’s live bitmap, not a query filter. Capturing it here keeps BM25 corpus statistics independent of later metadata allow-lists while avoiding any posting-list rewrite.

§Errors

Returns IndexError::LiveRowOutOfRange when the tombstone state names a row outside the sealed segment, or IndexError::LiveLengthMissing when a sealed length counter violates its dense-row invariant.

Source

pub fn segments(&self) -> &[Arc<SealedSegment>]

Returns the segments in seal order.

Source

pub fn terms(&self) -> impl Iterator<Item = &[u8]>

Iterates the analyzed vocabulary of every segment.

Terms may repeat across segments; callers that expand a structured query must impose their own deterministic de-duplication.

Source

pub fn document_count(&self) -> u64

Returns the store-wide document count.

Source

pub fn total_tokens(&self) -> u64

Returns the store-wide analyzed token count.

Source

pub fn corpus_stats(&self) -> Result<CorpusStats, IndexError>

Returns the store-wide corpus statistics.

This is the ONLY source of N and avgdl for scoring. There is deliberately no per-segment equivalent.

§Errors

Returns IndexError::Stats when the index holds no documents or no tokens, because avgdl is undefined then.

Source

pub fn document_frequency(&self, term: &[u8], fields: &[FieldId]) -> u32

Returns the store-wide document frequency of one term.

Summed across every segment and every requested field. A document containing the term in two fields counts once, which is what makes this a document frequency rather than a posting count. Segments without tombstones answer from their sealed dictionary. Segments with tombstones decode document identifiers and count only rows in the same live bitmap used for N and avgdl.

Trait Implementations§

Source§

impl Clone for LexicalIndex

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for LexicalIndex

Source§

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

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

impl Default for LexicalIndex

Source§

fn default() -> Self

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

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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.