You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/06/17 12:42:57 UTC

[GitHub] [arrow-rs] HaoYang670 opened a new issue, #1901: `log2(0)` panicked at `'attempt to subtract with overflow', parquet/src/util/bit_util.rs:148:5`

HaoYang670 opened a new issue, #1901:
URL: https://github.com/apache/arrow-rs/issues/1901

   **Describe the bug**
   https://github.com/apache/arrow-rs/blob/master/parquet/src/util/bit_util.rs#L142-L155
   
   **To Reproduce**
   assert_eq!(log2(0), 0);
   
   **Expected behavior**
   Alter 1: return `Some(n)` when `input > 0` and `None` when `input == 0`;
   Alter 2: use the std function `core::num::log2` which has not been stable yet. https://doc.rust-lang.org/std/primitive.u64.html#method.log2
   Alter 3: panic when `input == 0` (follow the behavior of `num::core::log2`)
   Alter 4: return `0` when `input == 0` (follow the behavior of `num::core::log2`)
   
   
   **Additional context**
   Add any other context about the problem here.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] jhorstmann commented on issue #1901: `log2(0)` panicked at `'attempt to subtract with overflow', parquet/src/util/bit_util.rs:148:5`

Posted by GitBox <gi...@apache.org>.
jhorstmann commented on issue #1901:
URL: https://github.com/apache/arrow-rs/issues/1901#issuecomment-1158840184

   Since this seems to be only used for getting the width of bitpacked data, a faster way to calculate that is using the `leading_zeros` function. I contributed a similar improvements to parquet2 some time ago: https://github.com/jorgecarleitao/parquet2/blob/34aac65e433cff8bdd9fb07147cb551584a5415c/src/read/levels.rs#L3


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] HaoYang670 commented on issue #1901: `log2(0)` panicked at `'attempt to subtract with overflow', parquet/src/util/bit_util.rs:148:5`

Posted by GitBox <gi...@apache.org>.
HaoYang670 commented on issue #1901:
URL: https://github.com/apache/arrow-rs/issues/1901#issuecomment-1158844111

   Thank you @jhorstmann.
   Agree with you on using `leading_zeros`, and this is also how the std library implements:
   ```rust
                   #[inline]
                   pub const fn log2(self) -> u32 {
                       Self::BITS - 1 - self.leading_zeros()
                   }
   ```
   But the corner case is what should the behavior of `log2(0)` be.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] HaoYang670 commented on issue #1901: `log2(0)` panicked at `'attempt to subtract with overflow', parquet/src/util/bit_util.rs:148:5`

Posted by GitBox <gi...@apache.org>.
HaoYang670 commented on issue #1901:
URL: https://github.com/apache/arrow-rs/issues/1901#issuecomment-1158847977

   Ha! Maybe we could remove this function directly because we already have `num_required_bits` which provide same functionality. 
   https://github.com/apache/arrow-rs/blob/master/parquet/src/util/bit_util.rs#L180-L189


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] tustvold closed issue #1901: `log2(0)` panicked at `'attempt to subtract with overflow', parquet/src/util/bit_util.rs:148:5`

Posted by GitBox <gi...@apache.org>.
tustvold closed issue #1901: `log2(0)` panicked at `'attempt to subtract with overflow', parquet/src/util/bit_util.rs:148:5`
URL: https://github.com/apache/arrow-rs/issues/1901


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org