pub struct MmapSidecarIndex<Id>{ /* private fields */ }Expand description
A memory-mapped sidecar index with zero-copy access to compressed payloads.
The file is memory-mapped via memmap2::Mmap. The FibScorer is
reconstructed from the profile and gram table in the file (owned
data). Each entry’s compressed FibCodeV1 bytes remain as &[u8]
slices into the mmap — they are decoded on demand during search.
The _mmap field keeps the mapping alive for the lifetime of this
struct.
Implementations§
Source§impl<Id> MmapSidecarIndex<Id>
impl<Id> MmapSidecarIndex<Id>
Sourcepub fn open(path: &Path) -> Result<Self>
pub fn open(path: &Path) -> Result<Self>
Memory-map a sidecar file and provide zero-copy access to compressed payloads.
The FibScorer is reconstructed from the profile (by rebuilding
the quantizer). Each entry’s compact bytes stay as zero-copy
&[u8] slices into the mmap and are decoded on demand during
search.
§Safety
This uses Mmap::map() which requires the file to be a valid
mmap-able file. The file must not be modified while the mmap is
alive.
§Errors
Returns FibQuantError::CorruptPayload for malformed files,
or IO errors wrapped in CorruptPayload.
Sourcepub fn profile(&self) -> &FibQuantProfileV1
pub fn profile(&self) -> &FibQuantProfileV1
Return a reference to the profile.
Sourcepub fn search(
&self,
query: &[f32],
top_k: usize,
oversample: usize,
) -> Result<Vec<ScoredCandidate<Id>>>where
Id: Clone,
pub fn search(
&self,
query: &[f32],
top_k: usize,
oversample: usize,
) -> Result<Vec<ScoredCandidate<Id>>>where
Id: Clone,
Approximate search returning sorted candidates.
Decodes each entry’s compressed bytes on demand from the mmap
slices, scores them against the query using the Gram table
estimator, and returns the top top_k * oversample candidates.
See FibSidecarIndex::search for full semantics.
Auto Trait Implementations§
impl<Id> Freeze for MmapSidecarIndex<Id>
impl<Id> RefUnwindSafe for MmapSidecarIndex<Id>where
Id: RefUnwindSafe,
impl<Id> Send for MmapSidecarIndex<Id>where
Id: Send,
impl<Id> Sync for MmapSidecarIndex<Id>where
Id: Sync,
impl<Id> Unpin for MmapSidecarIndex<Id>where
Id: Unpin,
impl<Id> UnsafeUnpin for MmapSidecarIndex<Id>
impl<Id> UnwindSafe for MmapSidecarIndex<Id>where
Id: UnwindSafe,
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> 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.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.