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

Function fetch_single_node_no_prefetch

nodedb/src/data/vamana_fetcher.rs:318–349  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

316
317 #[test]
318 fn fetch_single_node_no_prefetch() {
319 let dir = tempfile::tempdir().unwrap();
320 let vecs = vec![
321 vec![1.0_f32, 2.0, 3.0, 4.0],
322 vec![5.0_f32, 6.0, 7.0, 8.0],
323 vec![9.0_f32, 10.0, 11.0, 12.0],
324 ];
325 let dim = 4u32;
326 let n = vecs.len() as u64;
327
328 // Build a layout with adjacency_offset = HEADER_BYTES = 64, r = 0.
329 // vectors_offset = 64 + 0 * 4 * 3 = 64.
330 // We write the vectors block starting at byte 0 of our test file,
331 // so we create a layout where vectors_offset = 0.
332 let layout = VamanaStorageLayout {
333 dim,
334 r: 0,
335 alpha: 1.2,
336 num_nodes: n,
337 entry: 0,
338 adjacency_offset: 0,
339 vectors_offset: 0,
340 };
341
342 let path = dir.path().join("vamana.vec");
343 write_vectors_file(&path, &vecs);
344
345 let mut fetcher = IoUringNodeFetcher::open(&path, layout, 8).unwrap();
346
347 let got = fetcher.fetch_fp32(1).unwrap();
348 assert_eq!(got, vecs[1], "node 1 vector mismatch");
349 }
350
351 #[test]
352 fn prefetch_batch_then_fetch() {

Callers

nothing calls this directly

Calls 6

write_vectors_fileFunction · 0.85
joinMethod · 0.80
openFunction · 0.50
lenMethod · 0.45
pathMethod · 0.45
fetch_fp32Method · 0.45

Tested by

no test coverage detected