pub struct VectorStore { /* private fields */ }Expand description
Vector database using arroy + heed (LMDB)
Single-file database with:
- Vector search via arroy (ANN with random projections)
- Metadata storage via heed (LMDB)
- ACID transactions
- Memory-mapped for performance
Implementations§
Source§impl VectorStore
impl VectorStore
Sourcepub fn clear_stale_readers(&self) -> Result<usize>
pub fn clear_stale_readers(&self) -> Result<usize>
Clear stale LMDB reader slots left by crashed processes.
LMDB has a fixed reader table (default 126 slots). Processes that crash
without closing their read transactions leave stale entries. When the table
fills up, new read transactions fail with MDB_READERS_FULL.
Call this on startup to reclaim slots from dead PIDs.
Sourcepub fn new(db_path: &Path, dimensions: usize) -> Result<Self>
pub fn new(db_path: &Path, dimensions: usize) -> Result<Self>
Create or open a vector store
§Arguments
db_path- Path to the database directory (e.g., “.codesearch.db”)dimensions- Dimensionality of embeddings (e.g., 384, 768)
Sourcepub fn open_readonly(db_path: &Path, dimensions: usize) -> Result<Self>
pub fn open_readonly(db_path: &Path, dimensions: usize) -> Result<Self>
Open a vector store in read-only mode (for searches while another process writes)
§Arguments
db_path- Path to the database directory (e.g., “.codesearch.db”)dimensions- Dimensionality of embeddings (e.g., 384, 768)
Sourcepub fn insert_chunks(&mut self, chunks: Vec<EmbeddedChunk>) -> Result<usize>
pub fn insert_chunks(&mut self, chunks: Vec<EmbeddedChunk>) -> Result<usize>
Insert embedded chunks into the database
Returns the number of chunks inserted
Sourcepub fn build_index(&mut self) -> Result<()>
pub fn build_index(&mut self) -> Result<()>
Build the vector index
Must be called after inserting chunks and before searching
Sourcepub fn stats(&self) -> Result<StoreStats>
pub fn stats(&self) -> Result<StoreStats>
Get statistics about the vector store
Sourcepub fn delete_chunks(&mut self, chunk_ids: &[u32]) -> Result<usize>
pub fn delete_chunks(&mut self, chunk_ids: &[u32]) -> Result<usize>
Delete chunks by their IDs
Returns the number of chunks deleted
Sourcepub fn insert_chunks_with_ids(
&mut self,
chunks: Vec<EmbeddedChunk>,
) -> Result<Vec<u32>>
pub fn insert_chunks_with_ids( &mut self, chunks: Vec<EmbeddedChunk>, ) -> Result<Vec<u32>>
Delete all chunks from a specific file
Returns the IDs of deleted chunks Insert chunks and return their assigned IDs
Useful for tracking which chunks belong to which file
Sourcepub fn get_chunk_as_result(&self, id: u32) -> Result<Option<SearchResult>>
pub fn get_chunk_as_result(&self, id: u32) -> Result<Option<SearchResult>>
Get a chunk as SearchResult (for hybrid search)
Sourcepub fn all_chunks(&self) -> Result<Vec<(u32, ChunkMetadata)>>
pub fn all_chunks(&self) -> Result<Vec<(u32, ChunkMetadata)>>
Iterate all chunks in the store via LMDB cursor. Returns (id, metadata) pairs for every chunk, regardless of ID gaps. This is the correct way to enumerate chunks after delete+insert cycles.
Sourcepub fn is_indexed(&self) -> bool
pub fn is_indexed(&self) -> bool
Check if the index is built
Auto Trait Implementations§
impl Freeze for VectorStore
impl RefUnwindSafe for VectorStore
impl Send for VectorStore
impl Sync for VectorStore
impl Unpin for VectorStore
impl UnsafeUnpin for VectorStore
impl UnwindSafe for VectorStore
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for 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