pub struct EmbeddingIndex { /* private fields */ }Expand description
Brute-force vector index for semantic search.
Stores (unit_id, feature_vec) pairs copied from the graph for cache locality during sequential scan.
Implementations§
Source§impl EmbeddingIndex
impl EmbeddingIndex
Sourcepub fn build(graph: &CodeGraph) -> Self
pub fn build(graph: &CodeGraph) -> Self
Build an EmbeddingIndex from all code units in the given graph.
Only includes units whose feature vectors have the expected dimension and are not all-zero (i.e., have a non-negligible norm).
Sourcepub fn search(
&self,
query: &[f32],
top_k: usize,
min_similarity: f32,
) -> Vec<EmbeddingMatch>
pub fn search( &self, query: &[f32], top_k: usize, min_similarity: f32, ) -> Vec<EmbeddingMatch>
Search for the most similar vectors to query.
Returns at most top_k results with cosine similarity >= min_similarity,
ordered by descending score.
If the query vector dimension does not match the index dimension, or the query vector has near-zero norm, returns an empty vector.
Trait Implementations§
Source§impl Clone for EmbeddingIndex
impl Clone for EmbeddingIndex
Source§fn clone(&self) -> EmbeddingIndex
fn clone(&self) -> EmbeddingIndex
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EmbeddingIndex
impl Debug for EmbeddingIndex
Auto Trait Implementations§
impl Freeze for EmbeddingIndex
impl RefUnwindSafe for EmbeddingIndex
impl Send for EmbeddingIndex
impl Sync for EmbeddingIndex
impl Unpin for EmbeddingIndex
impl UnsafeUnpin for EmbeddingIndex
impl UnwindSafe for EmbeddingIndex
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