LABEL: bug
Description
IvfIndexBuilder::load_or_build_quantizer in rust/lance/src/index/vector/builder.rs returns early when a quantizer is already present:
if self.quantizer.is_some() {
return Ok(self.quantizer.clone().unwrap());
}
Everything after that point therefore runs with self.quantizer == None, which leaves two dead things behind and one check in the wrong place:
- The tail match
match &self.quantizer { Some(q) => q.clone(), None => { ... } } can only ever take its None arm.
- That
None arm holds the only validation of quantizer_params, so a builder constructed with neither params nor a quantizer samples the training data and computes residuals first, and only then errors.
sample_size_hint's None => 256 * 256 arm is commented "here it must be retrain", but retrain arrives with quantizer: Some(..) and returns at the top, so that default is unreachable too.
None of this is user-visible: the params-missing case is reachable only by calling IvfIndexBuilder::new(.., None, ..) explicitly, and it already ended in the same error, just after the sampling work. It is dead code plus a late check, which rust/CLAUDE.md asks to remove rather than keep.
Expected behavior
Validate the params once, before the sampling and residual work, and drop the arms that cannot be taken.
Lance version
13.0.0-beta.4 (main)
Language binding
Rust
LABEL: bug
Description
IvfIndexBuilder::load_or_build_quantizerinrust/lance/src/index/vector/builder.rsreturns early when a quantizer is already present:Everything after that point therefore runs with
self.quantizer == None, which leaves two dead things behind and one check in the wrong place:match &self.quantizer { Some(q) => q.clone(), None => { ... } }can only ever take itsNonearm.Nonearm holds the only validation ofquantizer_params, so a builder constructed with neither params nor a quantizer samples the training data and computes residuals first, and only then errors.sample_size_hint'sNone => 256 * 256arm is commented "here it must be retrain", but retrain arrives withquantizer: Some(..)and returns at the top, so that default is unreachable too.None of this is user-visible: the params-missing case is reachable only by calling
IvfIndexBuilder::new(.., None, ..)explicitly, and it already ended in the same error, just after the sampling work. It is dead code plus a late check, whichrust/CLAUDE.mdasks to remove rather than keep.Expected behavior
Validate the params once, before the sampling and residual work, and drop the arms that cannot be taken.
Lance version
13.0.0-beta.4 (main)
Language binding
Rust