test(index): size the block-max-score fixture so its assertion can fail - #9249
Open
jackylee-ch wants to merge 1 commit into
Open
jackylee-ch wants to merge 1 commit into
jackylee-ch wants to merge 1 commit into
Conversation
`test_block_max_scores_capacity_matches_block_count` guards the `Vec::with_capacity(num_blocks)` in `calculate_block_max_scores_with_block_size`, but its fixture produced four blocks and `Vec<f32>` allocates a minimum of four elements. The capacity assertion therefore held for any hint of four or fewer, including none at all: dropping the hint entirely left the test green. It still caught the original over-allocation the assertion was added for, since that reserved one slot per document rather than per block. Grow the fixture past that minimum and assert the block count exceeds it, so a later shrink cannot quietly restore the coincidence. Also parametrize over both entries of `VALID_BLOCK_SIZES`: the block count is derived from the `block_size` argument, and only the 128 path was reached through the wrapper. ## Testing `cargo test --release -p lance-index --all-features` for the module (5 passed), plus `cargo fmt` and clippy with `-D warnings`. With the capacity hint removed the fixture now allocates 8 against 6 expected blocks and both cases fail.
Contributor
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The larger fixture makes the capacity regression observable, and parametrizing the block-size-dependent path covers both supported sizes. This is a focused guard for the indexing-memory optimization established in #5718.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test_block_max_scores_capacity_matches_block_countguards theVec::with_capacity(num_blocks)incalculate_block_max_scores_with_block_size, but its fixture produced four blocks andVec<f32>allocates a minimum of four elements. The capacity assertion therefore held for any hint of four or fewer, including none at all: dropping the hint entirely left the test green. It still caught the original over-allocation the assertion was added for, since that reserved one slot per document rather than per block.Grow the fixture past that minimum and assert the block count exceeds it, so a later shrink cannot quietly restore the coincidence. Also parametrize over both entries of
VALID_BLOCK_SIZES: the block count is derived from theblock_sizeargument, and only the 128 path was reached through the wrapper.Testing
cargo test --release -p lance-index --all-featuresfor the module (5 passed), pluscargo fmtand clippy with-D warnings. With the capacity hint removed the fixture now allocates 8 against 6 expected blocks and both cases fail.