pub struct SortedIndexes { /* private fields */ }Expand description
In-memory sorted index per (collection, field). Rebuilt from object store on startup. O(log n) ORDER BY queries.
Implementations§
Source§impl SortedIndexes
impl SortedIndexes
pub fn new() -> Self
Sourcepub fn ensure(&self, coll: &str, field: &str)
pub fn ensure(&self, coll: &str, field: &str)
Register a field as sorted-indexed for a collection. Must be called before any puts for that field to be indexed.
Sourcepub fn insert(&self, coll: &str, field: &str, value: &Value, hash: &str)
pub fn insert(&self, coll: &str, field: &str, value: &Value, hash: &str)
Insert (or update) a value → hash mapping.
Sourcepub fn remove(&self, coll: &str, field: &str, value: &Value, hash: &str)
pub fn remove(&self, coll: &str, field: &str, value: &Value, hash: &str)
Remove a hash from the index (on overwrite/delete of a doc version).
Sourcepub fn top_k_asc(&self, coll: &str, field: &str, k: usize) -> Vec<String>
pub fn top_k_asc(&self, coll: &str, field: &str, k: usize) -> Vec<String>
Return the top-k hashes ordered by field ASC.
Sourcepub fn top_k_desc(&self, coll: &str, field: &str, k: usize) -> Vec<String>
pub fn top_k_desc(&self, coll: &str, field: &str, k: usize) -> Vec<String>
Return the top-k hashes ordered by field DESC.
Sourcepub fn range(
&self,
coll: &str,
field: &str,
low: Option<&Value>,
high: Option<&Value>,
low_incl: bool,
high_incl: bool,
) -> Vec<String>
pub fn range( &self, coll: &str, field: &str, low: Option<&Value>, high: Option<&Value>, low_incl: bool, high_incl: bool, ) -> Vec<String>
Hashes whose indexed value falls within the given bounds.
The BTreeMap already orders by value, so a bounded predicate is a
range walk rather than a full collection scan. None for either bound
means unbounded on that side, which serves a one-sided inequality
(fee > 10) as well as a two-sided BETWEEN.
Documents where the field is ABSENT are not in this index at all, and are therefore not returned. That is correct for every predicate this serves: a missing field compares as null, which satisfies no ordering comparison.
Sourcepub fn exact(&self, coll: &str, field: &str, value: &Value) -> Vec<String>
pub fn exact(&self, coll: &str, field: &str, value: &Value) -> Vec<String>
Hashes whose indexed value equals value — an O(log n) point lookup,
used for = and for each arm of an IN (...) list.
Sourcepub fn range_len(
&self,
coll: &str,
field: &str,
low: Option<&Value>,
high: Option<&Value>,
low_incl: bool,
high_incl: bool,
) -> usize
pub fn range_len( &self, coll: &str, field: &str, low: Option<&Value>, high: Option<&Value>, low_incl: bool, high_incl: bool, ) -> usize
How many hashes a range covers, without materialising them.
Lets the planner compare two candidate indexes and pick the more selective one, rather than committing to whichever field it saw first.
Auto Trait Implementations§
impl !RefUnwindSafe for SortedIndexes
impl Freeze for SortedIndexes
impl Send for SortedIndexes
impl Sync for SortedIndexes
impl Unpin for SortedIndexes
impl UnsafeUnpin for SortedIndexes
impl UnwindSafe for SortedIndexes
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
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
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> ⓘ
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