pub struct CodeStore { /* private fields */ }Expand description
Qdrant + SQLite dual-write store for code chunks.
CodeStore is the persistence layer for the indexing pipeline. It is cheaply
cloneable (all fields are reference-counted) and can safely be shared across async
tasks.
§Lifecycle
- Call
CodeStore::with_opsto construct. - Call
CodeStore::ensure_collectiononce at startup to create the Qdrant collection if it does not yet exist. - Use
CodeStore::upsert_chunks_batchduring indexing andCodeStore::searchduring retrieval.
Implementations§
Source§impl CodeStore
impl CodeStore
Sourcepub fn with_ops(ops: QdrantOps, pool: DbPool) -> Self
pub fn with_ops(ops: QdrantOps, pool: DbPool) -> Self
Create a CodeStore from a pre-built QdrantOps instance and a SQLite pool.
The Qdrant collection is not created here — call CodeStore::ensure_collection
before performing any upserts.
§Examples
use zeph_index::store::CodeStore;
use zeph_memory::QdrantOps;
let ops = QdrantOps::new("http://localhost:6334", None).unwrap();
let store = CodeStore::with_ops(ops, pool);
store.ensure_collection(1536).await?;Sourcepub async fn ensure_collection(&self, vector_size: u64) -> Result<()>
pub async fn ensure_collection(&self, vector_size: u64) -> Result<()>
Create collection with INT8 scalar quantization if it doesn’t exist.
§Errors
Returns an error if Qdrant operations fail.
Sourcepub async fn upsert_chunk(
&self,
chunk: &ChunkInsert<'_>,
vector: Vec<f32>,
) -> Result<String>
pub async fn upsert_chunk( &self, chunk: &ChunkInsert<'_>, vector: Vec<f32>, ) -> Result<String>
Upsert a code chunk into both Qdrant and SQLite.
§Errors
Returns an error if Qdrant or SQLite operations fail.
Sourcepub async fn upsert_chunks_batch(
&self,
chunks: Vec<(ChunkInsert<'_>, Vec<f32>)>,
) -> Result<Vec<String>>
pub async fn upsert_chunks_batch( &self, chunks: Vec<(ChunkInsert<'_>, Vec<f32>)>, ) -> Result<Vec<String>>
Upsert multiple chunks into both Qdrant and SQLite in a single batch.
All vector points are sent to Qdrant in one request and all metadata rows are inserted
in a single SQLite transaction, reducing per-chunk overhead during full-project indexing.
§Errors
Returns an error if Qdrant or SQLite operations fail.
Sourcepub async fn chunk_exists(&self, content_hash: &str) -> Result<bool>
pub async fn chunk_exists(&self, content_hash: &str) -> Result<bool>
Check if a chunk with this content hash already exists.
§Errors
Returns an error if the SQLite query fails.
Sourcepub async fn existing_hashes(&self, hashes: &[&str]) -> Result<HashSet<String>>
pub async fn existing_hashes(&self, hashes: &[&str]) -> Result<HashSet<String>>
Return the set of content hashes that already exist in the store.
Uses WHERE content_hash IN (...) with chunks of 900 to stay below
SQLite’s default variable limit of 999.
§Errors
Returns an error if the SQLite query fails.
Sourcepub async fn remove_file_chunks(&self, file_path: &str) -> Result<usize>
pub async fn remove_file_chunks(&self, file_path: &str) -> Result<usize>
Remove all chunks for a given file path from both stores.
§Errors
Returns an error if Qdrant or SQLite operations fail.
Sourcepub async fn search(
&self,
query_vector: EmbeddingVector<Normalized>,
limit: usize,
language_filter: Option<String>,
) -> Result<Vec<SearchHit>>
pub async fn search( &self, query_vector: EmbeddingVector<Normalized>, limit: usize, language_filter: Option<String>, ) -> Result<Vec<SearchHit>>
Search for similar code chunks.
The query_vector must be L2-normalized (use
EmbeddingVector::<Unnormalized>::normalize
or
EmbeddingVector::<Normalized>::new_normalized
before calling). Requiring Normalized at the type level prevents silent
near-zero cosine scores that Qdrant gRPC returns for mismatched or
unnormalized vectors.
§Errors
Returns an error if Qdrant search fails.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for CodeStore
impl !UnwindSafe for CodeStore
impl Freeze for CodeStore
impl Send for CodeStore
impl Sync for CodeStore
impl Unpin for CodeStore
impl UnsafeUnpin for CodeStore
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request