Open or create the sparse engine database at the given path.
(path: &Path)
| 75 | impl SparseEngine { |
| 76 | /// Open or create the sparse engine database at the given path. |
| 77 | pub fn open(path: &Path) -> crate::Result<Self> { |
| 78 | if let Some(parent) = path.parent() { |
| 79 | std::fs::create_dir_all(parent)?; |
| 80 | } |
| 81 | |
| 82 | let db = Database::create(path).map_err(|e| redb_err("open", e))?; |
| 83 | |
| 84 | let write_txn = db.begin_write().map_err(|e| redb_err("write txn", e))?; |
| 85 | { |
| 86 | let _ = write_txn |
| 87 | .open_table(DOCUMENTS) |
| 88 | .map_err(|e| redb_err("open documents table", e))?; |
| 89 | let _ = write_txn |
| 90 | .open_table(INDEXES) |
| 91 | .map_err(|e| redb_err("open indexes table", e))?; |
| 92 | } |
| 93 | write_txn.commit().map_err(|e| redb_err("commit", e))?; |
| 94 | |
| 95 | info!(path = %path.display(), "sparse engine opened"); |
| 96 | |
| 97 | let engine = Self { db: Arc::new(db) }; |
| 98 | engine.ensure_documents_versioned_table()?; |
| 99 | engine.ensure_indexes_versioned_table()?; |
| 100 | Ok(engine) |
| 101 | } |
| 102 | |
| 103 | /// Insert or update a document (tenant-scoped). |
| 104 | /// |
nothing calls this directly
no test coverage detected