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 new() -> TextSpatialIndex
pub fn new() -> TextSpatialIndex
Create a new empty index.
Sourcepub fn from_signals(signals: &[Signal]) -> TextSpatialIndex
pub fn from_signals(signals: &[Signal]) -> TextSpatialIndex
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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