Skip to main content

VectorIndex

Trait VectorIndex 

pub trait VectorIndex {
    // Required methods
    fn insert_embedding<P>(
        &self,
        registry: &P,
        e: EmbeddingInsert<'_>,
    ) -> Result<(), VectorIndexError>
       where P: EmbeddingProvenance;
    fn knn<P>(
        &self,
        registry: &P,
        task: TaskKind,
        query: &[f32],
        k: usize,
        platform: &str,
    ) -> Result<Vec<KnnHit>, VectorIndexError>
       where P: EmbeddingProvenance;
    fn stale_embedding_assets<P>(
        &self,
        registry: &P,
        task: TaskKind,
        platform: &str,
    ) -> Result<Vec<String>, VectorIndexError>
       where P: EmbeddingProvenance;
}
Expand description

The store port the ML layer writes embeddings into and ranks them from.

Partitioned by (platform, model_version): a query answers from the current canonical version only, so a stale embedding (an older version, left over after a model swap) is excluded structurally until regenerate_stale replaces it. The production implementor is the library catalog; an implementation must honour these laws:

  • insert_embedding refuses what EmbeddingProvenance::check_insert refuses and a vector whose length is not the declared dimension, and replaces any prior embedding for the same (asset, task, platform);
  • knn returns hits nearest-first from the platform partition at the registry’s current canonical version only;
  • stale_embedding_assets lists, sorted, the assets in the platform partition whose stored version trails the canonical one.

Required Methods§

fn insert_embedding<P>( &self, registry: &P, e: EmbeddingInsert<'_>, ) -> Result<(), VectorIndexError>

Insert (or replace) one provenanced embedding.

fn knn<P>( &self, registry: &P, task: TaskKind, query: &[f32], k: usize, platform: &str, ) -> Result<Vec<KnnHit>, VectorIndexError>

The k nearest neighbours of query in task’s current canonical platform partition.

fn stale_embedding_assets<P>( &self, registry: &P, task: TaskKind, platform: &str, ) -> Result<Vec<String>, VectorIndexError>

The regeneration work-list: assets in task’s platform partition whose embedding is stale under registry, sorted by asset id.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl VectorIndex for DatabaseDriver

The catalog is the production VectorIndex: each port method is the inherent method of the same name, with a SQLite failure type-erased into VectorIndexError::Store.