pub struct LearnedSparseIndex { /* private fields */ }Expand description
Learned Sparse Index using linear regression
Now with key normalization for numerical stability with large u64 keys. Keys are normalized to [0, n-1] before regression, avoiding precision loss with values near u64::MAX.
Implementations§
Source§impl LearnedSparseIndex
impl LearnedSparseIndex
Sourcepub fn build(keys: &[u64]) -> Self
pub fn build(keys: &[u64]) -> Self
Build index from sorted keys
Keys MUST be sorted in ascending order. This is not validated for performance.
Sourcepub fn build_with_threshold(keys: &[u64], correction_threshold: usize) -> Self
pub fn build_with_threshold(keys: &[u64], correction_threshold: usize) -> Self
Build index with custom correction threshold
Lower threshold = more corrections stored = faster lookups but more memory Higher threshold = fewer corrections = slower lookups but less memory
Sourcepub fn lookup(&self, key: u64) -> LookupResult
pub fn lookup(&self, key: u64) -> LookupResult
Lookup: O(1) expected, O(ε) worst case
Sourcepub fn lookup_with_error(&self, key: u64, max_error: usize) -> LookupResult
pub fn lookup_with_error(&self, key: u64, max_error: usize) -> LookupResult
Lookup with a custom error margin (tighter range if you know data is regular)
Sourcepub fn stats(&self) -> LearnedIndexStats
pub fn stats(&self) -> LearnedIndexStats
Get index statistics
Sourcepub fn is_efficient(&self) -> bool
pub fn is_efficient(&self) -> bool
Returns true if this index is well-suited for learned indexing (low error, few corrections)
Sourcepub fn memory_bytes(&self) -> usize
pub fn memory_bytes(&self) -> usize
Memory usage in bytes
Trait Implementations§
Source§impl Clone for LearnedSparseIndex
impl Clone for LearnedSparseIndex
Source§fn clone(&self) -> LearnedSparseIndex
fn clone(&self) -> LearnedSparseIndex
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LearnedSparseIndex
impl Debug for LearnedSparseIndex
Source§impl<'de> Deserialize<'de> for LearnedSparseIndex
impl<'de> Deserialize<'de> for LearnedSparseIndex
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for LearnedSparseIndex
impl RefUnwindSafe for LearnedSparseIndex
impl Send for LearnedSparseIndex
impl Sync for LearnedSparseIndex
impl Unpin for LearnedSparseIndex
impl UnsafeUnpin for LearnedSparseIndex
impl UnwindSafe for LearnedSparseIndex
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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