Skip to main content

VectorDatabase

Struct VectorDatabase 

Source
pub struct VectorDatabase { /* private fields */ }
👎Deprecated since 0.1.0:

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

Source

pub fn new() -> Self

Create a new vector database

Source

pub fn with_dimension(dimension: usize) -> Self

Create with custom dimension

Source

pub async fn in_memory() -> Result<Self>

Create a new in-memory database (async for API compatibility)

Source

pub fn insert_with_priority( &mut self, entry: VectorEntry, priority: Option<u8>, ) -> Result<()>

Insert a vector with priority for graph tree

Source

pub fn insert(&mut self, entry: VectorEntry) -> Result<()>

Insert a vector (backward compatible)

Source

pub fn get(&self, id: i64) -> Option<&VectorEntry>

Get a vector by ID

Source

pub fn remove(&mut self, id: i64) -> Option<VectorEntry>

Remove a vector by ID

Source

pub fn ids(&self) -> Vec<i64>

Get all vector IDs

Source

pub fn len(&self) -> usize

Get vector count

Source

pub fn is_empty(&self) -> bool

Check if empty

Source

pub fn by_namespace(&self, namespace_id: i64) -> Vec<&VectorEntry>

Get vectors by namespace

Source

pub fn by_category(&self, category: &str) -> Vec<&VectorEntry>

Get vectors by category

Source

pub fn dimension(&self) -> usize

Get the embedding dimension

Source

pub fn tree(&self) -> &GraphTree

Get reference to the graph tree

Source

pub fn tree_mut(&mut self) -> &mut GraphTree

Get mutable reference to the graph tree

Source

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

Source

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

Source

pub fn insert_batch(&mut self, entries: Vec<VectorEntry>) -> Result<usize>

Batch insert multiple vectors

More efficient than individual inserts for bulk loading.

Source

pub fn insert_batch_with_priorities( &mut self, entries: Vec<(VectorEntry, Option<u8>)>, ) -> Result<usize>

Batch insert with priorities

Source

pub fn remove_batch(&mut self, ids: &[i64]) -> Vec<Option<VectorEntry>>

Batch remove multiple vectors

Source

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)

Source

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

Source

pub fn stats(&self) -> VectorDatabaseStats

Get statistics about the vector database

Source

pub fn clear(&mut self)

Clear all vectors from the database

Source

pub fn contains(&self, id: i64) -> bool

Check if a vector exists

Source

pub fn all_vectors(&self) -> Vec<&VectorEntry>

Get all vectors as a slice (read-only access)

Source

pub fn update_embedding( &mut self, id: i64, new_embedding: Vec<f32>, ) -> Result<()>

Update an existing vector’s embedding

Trait Implementations§

Source§

impl Debug for VectorDatabase

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for VectorDatabase

Source§

fn default() -> VectorDatabase

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more