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

Method open

nodedb/src/engine/graph/edge_store/store.rs:72–94  ·  view source on GitHub ↗

Open or create the edge store database at the given path.

(path: &Path)

Source from the content-addressed store, hash-verified

70impl EdgeStore {
71 /// Open or create the edge store database at the given path.
72 pub fn open(path: &Path) -> crate::Result<Self> {
73 if let Some(parent) = path.parent() {
74 std::fs::create_dir_all(parent)?;
75 }
76
77 let db = Database::create(path).map_err(|e| redb_err("open", e))?;
78
79 let write_txn = db.begin_write().map_err(|e| redb_err("begin_write", e))?;
80 {
81 let _ = write_txn
82 .open_table(EDGES)
83 .map_err(|e| redb_err("open edges", e))?;
84 let _ = write_txn
85 .open_table(REVERSE_EDGES)
86 .map_err(|e| redb_err("open reverse_edges", e))?;
87 let _ = write_txn
88 .open_table(GRAPH_STATS)
89 .map_err(|e| redb_err("open graph_stats", e))?;
90 }
91 write_txn.commit().map_err(|e| redb_err("commit", e))?;
92
93 Ok(Self { db: Arc::new(db) })
94 }
95}
96
97#[cfg(test)]

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected