Skip to main content

a3s_memory/vector/
index.rs

1use super::{
2    VectorIndexDescriptor, VectorIndexStatus, VectorRecord, VectorResult, VectorSearchRequest,
3    VectorSearchResult,
4};
5
6/// A bounded vector index whose content and lifecycle are owned by its caller.
7///
8/// Partitions are the atomic mutation unit. Implementations must make a
9/// successful replacement visible in one revision and must not expose a
10/// partially constructed partition to concurrent searches.
11#[async_trait::async_trait]
12pub trait VectorIndex: Send + Sync {
13    /// Return the immutable shape and resource limits of this index.
14    fn descriptor(&self) -> &VectorIndexDescriptor;
15
16    /// Return the latest published status without waiting for background work.
17    fn status(&self) -> VectorIndexStatus;
18
19    /// Atomically replace every record in `partition`.
20    ///
21    /// Replacing an existing partition with an empty record list removes it.
22    /// Replacing a missing partition with an empty list is a no-op.
23    async fn replace_partition(
24        &self,
25        partition: &str,
26        records: Vec<VectorRecord>,
27    ) -> VectorResult<VectorIndexStatus>;
28
29    /// Atomically remove one partition. Missing partitions are a no-op.
30    async fn remove_partition(&self, partition: &str) -> VectorResult<VectorIndexStatus>;
31
32    /// Search one immutable index revision.
33    async fn search(&self, request: VectorSearchRequest) -> VectorResult<VectorSearchResult>;
34
35    /// Remove every partition. Clearing an empty index is a no-op.
36    async fn clear(&self) -> VectorResult<VectorIndexStatus>;
37}