-
Notifications
You must be signed in to change notification settings - Fork 784
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
Refine the bit_util
of Parquet.
#1905
Conversation
Signed-off-by: remzi <[email protected]>
Signed-off-by: remzi <[email protected]>
Signed-off-by: remzi <[email protected]>
Signed-off-by: remzi <[email protected]>
Signed-off-by: remzi <[email protected]>
Signed-off-by: remzi <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #1905 +/- ##
==========================================
- Coverage 83.43% 83.41% -0.02%
==========================================
Files 203 214 +11
Lines 56969 56988 +19
==========================================
+ Hits 47531 47538 +7
- Misses 9438 9450 +12
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, nice improvement!
if num_bits >= 64 { | ||
return v; | ||
v | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this if block is actually necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1<<num_bits
would overflow if num_bits >= 64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aah yes, forgot you can't just overflow. I presume LLVM is smart enough to turn the if into a mask, i.e.
1 << (num_bits & 64)
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple test:
#[test]
fn test() {
fn do_test(shift: i32) {
let i = 1_u64;
println!("{}", i << shift);
}
do_test(65);
}
Output:
panicked at 'attempt to shift left with overflow'
Which issue does this PR close?
Closes #1901 .
What changes are included in this PR?
log2
, because:log2 (n)
==num_required_bits(n - 1)
log2
is unsafe, which panics when the input number is zero.num_required_bits
to u8div_ceil
trailing_bits
Are there any user-facing changes?
Yes.