the-other-tim-brown commented on code in PR #13977:
URL: https://github.com/apache/hudi/pull/13977#discussion_r2373642172
##########
hudi-io/src/main/java/org/apache/hudi/io/hfile/HFileDataBlock.java:
##########
@@ -206,10 +207,22 @@ byte[] getLastKeyContent() {
return entriesToWrite.get(entriesToWrite.size() - 1).key;
}
+ @Override
+ protected int calculateBufferCapacity() {
+ // Key length = 4,
+ // value length = 4,
+ // key length length = 2,
+ // 10 bytes for column family, timestamp, and key type,
+ // 1 byte for MVCC.
+ // Sum is 21 bytes.
+ // So the capacity of the buffer should be: longestEntrySize + 21.
+ return longestEntrySize + 21;
+ }
+
@Override
protected ByteBuffer getUncompressedBlockDataToWrite() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ByteBuffer dataBuf = ByteBuffer.allocate(context.getBlockSize());
+ ByteBuffer dataBuf = ByteBuffer.allocate(calculateBufferCapacity());
Review Comment:
Similarly, what is the point of having a ByteBuffer here if we are just
writing bytes to the ByteArrayOutputStream?
--
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]