Skip to main content

validate_options

Function validate_options 

Source
pub fn validate_options(
    opts: &VectorAnnOptions,
    index_shape: IndexShape,
    collection_quant: VectorQuantization,
) -> Result<Option<CodecName>, RerankError>
Expand description

Validate the option combo against the index shape and the collection’s configured quantization. Returns the CodecName the search should use for rerank (None when the request is FP32-only), or RerankError::BadInput when the combination is invalid.

§Quantization contract

The codec is fixed at collection-creation time. collection_quant is the quantization that was declared via DDL; opts.quantization is the optional search-time override.

  • If opts.quantization is None: honor collection_quant — map it to a CodecName via codec_name_for_quant. Ternary / OPQ collection configs still surface as BadInput because they have no HNSW-integration path.
  • If opts.quantization is Some(q) and q == collection_quant: proceed (same as old behavior — the caller is being explicit about what the index already uses).
  • If opts.quantization is Some(q) and q != collection_quant: return RerankError::BadInput naming both the requested codec and the collection’s configured codec. Silent fallback is never allowed.
  • Some(VectorQuantization::None) against any non-None collection_quant is also a contradiction and returns BadInput.