Skip to main content

MmapPostingData

Struct MmapPostingData 

Source
pub struct MmapPostingData { /* private fields */ }
Expand description

Mmap’d posting data — read-only view of sparse.mmap.

Implementations§

Source§

impl MmapPostingData

Source

pub fn open(path: &Path) -> Result<Self, String>

Source

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.

Source

pub fn num_dims(&self) -> usize

Source

pub fn num_vectors(&self) -> usize

Source

pub fn version(&self) -> u32

The file’s format version (3 and up: dimensions are global token ids).

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn cursor(&self, dim_idx: usize) -> Option<MmapCursor<'_>>

Cursor over a remapped dimension, None when it has no postings.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.