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?
I would also structure this a bit differently:
`// figure out the worst case last location
long slop = WORST_UNCOMPRESSED_SLOP;
// if adjacent groups have the same compressed block offset then stretch
the slop
// by a factor to safely accommodate the next compression block.
// We need to calculate the maximum number of blocks by bufferSize
accordingly.
if (isCompressed) {
final int stretchFactor = 2 + (MAX_VALUES_LENGTH * MAX_BIT_WIDTH / 8 -
1) / bufferSize;
slop = stretchFactor * (OutStream.HEADER_SIZE + bufferSize);
}`
--
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]