Skip to content

fix!(rust): panic when using FastPFOR::new#53

Merged
CommanderStorm merged 3 commits into
fast-pack:mainfrom
CommanderStorm:make-FPF-new-nonzero
Feb 13, 2026
Merged

fix!(rust): panic when using FastPFOR::new#53
CommanderStorm merged 3 commits into
fast-pack:mainfrom
CommanderStorm:make-FPF-new-nonzero

Conversation

@CommanderStorm

Copy link
Copy Markdown
Collaborator

Both page_size and block_size don't make sense to have as zero

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 NonZeroU32 for FastPFOR::new parameters.
  • Updates public constants (BLOCK_SIZE_128, BLOCK_SIZE_256, DEFAULT_PAGE_SIZE) to NonZeroU32.
  • 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::new to require NonZeroU32 is also a breaking API change for callers that currently pass u32 values/variables (including internal benches/tests). If the goal is to avoid division-by-zero panics, consider keeping the u32 signature and validating page_size/block_size inside the constructor (e.g., return a FastPForResult via a new try_new, or at least fail fast with a clear error/panic message). Also note that page_size/block_size fields are still pub 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.

Comment thread src/rust/integer_compression/fastpfor.rs Outdated
Comment thread src/rust/integer_compression/fastpfor.rs
@CommanderStorm CommanderStorm changed the title fix: panic when using FastPFOR::new fix!: panic when using FastPFOR::new Feb 13, 2026
@CommanderStorm CommanderStorm changed the title fix!: panic when using FastPFOR::new fix!(rust): panic when using FastPFOR::new Feb 13, 2026
@codecov

codecov Bot commented Feb 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@CommanderStorm
CommanderStorm merged commit 3993707 into fast-pack:main Feb 13, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants