pub struct InvertedIndex { /* private fields */ }Expand description
Inverted index mapping blocking keys to record IDs.
Implementations§
Source§impl InvertedIndex
impl InvertedIndex
pub fn new() -> InvertedIndex
pub fn insert(&mut self, record_id: u64, keys: Vec<String>)
Sourcepub fn lookup_union(&self, keys: &[String], exclude: u64) -> Vec<u64>
pub fn lookup_union(&self, keys: &[String], exclude: u64) -> Vec<u64>
Returns all record IDs sharing at least one key with the query keys,
excluding exclude (the querying record itself). Result is deduplicated.
Sourcepub fn lookup_union_capped(
&self,
keys: &[String],
exclude: u64,
max_bucket_size: usize,
) -> Vec<u64>
pub fn lookup_union_capped( &self, keys: &[String], exclude: u64, max_bucket_size: usize, ) -> Vec<u64>
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).
Sourcepub fn bucket_size(&self, key: &str) -> usize
pub fn bucket_size(&self, key: &str) -> usize
Returns the size of a specific bucket, or 0 if not present.
Sourcepub fn oversized_buckets(&self, max_size: usize) -> usize
pub fn oversized_buckets(&self, max_size: usize) -> usize
Returns the number of buckets exceeding max_size.
Sourcepub fn all_pairs(
&self,
id_to_idx: &HashMap<u64, usize>,
max_bucket_size: usize,
) -> Vec<(usize, usize)>
pub fn all_pairs( &self, id_to_idx: &HashMap<u64, 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.
pub fn remove(&mut self, record_id: u64)
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn record_count(&self) -> usize
Trait Implementations§
Source§impl BlockIndex for InvertedIndex
impl BlockIndex for InvertedIndex
Source§fn insert(&mut self, record_id: u64, keys: Vec<String>)
fn insert(&mut self, record_id: u64, keys: Vec<String>)
Index
record_id under the given set of blocking keys.Source§fn lookup_union(&self, keys: &[String], exclude: u64) -> Vec<u64>
fn lookup_union(&self, keys: &[String], exclude: u64) -> Vec<u64>
Return all record IDs sharing at least one key with
keys, excluding
exclude (the querying record itself). Result must be deduplicated.fn as_any(&self) -> &(dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Source§impl Default for InvertedIndex
impl Default for InvertedIndex
Source§fn default() -> InvertedIndex
fn default() -> InvertedIndex
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for InvertedIndex
impl RefUnwindSafe for InvertedIndex
impl Send for InvertedIndex
impl Sync for InvertedIndex
impl Unpin for InvertedIndex
impl UnsafeUnpin for InvertedIndex
impl UnwindSafe for InvertedIndex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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