pub struct TextSpatialIndex { /* private fields */ }Expand description
Spatial index for text signals using an interval tree.
Enables efficient queries:
query_overlap(start, end): Find signals that overlap with rangequery_containing(start, end): Find signals that fully contain rangequery_contained_in(start, end): Find signals fully within range
§Performance
- Build: O(n log n)
- Query: O(log n + k) where k is result count
- Space: O(n)
For documents with >100 signals, this provides significant speedup over linear scan for range queries.
Implementations§
Source§impl TextSpatialIndex
impl TextSpatialIndex
Sourcepub fn from_signals(signals: &[Signal<Location>]) -> Self
pub fn from_signals(signals: &[Signal<Location>]) -> Self
Build index from signals in a document.
Sourcepub fn insert(&mut self, signal_id: SignalId, start: usize, end: usize)
pub fn insert(&mut self, signal_id: SignalId, start: usize, end: usize)
Insert a text span into the index.
Sourcepub fn query_overlap(&self, start: usize, end: usize) -> Vec<SignalId>
pub fn query_overlap(&self, start: usize, end: usize) -> Vec<SignalId>
Find signals that overlap with the given range.
Sourcepub fn query_containing(&self, start: usize, end: usize) -> Vec<SignalId>
pub fn query_containing(&self, start: usize, end: usize) -> Vec<SignalId>
Find signals that fully contain the given range.
Trait Implementations§
Source§impl Clone for TextSpatialIndex
impl Clone for TextSpatialIndex
Source§fn clone(&self) -> TextSpatialIndex
fn clone(&self) -> TextSpatialIndex
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TextSpatialIndex
impl Debug for TextSpatialIndex
Source§impl Default for TextSpatialIndex
impl Default for TextSpatialIndex
Source§fn default() -> TextSpatialIndex
fn default() -> TextSpatialIndex
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TextSpatialIndex
impl RefUnwindSafe for TextSpatialIndex
impl Send for TextSpatialIndex
impl Sync for TextSpatialIndex
impl Unpin for TextSpatialIndex
impl UnsafeUnpin for TextSpatialIndex
impl UnwindSafe for TextSpatialIndex
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