pub struct Index { /* private fields */ }Expand description
A lazily-maintained fst-segment index rooted at a directory (.ct/okf/).
Implementations§
Source§impl Index
impl Index
Sourcepub fn open(dir: &Path) -> Result<Index, String>
pub fn open(dir: &Path) -> Result<Index, String>
Open the index at dir, loading manifest.json if present (an absent or
unreadable manifest yields an empty index). The directory is created on
the first Index::save.
Sourcepub fn segment_count(&self) -> usize
pub fn segment_count(&self) -> usize
Number of live segments.
Sourcepub fn tombstone_count(&self) -> usize
pub fn tombstone_count(&self) -> usize
Number of tombstoned documents awaiting condense.
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
Atomically-published manifest generation. It advances on every successful content delta, rebuild, or compaction.
Sourcepub fn source_bytes(&self) -> u64
pub fn source_bytes(&self) -> u64
Bytes of live source documents represented by the manifest.
pub fn provider(&self) -> (&str, u64)
Sourcepub fn pending(&self, current: &[FileStat]) -> (usize, usize, usize)
pub fn pending(&self, current: &[FileStat]) -> (usize, usize, usize)
How many of current are new / changed / removed relative to the
manifest — a read-only staleness probe for index status that mutates
nothing (the same diff update would act on).
Sourcepub fn update_delta<F>(
&mut self,
upserts: &[FileStat],
removed: &[String],
load: F,
) -> Result<UpdateReport, String>
pub fn update_delta<F>( &mut self, upserts: &[FileStat], removed: &[String], load: F, ) -> Result<UpdateReport, String>
Apply a watcher-derived partial change set without walking unchanged
scopes. removed entries are keys or directory-key prefixes; every
matching live document is removed before upserts replace/add paths.
Periodic full update calls remain the correctness audit.
Sourcepub fn search(
&self,
query: &str,
limit: usize,
) -> Result<Vec<SearchHit>, String>
pub fn search( &self, query: &str, limit: usize, ) -> Result<Vec<SearchHit>, String>
Search the index, returning up to limit hits ranked by a tf-idf score.
Reads every live segment; tombstoned documents are filtered out.
Sourcepub fn condense(&mut self) -> Result<bool, String>
pub fn condense(&mut self) -> Result<bool, String>
Merge every segment into one, dropping tombstoned documents and their postings, then delete the old segment files. Reclaims space without re-reading any source file. A no-op when there is nothing to gain (≤1 segment and no tombstones).