()
| 350 | |
| 351 | #[test] |
| 352 | fn prefetch_batch_then_fetch() { |
| 353 | let dir = tempfile::tempdir().unwrap(); |
| 354 | let vecs: Vec<Vec<f32>> = (0..8u32) |
| 355 | .map(|i| vec![i as f32, (i + 1) as f32, (i + 2) as f32, (i + 3) as f32]) |
| 356 | .collect(); |
| 357 | let dim = 4u32; |
| 358 | let n = vecs.len() as u64; |
| 359 | |
| 360 | let layout = VamanaStorageLayout { |
| 361 | dim, |
| 362 | r: 0, |
| 363 | alpha: 1.2, |
| 364 | num_nodes: n, |
| 365 | entry: 0, |
| 366 | adjacency_offset: 0, |
| 367 | vectors_offset: 0, |
| 368 | }; |
| 369 | |
| 370 | let path = dir.path().join("vamana.vec"); |
| 371 | write_vectors_file(&path, &vecs); |
| 372 | |
| 373 | let mut fetcher = IoUringNodeFetcher::open(&path, layout, 8).unwrap(); |
| 374 | |
| 375 | // Pre-fetch nodes 0..4 in one batch. |
| 376 | fetcher.prefetch_batch(&[0, 1, 2, 3]); |
| 377 | |
| 378 | for i in 0u32..4 { |
| 379 | let got = fetcher.fetch_fp32(i).unwrap(); |
| 380 | assert_eq!( |
| 381 | got, vecs[i as usize], |
| 382 | "node {i} vector mismatch after prefetch" |
| 383 | ); |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | #[test] |
| 388 | fn out_of_range_returns_none() { |
nothing calls this directly
no test coverage detected