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.
V3 layout optimizations:
- SoA dimension table: binary search only touches
dim_idsarray (352KB for 88K dims, fits L2 cache) instead of 2.8MB AoS. - OwnedBytes skip section: zero-copy mmap reference to the contiguous skip-entry region at the tail of the file. No heap allocation or parsing during segment load.
- Single tail read: only footer + TOC + skip section are read during load; block data at the front of the file is never touched.
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,
dims: DimensionTable,
skip_bytes: OwnedBytes,
total_docs: u32,
total_vectors: u32,
) -> Self
pub fn new( handle: LazyFileHandle, dims: DimensionTable, skip_bytes: OwnedBytes, total_docs: u32, total_vectors: u32, ) -> Self
Create a new V3 sparse index with SoA dimension table and zero-copy skip section
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 via mmap)
Sourcepub fn get_skip_list(&self, dim_id: u32) -> Option<(Vec<SparseSkipEntry>, f32)>
pub fn get_skip_list(&self, dim_id: u32) -> Option<(Vec<SparseSkipEntry>, f32)>
Get skip list for a dimension (for block-max iteration without loading blocks). Returns owned Vec since entries are parsed from zero-copy mmap bytes.
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 SoA table, 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 estimated_memory_bytes(&self) -> usize
pub fn estimated_memory_bytes(&self) -> usize
Estimated memory usage in bytes
- DimensionTable: SoA arrays (6 × ndims × 4 bytes)
- Skip section: OwnedBytes (Arc overhead only; data is mmap-backed)
- Handle: LazyFileHandle overhead
Sourcepub async fn read_dim_raw(&self, dim_id: u32) -> Result<Option<DimRawData>>
pub async fn read_dim_raw(&self, dim_id: u32) -> Result<Option<DimRawData>>
Get merge-level info for a dimension: skip entries, doc_count, global_max_weight, and raw block data bytes (single mmap read, zero deserialization).
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.