pub struct EmbeddingRegistry {
pub concurrency: usize,
/* private fields */
}Expand description
Generic Qdrant-backed embedding registry.
Owns a QdrantOps instance, a collection name and a UUID namespace for
deterministic point IDs (uuid v5). The in-memory hashes map enables
O(1) delta detection between syncs.
The cached_dim field caches the collection’s vector dimension after the first successful
sync so that search_raw can validate the query vector
dimension without an extra Qdrant round-trip on every call. When a mismatch is detected,
search_raw returns EmbeddingRegistryError::DimensionProbe instead of silently issuing a
gRPC search that would return near-zero cosine scores (Qdrant gRPC behaviour on dim mismatch).
Fields§
§concurrency: usizeMaximum number of embedding requests dispatched concurrently during a sync.
Implementations§
Source§impl EmbeddingRegistry
impl EmbeddingRegistry
Sourcepub fn new(
ops: QdrantOps,
collection: impl Into<String>,
namespace: Uuid,
) -> Self
pub fn new( ops: QdrantOps, collection: impl Into<String>, namespace: Uuid, ) -> Self
Create a registry wrapping an existing QdrantOps connection.
Sourcepub async fn sync<T: Embeddable>(
&mut self,
items: &[T],
embedding_model: &str,
embed_fn: impl Fn(&str) -> EmbedFuture,
on_progress: Option<Box<dyn Fn(usize, usize) + Send>>,
) -> Result<SyncStats, EmbeddingRegistryError>
pub async fn sync<T: Embeddable>( &mut self, items: &[T], embedding_model: &str, embed_fn: impl Fn(&str) -> EmbedFuture, on_progress: Option<Box<dyn Fn(usize, usize) + Send>>, ) -> Result<SyncStats, EmbeddingRegistryError>
Sync items into Qdrant, computing a content-hash delta to avoid
unnecessary re-embedding. Re-creates the collection when the embedding
model changes.
on_progress, when provided, is called after each successful embed+upsert with
(completed, total) counts so callers can display progress indicators.
§Errors
Returns EmbeddingRegistryError on Qdrant or embedding failures.
Sourcepub async fn search_raw(
&self,
query: &str,
limit: usize,
embed_fn: impl Fn(&str) -> EmbedFuture,
) -> Result<Vec<ScoredVectorPoint>, EmbeddingRegistryError>
pub async fn search_raw( &self, query: &str, limit: usize, embed_fn: impl Fn(&str) -> EmbedFuture, ) -> Result<Vec<ScoredVectorPoint>, EmbeddingRegistryError>
Search the collection, returning raw scored Qdrant points.
Validates that the query vector dimension matches the collection before issuing the gRPC call. Qdrant gRPC silently returns near-zero cosine scores (~0.022) when dimensions mismatch instead of returning an error — this guard prevents that silent failure.
The dimension is checked against the cache populated by the most recent sync
call. If no sync has occurred (cache is None) the check is skipped to avoid blocking
reads before the first sync.
Consumers map the payloads to their domain types.
§Errors
Returns EmbeddingRegistryError::DimensionProbe when the query vector dimension does not
match the stored collection dimension. Returns EmbeddingRegistryError::Embedding if the
embed function fails, or EmbeddingRegistryError::VectorStore on Qdrant search failure.
Trait Implementations§
Source§impl Clone for EmbeddingRegistry
impl Clone for EmbeddingRegistry
Source§fn clone(&self) -> EmbeddingRegistry
fn clone(&self) -> EmbeddingRegistry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for EmbeddingRegistry
impl !RefUnwindSafe for EmbeddingRegistry
impl Send for EmbeddingRegistry
impl Sync for EmbeddingRegistry
impl Unpin for EmbeddingRegistry
impl UnsafeUnpin for EmbeddingRegistry
impl !UnwindSafe for EmbeddingRegistry
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> 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