pgaref commented on a change in pull request #996:
URL: https://github.com/apache/orc/pull/996#discussion_r783916769



##########
File path: java/core/src/java/org/apache/orc/impl/RecordReaderUtils.java
##########
@@ -180,12 +180,18 @@ public static long estimateRgEndOffset(boolean 
isCompressed,
                                          boolean isLast,
                                          long nextGroupOffset,
                                          long streamLength) {
+    if (isCompressed && bufferSize <= 0) {
+      throw new IllegalArgumentException("BufferSize must be > 0 but was " + 
bufferSize);
+    }
     // figure out the worst case last location
     // if adjacent groups have the same compressed block offset then stretch 
the slop
-    // by factor of 2 to safely accommodate the next compression block.
-    // One for the current compression block and another for the next 
compression block.
+    // by a factor to safely accommodate the next compression block.
+    // We need to calculate the maximum number of blocks by bufferSize 
accordingly.
+    final int stretchFactor = isCompressed
+        ? 2 + (MAX_VALUES_LENGTH * MAX_BIT_WIDTH / 8 - 1) / bufferSize

Review comment:
       I am not sure I understand the formula here -- first of all we divide by 
8 is the conversion from bits to Bytes?
   
   I thought this is a round up operation but for different buffer sizes like 
512, 1024 this is evaluates to: ``2 + 0`` . What am I missing 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to