| 7 | |
| 8 | #[tokio::test] |
| 9 | async fn vector() { |
| 10 | let path = "."; |
| 11 | let storage_name = "vectors"; |
| 12 | let total_page_size = 500; |
| 13 | let stype = crate::StorageType::RamCopies; |
| 14 | let off_reporter = true; |
| 15 | |
| 16 | let ops = Options::new(path, storage_name, total_page_size, stype, off_reporter); |
| 17 | let vstorage = VecStorage::open(ops).await.unwrap(); |
| 18 | |
| 19 | |
| 20 | let vid = String::from("vector_id"); |
| 21 | let vec =vec![1.2, 1.3, 0.5, 0.4]; |
| 22 | |
| 23 | |
| 24 | vstorage.insert(vid.clone(), vec.clone()).await.unwrap(); |
| 25 | |
| 26 | |
| 27 | let (vid2, vec2) = vstorage.lookup(&vid).unwrap(); |
| 28 | |
| 29 | assert_eq!(vid, vid2); |
| 30 | |
| 31 | assert_eq!(Vector(vec).cosine_similarity(&vec2).unwrap(), 0f32) |
| 32 | } |
| 33 | |
| 34 | |
| 35 | |