pub struct SemanticIndex { /* private fields */ }Expand description
The semantic index — stores embeddings for all symbols in a project
Implementations§
Source§impl SemanticIndex
impl SemanticIndex
pub fn new(project_root: PathBuf, dimension: usize) -> Self
Sourcepub fn entry_count(&self) -> usize
pub fn entry_count(&self) -> usize
Number of embedded symbol entries.
Sourcepub fn status_label(&self) -> &'static str
pub fn status_label(&self) -> &'static str
Human-readable status label for the index.
Sourcepub fn build<F>(
project_root: &Path,
files: &[PathBuf],
embed_fn: &mut F,
max_batch_size: usize,
) -> Result<Self, String>
pub fn build<F>( project_root: &Path, files: &[PathBuf], embed_fn: &mut F, max_batch_size: usize, ) -> Result<Self, String>
Build the semantic index from a set of files using the provided embedding function.
embed_fn takes a batch of texts and returns a batch of embedding vectors.
Sourcepub fn build_with_progress<F, P>(
project_root: &Path,
files: &[PathBuf],
embed_fn: &mut F,
max_batch_size: usize,
progress: &mut P,
) -> Result<Self, String>
pub fn build_with_progress<F, P>( project_root: &Path, files: &[PathBuf], embed_fn: &mut F, max_batch_size: usize, progress: &mut P, ) -> Result<Self, String>
Build the semantic index and report embedding progress using entry counts.
Sourcepub fn refresh_stale_files<F, P>(
&mut self,
project_root: &Path,
current_files: &[PathBuf],
embed_fn: &mut F,
max_batch_size: usize,
progress: &mut P,
) -> Result<RefreshSummary, String>
pub fn refresh_stale_files<F, P>( &mut self, project_root: &Path, current_files: &[PathBuf], embed_fn: &mut F, max_batch_size: usize, progress: &mut P, ) -> Result<RefreshSummary, String>
Incrementally refresh entries for changed/new files only, preserving cached embeddings for unchanged files. Used when loading the index from disk and finding that a small fraction of files have moved on, deleted, or appeared.
Returns RefreshSummary describing what changed. On success, self is
mutated in place and remains a valid index.
current_files is the full set of files the project considers indexable
(typically walk_project_files(...)). Files in the cache that are no
longer in this set are treated as deleted.
Sourcepub fn search(&self, query_vector: &[f32], top_k: usize) -> Vec<SemanticResult>
pub fn search(&self, query_vector: &[f32], top_k: usize) -> Vec<SemanticResult>
Search the index with a query embedding, returning top-K results sorted by relevance
Sourcepub fn is_file_stale(&self, file: &Path) -> bool
pub fn is_file_stale(&self, file: &Path) -> bool
Check if a file needs re-indexing based on mtime/size
Sourcepub fn remove_file(&mut self, file: &Path)
pub fn remove_file(&mut self, file: &Path)
Remove entries for a specific file
pub fn invalidate_file(&mut self, file: &Path)
pub fn fingerprint(&self) -> Option<&SemanticIndexFingerprint>
pub fn backend_label(&self) -> Option<&str>
pub fn model_label(&self) -> Option<&str>
pub fn set_fingerprint(&mut self, fingerprint: SemanticIndexFingerprint)
Sourcepub fn write_to_disk(&self, storage_dir: &Path, project_key: &str)
pub fn write_to_disk(&self, storage_dir: &Path, project_key: &str)
Write the semantic index to disk using atomic temp+rename pattern
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SemanticIndex
impl RefUnwindSafe for SemanticIndex
impl Send for SemanticIndex
impl Sync for SemanticIndex
impl Unpin for SemanticIndex
impl UnsafeUnpin for SemanticIndex
impl UnwindSafe for SemanticIndex
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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