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


##########
hudi-io/src/main/java/org/apache/hudi/io/hfile/HFileWriterImpl.java:
##########
@@ -216,7 +223,39 @@ private void writeBuffer(ByteBuffer buffer) throws 
IOException {
   private void initFileInfo() {
     fileInfoBlock.add(
         new String(MAX_MVCC_TS_KEY.getBytes(), StandardCharsets.UTF_8),
-        new byte[]{0});
+        toBytes(0L));
+  }
+
+  protected void finishFileInfo() {
+    // Record last key.
+    fileInfoBlock.add(
+        new String(LAST_KEY.getBytes(), StandardCharsets.UTF_8),
+        addKeyLength(lastKey));
+    fileInfoBlock.setStartOffsetInBuffForWrite(currentOffset);
+
+    // Average key length.
+    int avgKeyLen = totalNumberOfRecords == 0
+        ? 0 : (int) (totalKeyLength / totalNumberOfRecords);
+    fileInfoBlock.add(
+        new String(HFileInfo.AVG_KEY_LEN.getBytes(), StandardCharsets.UTF_8),
+        toBytes(avgKeyLen));
+    fileInfoBlock.add(
+        new String(HFileInfo.FILE_CREATION_TIME_TS.getBytes(), 
StandardCharsets.UTF_8),
+        toBytes(context.getFileCreateTime()));
+
+    // Average value length.
+    int avgValueLen = totalNumberOfRecords == 0
+        ? 0 : (int) (totalValueLength / totalNumberOfRecords);
+    fileInfoBlock.add(
+        new String(HFileInfo.AVG_VALUE_LEN.getBytes(), StandardCharsets.UTF_8),
+        toBytes(avgValueLen));
+
+    // NOTE: To make MVCC usage consistent cross different table versions,
+    // we should set following properties.
+    // After table versions <= 8 are deprecated, MVCC byte can be removed from 
key-value pair.
+    appendFileInfoIfNotExists(
+        new String(HFileInfo.KEY_VALUE_VERSION.getBytes(), 
StandardCharsets.UTF_8),
+        toBytes(KEY_VALUE_VERSION_WITH_MVCC_TS));

Review Comment:
   Fixed.



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