pub struct SparseIndex {
pub total_docs: u32,
pub total_vectors: u32,
/* private fields */
}Expand description
Sparse vector index for a field: lazy block loading via mmap
Stores skip list per dimension (block metadata). Blocks loaded on-demand. Memory: only skip list headers in RAM, block data via mmap (OS page cache).
Fields§
§total_docs: u32Total document count in this segment (for IDF computation)
total_vectors: u32Total sparse vectors in this segment (for multi-valued IDF)
Implementations§
Source§impl SparseIndex
impl SparseIndex
Sourcepub fn new(
handle: LazyFileHandle,
dimensions: Vec<DimensionEntry>,
total_docs: u32,
total_vectors: u32,
) -> Self
pub fn new( handle: LazyFileHandle, dimensions: Vec<DimensionEntry>, total_docs: u32, total_vectors: u32, ) -> Self
Create a new sparse index with lazy block loading
Sourcepub async fn get_posting(
&self,
dim_id: u32,
) -> Result<Option<Arc<BlockSparsePostingList>>>
pub async fn get_posting( &self, dim_id: u32, ) -> Result<Option<Arc<BlockSparsePostingList>>>
Get posting list for a dimension (loads all blocks - for compatibility)
Sourcepub fn get_skip_list(&self, dim_id: u32) -> Option<(&[SparseSkipEntry], f32)>
pub fn get_skip_list(&self, dim_id: u32) -> Option<(&[SparseSkipEntry], f32)>
Get skip list for a dimension (for block-max iteration without loading blocks)
Sourcepub async fn get_block(
&self,
dim_id: u32,
block_idx: usize,
) -> Result<Option<SparseBlock>>
pub async fn get_block( &self, dim_id: u32, block_idx: usize, ) -> Result<Option<SparseBlock>>
Load specific block for a dimension
Sourcepub fn has_dimension(&self, dim_id: u32) -> bool
pub fn has_dimension(&self, dim_id: u32) -> bool
Check if dimension exists
Sourcepub fn num_dimensions(&self) -> usize
pub fn num_dimensions(&self) -> usize
Get the number of dimensions in the index
Sourcepub fn active_dimensions(&self) -> impl Iterator<Item = u32> + '_
pub fn active_dimensions(&self) -> impl Iterator<Item = u32> + '_
Iterate over all active dimension IDs
Sourcepub fn doc_count(&self, dim_id: u32) -> u32
pub fn doc_count(&self, dim_id: u32) -> u32
Get doc count for dimension (from skip list, no I/O)
Sourcepub fn idf_weights(&self, dim_ids: &[u32]) -> Vec<f32>
pub fn idf_weights(&self, dim_ids: &[u32]) -> Vec<f32>
Get IDF weights for multiple dimensions
Sourcepub fn get_posting_blocking(
&self,
dim_id: u32,
) -> Result<Option<Arc<BlockSparsePostingList>>>
pub fn get_posting_blocking( &self, dim_id: u32, ) -> Result<Option<Arc<BlockSparsePostingList>>>
Get posting list synchronously (blocking) - for merger
Trait Implementations§
Source§impl Clone for SparseIndex
impl Clone for SparseIndex
Source§fn clone(&self) -> SparseIndex
fn clone(&self) -> SparseIndex
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SparseIndex
impl !RefUnwindSafe for SparseIndex
impl Send for SparseIndex
impl Sync for SparseIndex
impl Unpin for SparseIndex
impl !UnwindSafe for SparseIndex
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.