Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: override size_hint for BitIterator to return the exact remaining size #6495

Merged
merged 1 commit into from
Oct 2, 2024

Conversation

Beihao-Zhou
Copy link
Member

Which issue does this PR close?

Closes #6480

Rationale for this change

The BitIterator implementation was missing a proper size_hint method, which caused it to panic when used in conjunction with ExactSizeIterator. The ExactSizeIterator trait requires that size_hint() always return a precise number of elements, and failing to do so caused a mismatch in the expected and actual sizes, leading to an assertion failure.

What changes are included in this PR?

This PR introduces a fix by overriding the size_hint() method in BitIterator to return the correct remaining number of bits, ensuring compatibility with ExactSizeIterator and preventing panics.

Are there any user-facing changes?

No breaking changes to public APIs.

@github-actions github-actions bot added the arrow Changes to the arrow crate label Oct 2, 2024
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @Beihao-Zhou and @mbrobbel for the review ❤️

Copy link
Contributor

@Jefffrey Jefffrey left a comment

Choose a reason for hiding this comment

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

Looks good, thanks

@Jefffrey Jefffrey merged commit 581c647 into apache:master Oct 2, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BitIterator panics when retrieving length
4 participants