Skip to main content

InvertedIndex

Struct InvertedIndex 

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

Inverted index mapping blocking keys to record IDs.

Implementations§

Source§

impl InvertedIndex

Source

pub fn new() -> Self

Source

pub fn insert(&mut self, record_id: RecordId, keys: Vec<String>)

Source

pub fn lookup_union(&self, keys: &[String], exclude: RecordId) -> Vec<RecordId>

Returns all record IDs sharing at least one key with the query keys, excluding exclude (the querying record itself). Result is deduplicated.

Source

pub fn lookup_union_capped( &self, keys: &[String], exclude: RecordId, max_bucket_size: usize, ) -> Vec<RecordId>

Like Self::lookup_union but skips any bucket whose size exceeds max_bucket_size. Overfull buckets have low selectivity and produce O(n²) spurious pairs; capping them prevents unbounded memory growth.

Pass max_bucket_size = 0 to disable the cap (same as lookup_union).

Source

pub fn bucket_size(&self, key: &str) -> usize

Returns the size of a specific bucket, or 0 if not present.

Source

pub fn oversized_buckets(&self, max_size: usize) -> usize

Returns the number of buckets exceeding max_size.

Source

pub fn all_pairs( &self, id_to_idx: &HashMap<RecordId, usize>, max_bucket_size: usize, ) -> Vec<(usize, usize)>

Enumerate all canonical (i < j) candidate pairs directly from bucket contents.

Pass max_bucket_size = 0 to disable the cap.

Source

pub fn remove(&mut self, record_id: RecordId)

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn record_count(&self) -> usize

Trait Implementations§

Source§

impl BlockIndex for InvertedIndex

Source§

fn insert(&mut self, record_id: RecordId, keys: Vec<String>)

Index record_id under the given set of blocking keys.
Source§

fn lookup_union(&self, keys: &[String], exclude: RecordId) -> Vec<RecordId>

Return all record IDs sharing at least one key with keys, excluding exclude (the querying record itself). Result must be deduplicated.
Source§

fn remove(&mut self, record_id: RecordId)

Remove all index entries for record_id.
Source§

fn as_any(&self) -> &dyn Any

Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Source§

impl Default for InvertedIndex

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.