aurora_semantic/storage/
mod.rs1mod disk;
7mod metadata;
8
9pub use disk::DiskStorage;
10pub use metadata::WorkspaceMetadata;
11
12use std::path::PathBuf;
13
14use crate::error::Result;
15use crate::types::{Chunk, Document, WorkspaceId, WorkspaceStats};
16
17pub trait Storage: Send + Sync {
19 fn init_workspace(&self, workspace_id: &WorkspaceId, root_path: &PathBuf) -> Result<()>;
21
22 fn workspace_exists(&self, workspace_id: &WorkspaceId) -> bool;
24
25 fn load_workspace_metadata(&self, workspace_id: &WorkspaceId) -> Result<WorkspaceMetadata>;
27
28 fn save_workspace_metadata(
30 &self,
31 workspace_id: &WorkspaceId,
32 metadata: &WorkspaceMetadata,
33 ) -> Result<()>;
34
35 fn save_documents(&self, workspace_id: &WorkspaceId, documents: &[Document]) -> Result<()>;
37
38 fn load_documents(&self, workspace_id: &WorkspaceId) -> Result<Vec<Document>>;
40
41 fn save_chunks(&self, workspace_id: &WorkspaceId, chunks: &[Chunk]) -> Result<()>;
43
44 fn load_chunks(&self, workspace_id: &WorkspaceId) -> Result<Vec<Chunk>>;
46
47 fn save_embeddings(
49 &self,
50 workspace_id: &WorkspaceId,
51 embeddings: &[(String, Vec<f32>)], ) -> Result<()>;
53
54 fn load_embeddings(&self, workspace_id: &WorkspaceId) -> Result<Vec<(String, Vec<f32>)>>;
56
57 fn tantivy_index_path(&self, workspace_id: &WorkspaceId) -> PathBuf;
59
60 fn vector_index_path(&self, workspace_id: &WorkspaceId) -> PathBuf;
62
63 fn delete_workspace(&self, workspace_id: &WorkspaceId) -> Result<()>;
65
66 fn list_workspaces(&self) -> Result<Vec<WorkspaceId>>;
68
69 fn get_workspace_stats(&self, workspace_id: &WorkspaceId) -> Result<WorkspaceStats>;
71
72 fn flush(&self) -> Result<()>;
74}
75
76#[derive(Debug, Clone)]
78pub struct StorageOptions {
79 pub use_mmap: bool,
81 pub compress: bool,
83 pub buffer_size: usize,
85}
86
87impl Default for StorageOptions {
88 fn default() -> Self {
89 Self {
90 use_mmap: true,
91 compress: true,
92 buffer_size: 64 * 1024, }
94 }
95}