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

Function checkpoint_roundtrip

nodedb/src/engine/vector/sparse/index.rs:262–273  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

260
261 #[test]
262 fn checkpoint_roundtrip() {
263 let mut idx = SparseInvertedIndex::new();
264 idx.insert("doc1", &make_sv(&[(10, 0.5), (20, 0.8)]));
265 idx.insert("doc2", &make_sv(&[(20, 0.3), (30, 1.0)]));
266
267 let bytes = idx.checkpoint_to_bytes();
268 let restored = SparseInvertedIndex::from_checkpoint(&bytes).unwrap();
269
270 assert_eq!(restored.doc_count(), 2);
271 assert_eq!(restored.dim_count(), 3);
272 assert!(restored.resolve_doc_id(0).is_some());
273 }
274
275 #[test]
276 fn multiple_docs_same_dim() {

Callers

nothing calls this directly

Calls 3

make_svFunction · 0.70
insertMethod · 0.45
checkpoint_to_bytesMethod · 0.45

Tested by

no test coverage detected