fix: fixed integer overflow in ExpUnrolledLinkedList for large datasets #2735
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.
What
Changes
ExpUnrolledLinkedList::block_numfromu16tou32to prevent integer overflow when indexing large datasets. The structure now supports up to ~4 billion blocks (128 TB) instead of just 65,535 blocks (2.1 GB).Why
Users were experiencing index creation failures with the error
"mid > len"when creating BM25 indexes on tables with large integer arrays (100k rows × 6,700 elements = 660M operations). This required ~103,000 blocks, exceeding theu16::MAXlimit of 65,535, causing:"mid > len"errors"attempt to add with overflow"How
block_numtype:u16→u32(supports 65,536× more blocks)checked_add()inincrement_num_blocks()assert!()inread_to_end()Tests
Added 8 tests to verify the fix.