MCPcopy Create free account
hub / github.com/KCORES/vector-db-bench / test_deterministic_shuffle

Function test_deterministic_shuffle

benchmark/src/runner.rs:163–183  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

161
162 #[test]
163 fn test_deterministic_shuffle() {
164 let queries: Vec<IndexedVector> = (0..20)
165 .map(|i| IndexedVector {
166 id: i,
167 vector: vec![i as f32],
168 })
169 .collect();
170
171 let shuffle = |seed: u64| -> Vec<usize> {
172 let mut indexed: Vec<(usize, &IndexedVector)> =
173 queries.iter().enumerate().collect();
174 let mut rng = rand::rngs::StdRng::seed_from_u64(seed);
175 indexed.shuffle(&mut rng);
176 indexed.iter().map(|(i, _)| *i).collect()
177 };
178
179 // Same seed → same order
180 assert_eq!(shuffle(42), shuffle(42));
181 // Different seed → different order (extremely unlikely to collide)
182 assert_ne!(shuffle(42), shuffle(99));
183 }
184}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected