Struct SortedIndex
pub struct SortedIndex<'a> { /* private fields */ }Expand description
A sorted index over a borrowed slice of Values.
Keys are extracted from each value using a set of Projections. The index is
sorted using a private total ordering on Value that extends the existing
PartialOrd (which has SQL semantics and returns None for Null comparisons)
with a deterministic order for all cases.
Supports equality and range queries. Duplicate keys are allowed; queries
that would return multiple values (e.g. find_range) yield all of them.
Construction is O(n log n). All queries are O(log n + k) where k is the result count.
§Cloning
Key fields are cloned into owned Values for storage. Full records are never
cloned — the stored values are &'a Value references into the source slice.
Implementations§
§impl<'a> SortedIndex<'a>
impl<'a> SortedIndex<'a>
pub fn new(values: &'a [Value], projections: &[Projection]) -> SortedIndex<'a>
pub fn new(values: &'a [Value], projections: &[Projection]) -> SortedIndex<'a>
Build a sorted index over values, keyed by the fields selected by projections.
Each projection navigates into a value to extract one key component. Multiple projections produce a composite key compared lexicographically.
pub fn find_lt(&self, key: &[Value]) -> impl Iterator<Item = &'a Value>
pub fn find_lt(&self, key: &[Value]) -> impl Iterator<Item = &'a Value>
Iterate over all values whose key is strictly less than key.
pub fn find_le(&self, key: &[Value]) -> impl Iterator<Item = &'a Value>
pub fn find_le(&self, key: &[Value]) -> impl Iterator<Item = &'a Value>
Iterate over all values whose key is less than or equal to key.
pub fn find_gt(&self, key: &[Value]) -> impl Iterator<Item = &'a Value>
pub fn find_gt(&self, key: &[Value]) -> impl Iterator<Item = &'a Value>
Iterate over all values whose key is strictly greater than key.