pub fn rerank<'v, F>(
candidates: Vec<Candidate>,
query: &[f32],
metric: DistanceMetric,
k: usize,
opts: &VectorAnnOptions,
sidecar: Option<&CodecSidecar>,
fetch_vector: F,
) -> Result<Vec<Ranked>, RerankError>Expand description
Shared rerank pipeline. Both Origin and Lite call this after their index-level coarse search.
Callers use opts.oversample to compute fetch_k before pre-fetching from HNSW;
this function receives whatever candidates were fetched and reranks by exact distance.
When opts.quantization is None (or VectorQuantization::None), the FP32 path is used:
fetch_vector is called once per candidate and must return the stored full-precision vector.
Returning None for any id is a hard inconsistency error.
When opts.quantization is Some(_), a CodecSidecar must be provided. The sidecar
encodes query and stored vectors; fetch_vector is not called in this path.
When opts.query_dim = Some(d), the FP32 path applies Matryoshka truncated-distance
reranking using only the first d components. d must satisfy 0 < d <= query.len().
query_dim combined with quantization is not supported — return BadInput if both set.
target_recall, oversample, and meta_token_budget are accepted via opts but not
honored here — callers handle those before calling this function.