MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / open

Method open

nodedb/src/engine/sparse/btree.rs:77–101  ·  view source on GitHub ↗

Open or create the sparse engine database at the given path.

(path: &Path)

Source from the content-addressed store, hash-verified

75impl 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 ///

Callers

nothing calls this directly

Calls 6

begin_writeMethod · 0.80
redb_errFunction · 0.70
createFunction · 0.50
commitMethod · 0.45

Tested by

no test coverage detected