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

Method from_snapshot

nodedb-vector/src/collection/payload_index.rs:443–464  ·  view source on GitHub ↗

Restore from a checkpoint snapshot.

(snap: PayloadIndexSetSnapshot)

Source from the content-addressed store, hash-verified

441
442 /// Restore from a checkpoint snapshot.
443 pub fn from_snapshot(snap: PayloadIndexSetSnapshot) -> Self {
444 let mut indexes = HashMap::new();
445 for idx_snap in snap.indexes {
446 let mut bitmaps = PayloadIndexBitmaps::for_kind(idx_snap.kind);
447 for (key_bytes, bm_bytes) in idx_snap.entries {
448 let Ok(key) = zerompk::from_msgpack::<PayloadKey>(&key_bytes) else {
449 continue;
450 };
451 let Ok(bm) = RoaringBitmap::deserialize_from(bm_bytes.as_slice()) else {
452 continue;
453 };
454 *bitmaps.entry_or_default(key) = bm;
455 }
456 let idx = PayloadIndex {
457 field: idx_snap.field.clone(),
458 kind: idx_snap.kind,
459 bitmaps,
460 };
461 indexes.insert(idx_snap.field, idx);
462 }
463 Self { indexes }
464 }
465}
466
467// ── Tests ─────────────────────────────────────────────────────────────────────

Callers

nothing calls this directly

Calls 4

entry_or_defaultMethod · 0.80
as_sliceMethod · 0.45
cloneMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected