Skip to main content

DocLenSlot

Struct DocLenSlot 

Source
pub struct DocLenSlot {
    pub fact: FactId,
    pub len: u16,
    pub distinct: u16,
    pub sig: u64,
}
Expand description

Per-document record: [fact 4 | len u16 | distinct u16 | sig u64], Uniform arena.

Beyond the length BM25 scores with, the slot carries a summary of the document’s term set: how many distinct terms it has, and one bit per term hashed into a 64-bit word. That summary is what lets the write path bound the term-set overlap of two facts without re-reading and re-tokenizing their texts (see Memory::find_similar). It is written when the document is indexed, where the term set is already in hand, so it costs nothing to produce.

Fields§

§fact: FactId

The document (fact) id — the key.

§len: u16

Token count of the document, saturated at u16::MAX.

§distinct: u16

Number of distinct terms, saturated at u16::MAX. Zero means “unknown”: a document indexed before the signature existed, read through the legacy migration.

§sig: u64

Union of sig_bit over the document’s distinct terms. A term absent from this word is definitely absent from the document; a term present may still be absent (bits collide). Zero alongside distinct == 0 means “unknown”.

Implementations§

Source§

impl DocLenSlot

Source

pub fn has_signature(&self) -> bool

Whether the term-set summary is present. A legacy document carries none, and callers must fall back to reading its text.

Source

pub fn overlap_bound(&self, terms: &[u32]) -> usize

An upper bound on how many of terms this document also holds.

Exact in the direction that matters: a term whose bit is clear cannot be in the document, so the true intersection is never larger than the count returned here. Callers use it to rule overlap out.

Trait Implementations§

Source§

impl Clone for DocLenSlot

Source§

fn clone(&self) -> DocLenSlot

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 Copy for DocLenSlot

Source§

impl Debug for DocLenSlot

Source§

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

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

impl Eq for DocLenSlot

Source§

impl PartialEq for DocLenSlot

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Slot for DocLenSlot

Source§

const SIZE: usize = doclen_at::SIZE

Total size of the record in bytes.
Source§

const KEY_LEN: usize = doclen_at::KEY_LEN

Length of the key prefix; sorting and lookups compare only these leading bytes. Must not exceed SIZE.
Source§

fn write(&self, out: &mut [u8])

Serializes the record into out (out.len() == SIZE), filling every byte.
Source§

fn read(bytes: &[u8]) -> Self

Reconstructs the record from bytes (bytes.len() == SIZE).
Source§

impl StructuralPartialEq for DocLenSlot

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

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