Skip to main content

ChunkedDocumentStoreTrait

Trait ChunkedDocumentStoreTrait 

Source
pub trait ChunkedDocumentStoreTrait: Send + Sync {
Show 18 methods // Required methods fn add_parent_document<'life0, 'async_trait>( &'life0 self, document: Document, chunk_size: usize, ) -> Pin<Box<dyn Future<Output = Result<(String, Vec<String>), VectorStoreError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn add_parent_documents<'life0, 'async_trait>( &'life0 self, documents: Vec<Document>, chunk_size: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<(String, Vec<String>)>, VectorStoreError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn get_parent_document<'life0, 'life1, 'async_trait>( &'life0 self, parent_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Document>, VectorStoreError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn get_chunk<'life0, 'life1, 'async_trait>( &'life0 self, chunk_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<ChunkDocument>, VectorStoreError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn get_chunk_document<'life0, 'life1, 'async_trait>( &'life0 self, chunk_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Document>, VectorStoreError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn get_chunks_for_parent<'life0, 'life1, 'async_trait>( &'life0 self, parent_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<ChunkDocument>, VectorStoreError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn get_chunk_documents_for_parent<'life0, 'life1, 'async_trait>( &'life0 self, parent_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, VectorStoreError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn delete_parent_document<'life0, 'life1, 'async_trait>( &'life0 self, parent_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn parent_count<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn chunk_count<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn get_all_chunks<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<ChunkDocument>, VectorStoreError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn clear<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn add_parent_document_blocking( &self, document: Document, chunk_size: usize, ) -> Result<(String, Vec<String>), VectorStoreError>; fn get_parent_document_blocking( &self, parent_id: &str, ) -> Result<Option<Document>, VectorStoreError>; fn get_chunk_blocking( &self, chunk_id: &str, ) -> Result<Option<ChunkDocument>, VectorStoreError>; fn blocking_get_chunks_for_parent( &self, parent_id: &str, ) -> Result<Vec<ChunkDocument>, VectorStoreError>; // Provided methods fn save<'life0, 'async_trait>( &'life0 self, _path: impl AsRef<Path> + Send + 'async_trait, ) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait { ... } fn load<'async_trait>( _path: impl AsRef<Path> + Send + 'async_trait, ) -> Pin<Box<dyn Future<Output = Result<Self, VectorStoreError>> + Send + 'async_trait>> where Self: Sized + 'async_trait { ... }
}
Expand description

支持 Parent-Child 结构的文档存储 trait

此 trait 定义了回表存储的统一接口,支持:

  • MongoDB(生产环境)
  • InMemory(开发/测试)
  • Redis(缓存层,预留)
  • SQLite(本地存储,预留)

Required Methods§

Source

fn add_parent_document<'life0, 'async_trait>( &'life0 self, document: Document, chunk_size: usize, ) -> Pin<Box<dyn Future<Output = Result<(String, Vec<String>), VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

添加 Parent 文档并自动分割为 chunks

§参数
  • document: 原始文档
  • chunk_size: 每个 chunk 的字符大小
§返回
  • (parent_id, chunk_ids): Parent ID 和生成的 Chunk ID 列表
Source

fn add_parent_documents<'life0, 'async_trait>( &'life0 self, documents: Vec<Document>, chunk_size: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<(String, Vec<String>)>, VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

批量添加 Parent 文档

Source

fn get_parent_document<'life0, 'life1, 'async_trait>( &'life0 self, parent_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Document>, VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

获取 Parent 文档

Source

fn get_chunk<'life0, 'life1, 'async_trait>( &'life0 self, chunk_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<ChunkDocument>, VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

获取单个 Chunk

Source

fn get_chunk_document<'life0, 'life1, 'async_trait>( &'life0 self, chunk_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Document>, VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

获取单个 Chunk(转为 Document)

Source

fn get_chunks_for_parent<'life0, 'life1, 'async_trait>( &'life0 self, parent_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<ChunkDocument>, VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

获取 Parent 的所有 Chunks

Source

fn get_chunk_documents_for_parent<'life0, 'life1, 'async_trait>( &'life0 self, parent_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

获取 Parent 的所有 Chunks(转为 Document)

Source

fn delete_parent_document<'life0, 'life1, 'async_trait>( &'life0 self, parent_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

删除 Parent 文档及其所有 Chunks

Source

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

获取 Parent 文档数量

Source

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

获取 Chunk 文档数量

Source

fn get_all_chunks<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<ChunkDocument>, VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

获取所有 Chunks

Source

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

清空所有数据

Source

fn add_parent_document_blocking( &self, document: Document, chunk_size: usize, ) -> Result<(String, Vec<String>), VectorStoreError>

添加 Parent 文档(阻塞版本)

Source

fn get_parent_document_blocking( &self, parent_id: &str, ) -> Result<Option<Document>, VectorStoreError>

获取 Parent 文档(阻塞版本)

Source

fn get_chunk_blocking( &self, chunk_id: &str, ) -> Result<Option<ChunkDocument>, VectorStoreError>

获取单个 Chunk(阻塞版本)

Source

fn blocking_get_chunks_for_parent( &self, parent_id: &str, ) -> Result<Vec<ChunkDocument>, VectorStoreError>

获取 Parent 的所有 Chunks(阻塞版本)

Provided Methods§

Source

fn save<'life0, 'async_trait>( &'life0 self, _path: impl AsRef<Path> + Send + 'async_trait, ) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

持久化存储(可选实现)

Source

fn load<'async_trait>( _path: impl AsRef<Path> + Send + 'async_trait, ) -> Pin<Box<dyn Future<Output = Result<Self, VectorStoreError>> + Send + 'async_trait>>
where Self: Sized + 'async_trait,

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§