()
| 515 | /// Part F.1: codec path uses sidecar distances rather than FP32 fetch_vector. |
| 516 | #[test] |
| 517 | fn codec_path_uses_sidecar() { |
| 518 | // StubCodec uses Binary name, so request VectorQuantization::Binary. |
| 519 | let mut sc = make_sidecar(CodecName::Binary); |
| 520 | // Insert 3 vectors: distances from [0,0] are 1.0, 2.0, 3.0. |
| 521 | sc.encode_and_insert(1, &[1.0, 0.0]).unwrap(); |
| 522 | sc.encode_and_insert(2, &[0.0, 2.0]).unwrap(); |
| 523 | sc.encode_and_insert(3, &[3.0, 0.0]).unwrap(); |
| 524 | |
| 525 | let candidates = vec![make(1), make(2), make(3)]; |
| 526 | let opts = opts_with_quant(VectorQuantization::Binary); |
| 527 | |
| 528 | // fetch_vector should never be called in codec path — pass a closure |
| 529 | // that panics to confirm. |
| 530 | let result = rerank( |
| 531 | candidates, |
| 532 | &[0.0, 0.0], |
| 533 | DistanceMetric::L2, |
| 534 | 3, |
| 535 | &opts, |
| 536 | Some(&sc), |
| 537 | |_id| panic!("fetch_vector must not be called in codec path"), |
| 538 | ) |
| 539 | .unwrap(); |
| 540 | |
| 541 | assert_eq!(result.len(), 3); |
| 542 | // Distances: id=1 → 1.0, id=2 → 2.0, id=3 → 3.0 |
| 543 | assert_eq!(result[0].id, 1); |
| 544 | assert_eq!(result[1].id, 2); |
| 545 | assert_eq!(result[2].id, 3); |
| 546 | assert!((result[0].distance - 1.0).abs() < 1e-5); |
| 547 | } |
| 548 | |
| 549 | /// Part F.2: opts requests codec but sidecar is None → BadInput. |
| 550 | #[test] |
nothing calls this directly
no test coverage detected