| 114 | use crate::mmap_segment::MmapVectorSegment; |
| 115 | |
| 116 | fn make_backing(dim: usize, vecs: &[Vec<f32>]) -> PlainMmapBacking { |
| 117 | let dir = tempdir().unwrap(); |
| 118 | let path = dir.path().join("test.ndvs"); |
| 119 | |
| 120 | let refs: Vec<&[f32]> = vecs.iter().map(|v| v.as_slice()).collect(); |
| 121 | let surrogates: Vec<u64> = (0..vecs.len() as u64).collect(); |
| 122 | |
| 123 | let seg = |
| 124 | MmapVectorSegment::create_with_surrogates(&path, dim, &refs, &surrogates).unwrap(); |
| 125 | |
| 126 | // Keep the tempdir alive by leaking it for the test duration. |
| 127 | // The backing borrows from the mmap, which is already self-contained |
| 128 | // (fd kept open by the segment); dir can be dropped. |
| 129 | drop(dir); |
| 130 | |
| 131 | PlainMmapBacking::new(seg) |
| 132 | } |
| 133 | |
| 134 | #[test] |
| 135 | fn plain_backing_basic_roundtrip() { |