Skip to content

bug: load_or_build_quantizer validates its params after sampling, and carries a dead match arm #9367

Description

@LuciferYang

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions