pub struct MmapPostingData { /* private fields */ }Expand description
Mmap’d posting data — read-only view of sparse.mmap.
Implementations§
Source§impl MmapPostingData
impl MmapPostingData
pub fn open(path: &Path) -> Result<Self, String>
Sourcepub fn verify_checksum(&self, path: &Path) -> Result<(), String>
pub fn verify_checksum(&self, path: &Path) -> Result<(), String>
Recompute the CRC-32 of the whole file and compare it with the footer’s. Reads every byte; a version 1 file has no footer and passes.
pub fn num_dims(&self) -> usize
pub fn num_vectors(&self) -> usize
Sourcepub fn version(&self) -> u32
pub fn version(&self) -> u32
The file’s format version (3 and up: dimensions are global token ids).
Sourcepub fn has_global_dims(&self) -> bool
pub fn has_global_dims(&self) -> bool
Whether a dimension is addressed by its global token id (version 3) or by a dense position this file alone defines (versions 1 and 2).
Sourcepub fn dim_of_token(&self, token_id: u32) -> Option<usize>
pub fn dim_of_token(&self, token_id: u32) -> Option<usize>
The position of a global token id in this file’s table, by binary
search. None on a version 1 or 2 file, whose table is dense and
says nothing about token ids.
Sourcepub fn tokens(&self) -> impl Iterator<Item = (u32, usize)> + '_
pub fn tokens(&self) -> impl Iterator<Item = (u32, usize)> + '_
Every (token_id, position) of this file, in sorted order — what a
merge walks. Empty on a version 1 or 2 file.
Sourcepub fn entries_of_token(&self, token_id: u32) -> &[PostingEntry]
pub fn entries_of_token(&self, token_id: u32) -> &[PostingEntry]
The entries of a global token id, empty when this file does not hold that dimension.
Sourcepub fn entries(&self, dim_idx: usize) -> &[PostingEntry]
pub fn entries(&self, dim_idx: usize) -> &[PostingEntry]
The entries of a remapped dimension, sorted by record id; empty for an empty or unknown dimension.
Sourcepub fn cursor(&self, dim_idx: usize) -> Option<MmapCursor<'_>>
pub fn cursor(&self, dim_idx: usize) -> Option<MmapCursor<'_>>
Cursor over a remapped dimension, None when it has no postings.
Sourcepub fn load_postings_of_token(&self, token_id: u32) -> Postings
pub fn load_postings_of_token(&self, token_id: u32) -> Postings
Load a global token id’s entries into an in-RAM list. Empty when the file does not hold that dimension — the lookup a version 3 file answers itself, and the only correct one once the table is sorted by token rather than laid out by position.
Sourcepub fn load_postings(&self, dim_idx: usize) -> Postings
pub fn load_postings(&self, dim_idx: usize) -> Postings
Load a dimension’s entries into an in-RAM list, recomputing the
ceilings from the weights. dim_idx is a position in this file,
which is the caller’s dense dimension only on a version 1 or 2 file.