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: FactIdThe document (fact) id — the key.
len: u16Token count of the document, saturated at u16::MAX.
distinct: u16Number of distinct terms, saturated at u16::MAX. Zero means
“unknown”: a document indexed before the signature existed, read
through the legacy migration.
sig: u64Union 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
impl DocLenSlot
Sourcepub fn has_signature(&self) -> bool
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.
Sourcepub fn overlap_bound(&self, terms: &[u32]) -> usize
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
impl Clone for DocLenSlot
Source§fn clone(&self) -> DocLenSlot
fn clone(&self) -> DocLenSlot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more