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

Function insert_and_search

nodedb-vector/src/flat.rs:342–354  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

340
341 #[test]
342 fn insert_and_search() {
343 let mut idx = FlatIndex::new(3, DistanceMetric::L2);
344 for i in 0..100u32 {
345 idx.insert(vec![i as f32, 0.0, 0.0]);
346 }
347 assert_eq!(idx.len(), 100);
348 assert_eq!(idx.live_count(), 100);
349
350 let results = idx.search(&[50.0, 0.0, 0.0], 3);
351 assert_eq!(results.len(), 3);
352 assert_eq!(results[0].id, 50);
353 assert!(results[0].distance < 0.01);
354 }
355
356 #[test]
357 fn delete_excludes_from_search() {

Callers

nothing calls this directly

Calls 2

insertMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected