pgaref commented on pull request #714:
URL: https://github.com/apache/orc/pull/714#issuecomment-857693888


   > @pgaref Also, for a sanity check, I ran this locally:
   > 
   > ```java
   >   public static int bs(int bs)
   >   {
   >     final int kb4 = 4 * 1024;
   >     final int kb256 = 256 * 1024;
   > 
   >     final int pow2 = bs == 1 ? 1 : Integer.highestOneBit(bs - 1) * 2;
   >     return Math.min(kb256, Math.max(kb4, pow2));
   >   }
   > 
   >   private static int getClosestBufferSize(int estBufferSize)
   >   {
   >     final int kb4 = 4 * 1024;
   >     final int kb8 = 8 * 1024;
   >     final int kb16 = 16 * 1024;
   >     final int kb32 = 32 * 1024;
   >     final int kb64 = 64 * 1024;
   >     final int kb128 = 128 * 1024;
   >     final int kb256 = 256 * 1024;
   >     if (estBufferSize <= kb4)
   >     {
   >       return kb4;
   >     } else if (estBufferSize <= kb8)
   >     {
   >       return kb8;
   >     } else if (estBufferSize <= kb16)
   >     {
   >       return kb16;
   >     } else if (estBufferSize <= kb32)
   >     {
   >       return kb32;
   >     } else if (estBufferSize <= kb64)
   >     {
   >       return kb64;
   >     } else if (estBufferSize <= kb128)
   >     {
   >       return kb128;
   >     } else
   >     {
   >       return kb256;
   >     }
   >   }
   > 
   >   public static void main(String[] args) throws IOException, 
URISyntaxException
   >   {
   >     final int kb256 = 256 * 1024;
   >     
   >     for (int i = 0; i <= kb256 * 16; i++) {
   >       int r1 = bs(i);
   >       int r2 = getClosestBufferSize(i);
   >       if (r1 != r2) {
   >         System.out.print(i);
   >       }
   >     }
   > ```
   
   Got it thanks!
   
   One more question: what is the point of 
   > Integer.highestOneBit(size - 1) * 2 ?
   
   looks to me like this can be simplified to Integer.highestOneBit(size) as * 
2 is << 1 right?


-- 
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:
[email protected]


Reply via email to