bug: build_ivf_model panics when num_partitions is unset

Open Beginner friendly
#9,428 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust

Research direction

Start in rust/lance/src/index/vector/ivf.rs at the public build_ivf_model entry point, then compare its parameter handling with build_ivf_model_and_pq and do_train_ivf_model. Verify that calling build_ivf_model with IvfBuildParams::default() no longer panics and uses the same fallback behavior as the sibling trainers.

Written by the indexing model from the issue text.

Description

bug
Description

build_ivf_model in rust/lance/src/index/vector/ivf.rs starts with

let num_partitions = params.num_partitions.unwrap();

IvfBuildParams::num_partitions is an Option (it is deprecated in favour of target_partition_size, and IvfBuildParams::default() leaves both unset), and build_ivf_model is public, so a caller that sets neither gets a panic out of a library call. The two sibling trainers in the same file already handle it: build_ivf_model_and_pq uses ivf_params.num_partitions.unwrap_or(32) with the comment "we use 32 as the default to avoid panicking, 32 is the default value before we make num_partitions optional", and do_train_ivf_model does the same.

The in-tree index build paths fill num_partitions in before calling this, so this is about the public function's own contract.

Expected behavior

Fall back to the same default the sibling trainers use rather than unwrapping None.

Lance version

13.0.0-beta.4 (main)

Language binding

Rust

Dominant language
Rust
Stars
7.1k
Forks
852
Avg merge
3d 18h
Merged PRs (30d)
252

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lance-format/lance

All issues in lance-format/lance

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.