fix!(rust): panic when using FastPFOR::new#53
Merged
CommanderStorm merged 3 commits intoFeb 13, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent panics caused by constructing FastPFOR with a page_size or block_size of zero by making these values non-zero at the type level.
Changes:
- Introduces
NonZeroU32forFastPFOR::newparameters. - Updates public constants (
BLOCK_SIZE_128,BLOCK_SIZE_256,DEFAULT_PAGE_SIZE) toNonZeroU32. - Adjusts one internal comparison to account for
NonZeroU32(.get()).
Comments suppressed due to low confidence (1)
src/rust/integer_compression/fastpfor.rs:152
- Changing
FastPFOR::newto requireNonZeroU32is also a breaking API change for callers that currently passu32values/variables (including internal benches/tests). If the goal is to avoid division-by-zero panics, consider keeping theu32signature and validatingpage_size/block_sizeinside the constructor (e.g., return aFastPForResultvia a newtry_new, or at least fail fast with a clear error/panic message). Also note thatpage_size/block_sizefields are stillpub u32, so invariants can still be violated after construction.
pub fn new(page_size: NonZeroU32, block_size: NonZeroU32) -> FastPFOR {
let page_size = page_size.get();
let block_size = block_size.get();
FastPFOR {
page_size,
block_size,
bytes_container: bytebuffer::ByteBuffer::new(3 * page_size / block_size + page_size),
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
FastPFOR::newFastPFOR::new
FastPFOR::newFastPFOR::new
nyurik
approved these changes
Feb 13, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Both
page_sizeandblock_sizedon't make sense to have as zero