pub struct VectorDatabase { /* private fields */ }Use SemanticSearch over storage-backed VectorEntry slices for runtime retrieval. VectorDatabase is an internal/test abstraction.
Expand description
Vector database for storing and searching embeddings
Deprecated: VectorDatabase is an in-memory test/development abstraction.
The live retrieval path uses SemanticSearch over storage-backed VectorEntry
slices (see crate::search::SemanticSearch). SemanticSearch is the actual
runtime retrieval path used by RepresentationService.
Implementations§
Source§impl VectorDatabase
impl VectorDatabase
Sourcepub fn with_dimension(dimension: usize) -> Self
pub fn with_dimension(dimension: usize) -> Self
Create with custom dimension
Sourcepub async fn in_memory() -> Result<Self>
pub async fn in_memory() -> Result<Self>
Create a new in-memory database (async for API compatibility)
Sourcepub fn insert_with_priority(
&mut self,
entry: VectorEntry,
priority: Option<u8>,
) -> Result<()>
pub fn insert_with_priority( &mut self, entry: VectorEntry, priority: Option<u8>, ) -> Result<()>
Insert a vector with priority for graph tree
Sourcepub fn insert(&mut self, entry: VectorEntry) -> Result<()>
pub fn insert(&mut self, entry: VectorEntry) -> Result<()>
Insert a vector (backward compatible)
Sourcepub fn get(&self, id: i64) -> Option<&VectorEntry>
pub fn get(&self, id: i64) -> Option<&VectorEntry>
Get a vector by ID
Sourcepub fn remove(&mut self, id: i64) -> Option<VectorEntry>
pub fn remove(&mut self, id: i64) -> Option<VectorEntry>
Remove a vector by ID
Sourcepub fn by_namespace(&self, namespace_id: i64) -> Vec<&VectorEntry>
pub fn by_namespace(&self, namespace_id: i64) -> Vec<&VectorEntry>
Get vectors by namespace
Sourcepub fn by_category(&self, category: &str) -> Vec<&VectorEntry>
pub fn by_category(&self, category: &str) -> Vec<&VectorEntry>
Get vectors by category
Sourcepub fn search(
&self,
query: &[f32],
namespace_id: i64,
limit: usize,
threshold: f32,
) -> Result<(Vec<VectorSearchResult>, SearchLatency)>
pub fn search( &self, query: &[f32], namespace_id: i64, limit: usize, threshold: f32, ) -> Result<(Vec<VectorSearchResult>, SearchLatency)>
Search for similar vectors
Returns results sorted by boosted score (descending). Target latency: <10ms
Sourcepub fn search_by_category(
&self,
query: &[f32],
namespace_id: i64,
category: &str,
limit: usize,
threshold: f32,
) -> Result<(Vec<VectorSearchResult>, SearchLatency)>
pub fn search_by_category( &self, query: &[f32], namespace_id: i64, category: &str, limit: usize, threshold: f32, ) -> Result<(Vec<VectorSearchResult>, SearchLatency)>
Search with category filter
Sourcepub fn insert_batch(&mut self, entries: Vec<VectorEntry>) -> Result<usize>
pub fn insert_batch(&mut self, entries: Vec<VectorEntry>) -> Result<usize>
Batch insert multiple vectors
More efficient than individual inserts for bulk loading.
Sourcepub fn insert_batch_with_priorities(
&mut self,
entries: Vec<(VectorEntry, Option<u8>)>,
) -> Result<usize>
pub fn insert_batch_with_priorities( &mut self, entries: Vec<(VectorEntry, Option<u8>)>, ) -> Result<usize>
Batch insert with priorities
Sourcepub fn remove_batch(&mut self, ids: &[i64]) -> Vec<Option<VectorEntry>>
pub fn remove_batch(&mut self, ids: &[i64]) -> Vec<Option<VectorEntry>>
Batch remove multiple vectors
Sourcepub fn search_batch(
&self,
queries: &[Vec<f32>],
namespace_id: i64,
limit: usize,
threshold: f32,
) -> Result<Vec<(Vec<VectorSearchResult>, SearchLatency)>>
pub fn search_batch( &self, queries: &[Vec<f32>], namespace_id: i64, limit: usize, threshold: f32, ) -> Result<Vec<(Vec<VectorSearchResult>, SearchLatency)>>
Search with multiple queries (for batch operations)
Sourcepub fn find_similar(
&self,
memory_id: i64,
limit: usize,
threshold: f32,
) -> Result<(Vec<VectorSearchResult>, SearchLatency)>
pub fn find_similar( &self, memory_id: i64, limit: usize, threshold: f32, ) -> Result<(Vec<VectorSearchResult>, SearchLatency)>
Find similar vectors to a stored vector by ID
Sourcepub fn stats(&self) -> VectorDatabaseStats
pub fn stats(&self) -> VectorDatabaseStats
Get statistics about the vector database
Sourcepub fn all_vectors(&self) -> Vec<&VectorEntry>
pub fn all_vectors(&self) -> Vec<&VectorEntry>
Get all vectors as a slice (read-only access)