pub struct TrigramIndex { /* private fields */ }Expand description
Opened trigram index with memory-mapped posting lists.
A trigram index is an inverted index mapping every 3-byte sequence found in the corpus to the set of files that contain it. At query time, required literals are extracted from the regex pattern, decomposed into trigrams, and intersected against the posting lists to produce a narrow candidate set.
This is the first shipped index type in Sift’s composable index architecture.
It sits alongside future index types (AST, dependency graph, vector) as a
peer in the Index enum.
Implementations§
Source§impl TrigramIndex
impl TrigramIndex
Sourcepub fn build(
config: &IndexConfig<'_>,
output_dir: &Path,
paths: &[PathBuf],
) -> Result<Self>
pub fn build( config: &IndexConfig<'_>, output_dir: &Path, paths: &[PathBuf], ) -> Result<Self>
Build a trigram index from an explicit path list (or full walk when paths is empty).
§Errors
Returns an error if corpus walking, extraction, or encoding fails.
Sourcepub fn open(
index_dir: &Path,
root: &Path,
corpus_kind: CorpusKind,
) -> Result<Self>
pub fn open( index_dir: &Path, root: &Path, corpus_kind: CorpusKind, ) -> Result<Self>
Open a previously persisted trigram index from index_dir.
§Errors
Returns an error if persistence files are missing or malformed.
Sourcepub fn update(
&self,
config: &IndexConfig<'_>,
output_dir: &Path,
paths: &[PathBuf],
) -> Result<Option<Self>>
pub fn update( &self, config: &IndexConfig<'_>, output_dir: &Path, paths: &[PathBuf], ) -> Result<Option<Self>>
Update the index from the current corpus, writing artifact files
into output_dir.
Returns Ok(Some(index)) if a new index was written, or Ok(None)
if no files changed.
§Errors
Returns an error if corpus walking, extraction, or encoding fails.
Source§impl TrigramIndex
impl TrigramIndex
Sourcepub fn candidates(&self, query: &QuerySpec<'_>) -> Option<Vec<Candidate>>
pub fn candidates(&self, query: &QuerySpec<'_>) -> Option<Vec<Candidate>>
Produce narrowed candidate files for the query.
Returns None if the query can’t be narrowed (full scan required).
Sourcepub fn explain(&self, query: &QuerySpec<'_>) -> QueryPlanOutput
pub fn explain(&self, query: &QuerySpec<'_>) -> QueryPlanOutput
Returns an explanation of how a query would be handled.
Source§impl TrigramIndex
impl TrigramIndex
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TrigramIndex
impl RefUnwindSafe for TrigramIndex
impl Send for TrigramIndex
impl Sync for TrigramIndex
impl Unpin for TrigramIndex
impl UnsafeUnpin for TrigramIndex
impl UnwindSafe for TrigramIndex
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 more