yihua commented on code in PR #12866:
URL: https://github.com/apache/hudi/pull/12866#discussion_r2106146117


##########
hudi-io/src/main/java/org/apache/hudi/io/hfile/HFileDataBlock.java:
##########
@@ -149,4 +169,56 @@ public boolean next(HFileCursor cursor, int 
blockStartOffsetInFile) {
   private boolean isAtFirstKey(int relativeOffset) {
     return relativeOffset == HFILEBLOCK_HEADER_SIZE;
   }
+
+  // ================ Below are for Write ================
+
+  boolean isEmpty() {
+    return entriesToWrite.isEmpty();
+  }
+
+  void add(byte[] key, byte[] value) {
+    KeyValueEntry kv = new KeyValueEntry(key, value);
+    // Assume all entries are sorted before write.
+    entriesToWrite.add(kv);
+  }
+
+  int getNumOfEntries() {
+    return entriesToWrite.size();
+  }
+
+  byte[] getFirstKey() {
+    return entriesToWrite.get(0).key;
+  }
+
+  byte[] getLastKeyContent() {
+    if (entriesToWrite.isEmpty()) {
+      return new byte[0];
+    }
+    return entriesToWrite.get(entriesToWrite.size() - 1).key;
+  }
+
+  @Override
+  protected ByteBuffer getUncompressedBlockDataToWrite() {
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    ByteBuffer dataBuf = ByteBuffer.allocate(context.getBlockSize());

Review Comment:
   i.e., `uncompressedDataBlockBytes` is calculated in `HFileWriterImpl#append`.



-- 
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