You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@orc.apache.org by GitBox <gi...@apache.org> on 2021/06/09 13:42:30 UTC

[GitHub] [orc] belugabehr edited a comment on pull request #714: ORC-812: Simplify getClosestBufferSize in Writer

belugabehr edited a comment on pull request #714:
URL: https://github.com/apache/orc/pull/714#issuecomment-857703731


   Hey @pgaref You'll have to pull out pen-and-paper and play with it :)
   
   `<< 1` simply doubles the value.  We're not interested in doubling, we're interesting in finding the next power of 2. 
   
   `3  << 1 = 6 (not power of 2)`
   `3 - 1 = 2 = 0x02 = 2 is highest one bit  ===>  2 * 2 = 4` ✔️ 
   
   
   Consider a value of `2`:
   `Integer.highestOneBit(size) = 0x02 ====> 2 * 2 = 4` ❌ (The nearest power of 2 is 2)


-- 
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.

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