pub struct ChunkedVectorStore { /* private fields */ }Expand description
Chunked Vector Store
Implementations§
Source§impl ChunkedVectorStore
impl ChunkedVectorStore
pub fn new( document_store: Arc<InMemoryChunkedDocumentStore>, vector_size: usize, ) -> ChunkedVectorStore
Sourcepub async fn add_chunk_vector(
&self,
chunk_id: String,
embedding: Vec<f32>,
) -> Result<(), VectorStoreError>
pub async fn add_chunk_vector( &self, chunk_id: String, embedding: Vec<f32>, ) -> Result<(), VectorStoreError>
添加 chunk 向量(chunk_id + embedding)
Sourcepub async fn add_chunk_vectors(
&self,
chunk_ids: Vec<String>,
embeddings: Vec<Vec<f32>>,
) -> Result<(), VectorStoreError>
pub async fn add_chunk_vectors( &self, chunk_ids: Vec<String>, embeddings: Vec<Vec<f32>>, ) -> Result<(), VectorStoreError>
批量添加 chunk 向量
Sourcepub async fn add_parent_document(
&self,
document: Document,
chunk_size: usize,
embeddings_fn: impl Fn(&str) -> Vec<f32>,
) -> Result<(String, Vec<String>), VectorStoreError>
pub async fn add_parent_document( &self, document: Document, chunk_size: usize, embeddings_fn: impl Fn(&str) -> Vec<f32>, ) -> Result<(String, Vec<String>), VectorStoreError>
从 Parent 文档添加(自动分割 + 向量化)
Sourcepub async fn get_embedding(
&self,
chunk_id: &str,
) -> Result<Option<Vec<f32>>, VectorStoreError>
pub async fn get_embedding( &self, chunk_id: &str, ) -> Result<Option<Vec<f32>>, VectorStoreError>
获取 chunk_id 对应的向量 (M4: O(1) HashMap lookup)
Sourcepub async fn vector_count(&self) -> usize
pub async fn vector_count(&self) -> usize
获取向量数量
Trait Implementations§
Source§impl VectorStore for ChunkedVectorStore
impl VectorStore for ChunkedVectorStore
Source§fn add_documents<'life0, 'async_trait>(
&'life0 self,
documents: Vec<Document>,
embeddings: Vec<Vec<f32>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn add_documents<'life0, 'async_trait>(
&'life0 self,
documents: Vec<Document>,
embeddings: Vec<Vec<f32>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
ChunkedVectorStore: 'async_trait,
Adds documents. Read more
Source§fn similarity_search<'life0, 'life1, 'async_trait>(
&'life0 self,
query_embedding: &'life1 [f32],
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn similarity_search<'life0, 'life1, 'async_trait>(
&'life0 self,
query_embedding: &'life1 [f32],
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
Searches similar documents. Read more
Source§fn get_document<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Document>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn get_document<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Document>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
Gets document by ID.
Source§fn get_embedding<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<f32>>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn get_embedding<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<f32>>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
Gets document embedding by ID.
Source§fn delete_document<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn delete_document<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
Deletes document.
Auto Trait Implementations§
impl !RefUnwindSafe for ChunkedVectorStore
impl !UnwindSafe for ChunkedVectorStore
impl Freeze for ChunkedVectorStore
impl Send for ChunkedVectorStore
impl Sync for ChunkedVectorStore
impl Unpin for ChunkedVectorStore
impl UnsafeUnpin for ChunkedVectorStore
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
Mutably borrows from an owned value. Read more