Skip to main content

VectorIndex

Trait VectorIndex 

Source
pub trait VectorIndex: Send + Sync {
    // Required methods
    fn descriptor(&self) -> &VectorIndexDescriptor;
    fn status(&self) -> VectorIndexStatus;
    fn replace_partition<'life0, 'life1, 'async_trait>(
        &'life0 self,
        partition: &'life1 str,
        records: Vec<VectorRecord>,
    ) -> Pin<Box<dyn Future<Output = VectorResult<VectorIndexStatus>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn remove_partition<'life0, 'life1, 'async_trait>(
        &'life0 self,
        partition: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = VectorResult<VectorIndexStatus>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn search<'life0, 'async_trait>(
        &'life0 self,
        request: VectorSearchRequest,
    ) -> Pin<Box<dyn Future<Output = VectorResult<VectorSearchResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn clear<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = VectorResult<VectorIndexStatus>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn change_token(&self) -> Option<VectorIndexChangeToken> { ... }
    fn observe<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = VectorResult<VectorIndexObservation>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn mutation_consistency(&self) -> VectorMutationConsistency { ... }
    fn replace_partition_if_revision<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _partition: &'life1 str,
        _expected_revision: VectorRevision,
        _records: Vec<VectorRecord>,
    ) -> Pin<Box<dyn Future<Output = VectorResult<VectorIndexStatus>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn remove_partition_if_revision<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _partition: &'life1 str,
        _expected_revision: VectorRevision,
    ) -> Pin<Box<dyn Future<Output = VectorResult<VectorIndexStatus>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

A bounded vector index whose content and lifecycle are owned by its caller.

Partitions are the atomic mutation unit. Implementations must make a successful replacement visible in one revision and must not expose a partially constructed partition to concurrent searches.

Required Methods§

Source

fn descriptor(&self) -> &VectorIndexDescriptor

Return the immutable shape and resource limits of this index.

Source

fn status(&self) -> VectorIndexStatus

Return the latest locally observed status without waiting for I/O.

This compatibility accessor can be stale for durable or remote backends. Use Self::observe when the result guards correctness.

Source

fn replace_partition<'life0, 'life1, 'async_trait>( &'life0 self, partition: &'life1 str, records: Vec<VectorRecord>, ) -> Pin<Box<dyn Future<Output = VectorResult<VectorIndexStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Atomically replace every record in partition.

Replacing an existing partition with an empty record list removes it. Replacing a missing partition with an empty list is a no-op.

Source

fn remove_partition<'life0, 'life1, 'async_trait>( &'life0 self, partition: &'life1 str, ) -> Pin<Box<dyn Future<Output = VectorResult<VectorIndexStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Atomically remove one partition. Missing partitions are a no-op.

Source

fn search<'life0, 'async_trait>( &'life0 self, request: VectorSearchRequest, ) -> Pin<Box<dyn Future<Output = VectorResult<VectorSearchResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Search one immutable index revision.

Source

fn clear<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = VectorResult<VectorIndexStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove every partition. Clearing an empty index is a no-op.

Provided Methods§

Source

fn change_token(&self) -> Option<VectorIndexChangeToken>

Return exact evidence for the current revision of one index history.

The default preserves source compatibility but provides no continuity proof. A backend may return Some only when every content mutation advances the revision and its history identity changes whenever storage is independently recreated or restored onto a divergent history.

Source

fn observe<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = VectorResult<VectorIndexObservation>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Observe one self-consistent published revision.

The conservative default exposes only the status compatibility view. Backends must override this method to expose an exact history token; doing so asserts that the status and token were read atomically.

Source

fn mutation_consistency(&self) -> VectorMutationConsistency

Return the strongest partition-mutation ordering contract implemented by this backend.

Source

fn replace_partition_if_revision<'life0, 'life1, 'async_trait>( &'life0 self, _partition: &'life1 str, _expected_revision: VectorRevision, _records: Vec<VectorRecord>, ) -> Pin<Box<dyn Future<Output = VectorResult<VectorIndexStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Atomically replace one partition only when the complete index still has expected_revision.

Implementations advertising IndexRevisionCas must compare and mutate at one linearization point. The default fails closed so a custom backend cannot accidentally claim cross-writer ordering from a check-then-write.

Source

fn remove_partition_if_revision<'life0, 'life1, 'async_trait>( &'life0 self, _partition: &'life1 str, _expected_revision: VectorRevision, ) -> Pin<Box<dyn Future<Output = VectorResult<VectorIndexStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Atomically remove one partition only when the complete index still has expected_revision.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§