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

Method checkpoint_to_bytes

nodedb/src/engine/vector/sparse/index.rs:144–171  ·  view source on GitHub ↗

Serialize to bytes for checkpoint persistence.

(&self)

Source from the content-addressed store, hash-verified

142
143 /// Serialize to bytes for checkpoint persistence.
144 pub fn checkpoint_to_bytes(&self) -> Vec<u8> {
145 let snapshot = SparseIndexSnapshot {
146 next_id: self.next_id,
147 documents: self
148 .doc_id_reverse
149 .iter()
150 .map(|(&id, name)| {
151 let dims = self.doc_dims.get(&id).cloned().unwrap_or_default();
152 let entries: Vec<(u32, f32)> = dims
153 .iter()
154 .filter_map(|&dim| {
155 self.postings.get(&dim).and_then(|list| {
156 list.iter()
157 .find(|&&(doc, _)| doc == id)
158 .map(|&(_, w)| (dim, w))
159 })
160 })
161 .collect();
162 SparseDocSnapshot {
163 internal_id: id,
164 doc_id: name.clone(),
165 entries,
166 }
167 })
168 .collect(),
169 };
170 zerompk::to_msgpack_vec(&snapshot).unwrap_or_default()
171 }
172
173 /// Restore from checkpoint bytes.
174 pub fn from_checkpoint(bytes: &[u8]) -> Option<Self> {

Callers 8

export_snapshotMethod · 0.45
rebuild_hnsw_threadFunction · 0.45
rebuild_csr_threadFunction · 0.45
start_csr_rebuildMethod · 0.45
checkpoint_roundtripFunction · 0.45

Calls 5

collectMethod · 0.80
iterMethod · 0.45
getMethod · 0.45
findMethod · 0.45
cloneMethod · 0.45

Tested by 1

checkpoint_roundtripFunction · 0.36