fix(index): keep the trailing rows when shuffling a v2 buffer - #9246
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
Contributor
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The v2 shuffler now schedules the trailing logical batch and clamps both read passes to the file’s true row count, preserving every transformed vector without changing the legacy path. The regression covers a partial tail, a sub-batch file, and an exact multiple.
`IvfShuffler::total_batches` divides a v2 unsorted buffer's row count by `SHUFFLE_BATCH_SIZE`, so the trailing partial batch is never read; the legacy arm of the same function uses the exact `reader.num_batches()`. A buffer shorter than one batch counts as zero batches and `write_partitioned_shuffles` returns no files at all, while the caller goes on to commit an index whose fragment bitmap claims full coverage. `shuffle_vectors` is the only constructor passing `is_legacy = false`, reached from `IndicesBuilder.shuffle_transformed_vectors`, so a distributed index build silently loses those vectors. Round the batch count up, and clamp the row range both readers derive from it -- `ReadBatchParams::Range` rejects a range past the end of the file. ## Testing `cargo test --release -p lance-index --all-features shuffler::test`. The new `test_v2_shuffle_keeps_every_row` covers a partial trailing batch, a buffer shorter than one batch, and an exact multiple; on the old arithmetic the first loses 7 of 2055 rows and the second produces no output. `write_unsorted_stream` only emits v1 files, so the fixture writes the v2 buffer directly.
jackylee-ch
force-pushed
the
fix/ivf-shuffle-tail-rows
branch
from
September 15, 2026 12:00
5430659 to
39c9143
Compare
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.
IvfShuffler::total_batchesdivides a v2 unsorted buffer's row count bySHUFFLE_BATCH_SIZE, so the trailing partial batch is never read; the legacy arm uses the exactreader.num_batches(). A buffer shorter than one batch counts as zero batches andwrite_partitioned_shufflesreturns no files at all, while the caller goes on to commit an index whose fragment bitmap claims full coverage.shuffle_vectorsis the only constructor passingis_legacy = false, reached fromIndicesBuilder.shuffle_transformed_vectors, so a distributed index build silently loses those vectors.Round the batch count up, and clamp the row range both readers derive from it --
ReadBatchParams::Rangerejects a range past the end of the file.Testing
cargo test --release -p lance-index --all-features shuffler::test. The newtest_v2_shuffle_keeps_every_rowcovers a partial trailing batch, a buffer shorter than one batch, and an exact multiple; on the old arithmetic the first loses 7 of 2055 rows and the second produces no output.write_unsorted_streamonly emits v1 files, so the fixture writes the v2 buffer directly.