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

Function restore_vector_checkpoints

nodedb/src/storage/snapshot_executor.rs:201–229  ·  view source on GitHub ↗
(
    data_dir: &Path,
    _core_id: usize,
    hnsw_indexes: &[crate::data::snapshot::HnswSnapshot],
)

Source from the content-addressed store, hash-verified

199}
200
201fn restore_vector_checkpoints(
202 data_dir: &Path,
203 _core_id: usize,
204 hnsw_indexes: &[crate::data::snapshot::HnswSnapshot],
205) -> crate::Result<u64> {
206 if hnsw_indexes.is_empty() {
207 return Ok(0);
208 }
209
210 let ckpt_dir = data_dir.join("vector-ckpt");
211 // no-objectstore: HNSW checkpoints are mmap'd locally for query hot path.
212 std::fs::create_dir_all(&ckpt_dir).map_err(crate::Error::Io)?;
213
214 let mut total_vectors = 0u64;
215 for idx in hnsw_indexes {
216 let key = format!("{}:{}:emb", idx.tenant_id, idx.collection);
217 let ckpt_path = ckpt_dir.join(format!("{key}.ckpt"));
218 let tmp_path = ckpt_dir.join(format!("{key}.ckpt.tmp"));
219 nodedb_wal::segment::atomic_write_fsync(&tmp_path, &ckpt_path, &idx.checkpoint_bytes)
220 .map_err(crate::Error::Wal)?;
221 total_vectors += 1;
222 }
223
224 info!(
225 collections = hnsw_indexes.len(),
226 "vector checkpoints restored"
227 );
228 Ok(total_vectors)
229}
230
231fn restore_crdt_checkpoints(
232 data_dir: &Path,

Callers 1

restore_core_stateFunction · 0.85

Calls 3

atomic_write_fsyncFunction · 0.85
joinMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected