pub struct SearchIndex { /* private fields */ }Expand description
Inverted word index for fast entity search.
For each entity, we tokenize its name, type, and observations, store each token → set of matching entity indices.
Uses a flat Vec<(StrId, u32)> sorted by (token, entity_idx)
for cache-friendly lookups via binary search.
Implementations§
Source§impl SearchIndex
impl SearchIndex
pub fn new() -> Self
pub fn clear(&mut self)
pub const fn len(&self) -> usize
pub const fn is_empty(&self) -> bool
Sourcepub fn index_entity(
&mut self,
interner: &mut StringInterner,
entity_idx: u32,
name: StrId,
entity_type: StrId,
observations: &[StrId],
)
pub fn index_entity( &mut self, interner: &mut StringInterner, entity_idx: u32, name: StrId, entity_type: StrId, observations: &[StrId], )
Index a single entity by its name, type, and observations.
All strings must already be interned.
entity_idx is the position in the entity storage vec.
Sourcepub fn remove_entity(&mut self, entity_idx: u32)
pub fn remove_entity(&mut self, entity_idx: u32)
Remove all entries for a given entity (before re-indexing).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SearchIndex
impl RefUnwindSafe for SearchIndex
impl Send for SearchIndex
impl Sync for SearchIndex
impl Unpin for SearchIndex
impl UnsafeUnpin for SearchIndex
impl UnwindSafe for SearchIndex
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