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

Method export_snapshot

nodedb/src/data/executor/snapshot.rs:12–77  ·  view source on GitHub ↗

Export the current state of all engines into a serializable snapshot. This captures the complete Data Plane state for this core: redb tables (sparse + edge), in-memory HNSW indexes, and CRDT state.

(&self)

Source from the content-addressed store, hash-verified

10 /// This captures the complete Data Plane state for this core:
11 /// redb tables (sparse + edge), in-memory HNSW indexes, and CRDT state.
12 pub fn export_snapshot(&self) -> crate::Result<crate::data::snapshot::CoreSnapshot> {
13 use crate::data::snapshot::*;
14
15 let sparse_documents: Vec<KvPair> = self
16 .sparse
17 .export_documents()?
18 .into_iter()
19 .map(|(k, v)| KvPair { key: k, value: v })
20 .collect();
21
22 let sparse_indexes: Vec<KvPair> = self
23 .sparse
24 .export_indexes()?
25 .into_iter()
26 .map(|(k, v)| KvPair { key: k, value: v })
27 .collect();
28
29 let edges: Vec<TenantKvPair> = self
30 .edge_store
31 .export_edges()?
32 .into_iter()
33 .map(|(tid, k, v)| TenantKvPair {
34 tenant_id: tid.as_u64(),
35 key: k,
36 value: v,
37 })
38 .collect();
39
40 let hnsw_indexes: Vec<HnswSnapshot> = self
41 .vector_collections
42 .iter()
43 .filter_map(|(key, coll)| {
44 let checkpoint_bytes =
45 coll.checkpoint_to_bytes(self.vector_checkpoint_kek.as_ref());
46 if checkpoint_bytes.is_empty() {
47 return None;
48 }
49 Some(HnswSnapshot {
50 tenant_id: key.0.as_u64(),
51 collection: key.1.clone(),
52 checkpoint_bytes,
53 })
54 })
55 .collect();
56
57 let crdt_snapshots: Vec<CrdtSnapshot> = self
58 .crdt_engines
59 .iter()
60 .map(|(tid, engine)| {
61 Ok(CrdtSnapshot {
62 tenant_id: tid.as_u64(),
63 peer_id: engine.peer_id(),
64 snapshot_bytes: engine.export_snapshot_bytes()?,
65 })
66 })
67 .collect::<crate::Result<Vec<_>>>()?;
68
69 Ok(CoreSnapshot {

Callers 2

Calls 12

collectMethod · 0.80
export_documentsMethod · 0.80
export_indexesMethod · 0.80
export_edgesMethod · 0.80
export_snapshot_bytesMethod · 0.80
as_u64Method · 0.45
iterMethod · 0.45
checkpoint_to_bytesMethod · 0.45
as_refMethod · 0.45
is_emptyMethod · 0.45
cloneMethod · 0.45
peer_idMethod · 0.45

Tested by

no test coverage detected