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 more