pub struct ValueIndex { /* private fields */ }Expand description
A collection of B-Tree indexes keyed by field name.
Each index maps orderable values to the set of entity IDs that have that value for the given field. Supports efficient range lookups.
Implementations§
Source§impl ValueIndex
impl ValueIndex
Sourcepub fn index_field(&mut self, field: &str)
pub fn index_field(&mut self, field: &str)
Register a field for indexing. Call this before adding entities.
Sourcepub fn indexed_fields(&self) -> impl Iterator<Item = &str>
pub fn indexed_fields(&self) -> impl Iterator<Item = &str>
Returns the set of indexed field names.
Sourcepub fn add(&mut self, entity_id: usize, field: &str, value: &Kind)
pub fn add(&mut self, entity_id: usize, field: &str, value: &Kind)
Add an entity’s value to the index for a given field.
Sourcepub fn remove(&mut self, entity_id: usize, field: &str, value: &Kind)
pub fn remove(&mut self, entity_id: usize, field: &str, value: &Kind)
Remove an entity from the index for a given field/value.
Sourcepub fn eq_lookup(&self, field: &str, val: &Kind) -> Vec<usize>
pub fn eq_lookup(&self, field: &str, val: &Kind) -> Vec<usize>
Look up entity IDs where field == val.
Sourcepub fn ne_lookup(&self, field: &str, val: &Kind) -> Vec<usize>
pub fn ne_lookup(&self, field: &str, val: &Kind) -> Vec<usize>
Look up entity IDs where field != val (all indexed minus exact match).
Optimized: collects all IDs for the field and excludes the matching set, avoiding iteration of the entire BTreeMap.
Sourcepub fn gt_lookup(&self, field: &str, val: &Kind) -> Vec<usize>
pub fn gt_lookup(&self, field: &str, val: &Kind) -> Vec<usize>
Look up entity IDs where field > val.
Sourcepub fn ge_lookup(&self, field: &str, val: &Kind) -> Vec<usize>
pub fn ge_lookup(&self, field: &str, val: &Kind) -> Vec<usize>
Look up entity IDs where field >= val.
Sourcepub fn lt_lookup(&self, field: &str, val: &Kind) -> Vec<usize>
pub fn lt_lookup(&self, field: &str, val: &Kind) -> Vec<usize>
Look up entity IDs where field < val.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ValueIndex
impl RefUnwindSafe for ValueIndex
impl Send for ValueIndex
impl Sync for ValueIndex
impl Unpin for ValueIndex
impl UnsafeUnpin for ValueIndex
impl UnwindSafe for ValueIndex
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