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

Function reopen_roundtrip

nodedb-vector/src/mmap_segment/reader.rs:524–542  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

522
523 #[test]
524 fn reopen_roundtrip() {
525 let dir = tempfile::tempdir().unwrap();
526 let path = dir.path().join("reopen.vseg");
527
528 let vectors: Vec<Vec<f32>> = (0..100)
529 .map(|i| vec![i as f32, (i as f32).sin(), (i as f32).cos()])
530 .collect();
531 let refs: Vec<&[f32]> = vectors.iter().map(|v| v.as_slice()).collect();
532 let sids: Vec<u64> = (0u64..100).collect();
533
534 MmapVectorSegment::create_with_surrogates(&path, 3, &refs, &sids).unwrap();
535
536 let seg = MmapVectorSegment::open(&path).unwrap();
537 assert_eq!(seg.count(), 100);
538 for (i, v) in vectors.iter().enumerate() {
539 assert_eq!(seg.get_vector(i as u32).unwrap(), v.as_slice());
540 assert_eq!(seg.get_surrogate_id(i as u32).unwrap(), i as u64);
541 }
542 }
543
544 #[test]
545 fn no_surrogates_defaults_to_zero() {

Callers

nothing calls this directly

Calls 6

joinMethod · 0.80
collectMethod · 0.80
openFunction · 0.50
pathMethod · 0.45
iterMethod · 0.45
as_sliceMethod · 0.45

Tested by

no test coverage detected