pub struct Index {
pub root: PathBuf,
pub corpus_kind: CorpusKind,
pub index_dir: Option<PathBuf>,
/* private fields */
}Expand description
In-memory trigram index backed by memory-mapped storage.
All data is accessed zero-copy from mapped files. Opening an index is cheap — just memory-mapping the three index files, no deserialization.
Fields§
§root: PathBuf§corpus_kind: CorpusKind§index_dir: Option<PathBuf>Implementations§
Source§impl Index
impl Index
Sourcepub fn open(path: &Path) -> Result<Self>
pub fn open(path: &Path) -> Result<Self>
Open an index directory produced by IndexBuilder::build.
§Errors
Returns crate::Error::MissingMeta if sift.meta is absent,
crate::Error::InvalidMeta if metadata is empty or malformed,
crate::Error::MissingComponent if a trigram table file is missing,
or crate::Error::Io on read/mmap failure.
Sourcepub fn save_to_dir(&self, dir: &Path) -> Result<()>
pub fn save_to_dir(&self, dir: &Path) -> Result<()>
Persist the in-memory index to dir.
§Errors
Propagates IO errors from creating directories or writing files.
pub fn index_dir(&self) -> Option<&Path>
pub fn explain(&self, pattern: &str) -> QueryPlan
pub fn posting_bytes_slice(&self, tri: [u8; 3]) -> &[u8] ⓘ
Sourcepub fn posting_list_for_trigram(&self, tri: [u8; 3]) -> Vec<u32>
pub fn posting_list_for_trigram(&self, tri: [u8; 3]) -> Vec<u32>
Get sorted file IDs for a trigram. Materializes from mapped bytes.
§Panics
Panics if postings data for this trigram is corrupted.
pub fn candidate_file_ids(&self, arms: &[Vec<[u8; 3]>]) -> Vec<u32>
pub fn candidate_paths(&self, arms: &[Vec<[u8; 3]>]) -> Vec<PathBuf>
pub fn file_path(&self, id: usize) -> Option<&Path>
pub const fn file_count(&self) -> usize
pub fn iter_files(&self) -> impl Iterator<Item = &Path>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Index
impl RefUnwindSafe for Index
impl Send for Index
impl Sync for Index
impl Unpin for Index
impl UnsafeUnpin for Index
impl UnwindSafe for Index
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 more