MCPcopy Index your code
hub / github.com/InfinitiBit/graphbit / test_vector_index_update

Function test_vector_index_update

core/src/memory/vector.rs:161–177  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

159
160 #[tokio::test]
161 async fn test_vector_index_update() {
162 let index = VectorIndex::new();
163 let id = MemoryId::new();
164
165 index.insert(id.clone(), vec![1.0, 0.0, 0.0]).await;
166
167 // Update embedding
168 index.update(&id, vec![0.0, 1.0, 0.0]).await;
169
170 // Now id should be similar to [0, 1, 0] rather than [1, 0, 0]
171 let results = index
172 .search(&[0.0, 1.0, 0.0], 10, 0.5)
173 .await
174 .expect("search ok");
175 assert_eq!(results.len(), 1);
176 assert!((results[0].1 - 1.0).abs() < 0.01);
177 }
178
179 #[tokio::test]
180 async fn test_vector_index_clear() {

Callers

nothing calls this directly

Calls 4

insertMethod · 0.80
cloneMethod · 0.80
updateMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected