Fokko commented on code in PR #3749:
URL: https://github.com/apache/parquet-java/pull/3749#discussion_r3923617121
##########
parquet-column/src/main/java/org/apache/parquet/column/values/rle/RunLengthBitPackingHybridDecoder.java:
##########
@@ -91,16 +94,25 @@ private void readNext() throws IOException {
int numGroups = header >>> 1;
currentCount = numGroups * 8;
LOG.debug("reading {} values BIT PACKED", currentCount);
- currentBuffer = new int[currentCount]; // TODO: reuse a buffer
- byte[] bytes = new byte[numGroups * bitWidth];
+ if (currentBuffer.length < currentCount) {
+ currentBuffer = new int[currentCount];
+ }
+ currentBufferPosition = 0;
+ int bytesRequired = numGroups * bitWidth;
+ if (packedBytes.length < bytesRequired) {
+ packedBytes = new byte[bytesRequired];
+ }
// At the end of the file RLE data though, there might not be that
many bytes left.
int bytesToRead = (int) Math.ceil(currentCount * bitWidth / 8.0);
bytesToRead = Math.min(bytesToRead, in.available());
- new DataInputStream(in).readFully(bytes, 0, bytesToRead);
Review Comment:
Nice, I always found it weird to wrap the stream with a new stream to read
the bytes 👍
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]