linliu-code commented on code in PR #9809:
URL: https://github.com/apache/hudi/pull/9809#discussion_r1341920220


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/HoodieMergeHandle.java:
##########
@@ -310,8 +310,19 @@ private boolean writeRecord(HoodieRecord<T> newRecord, 
Option<HoodieRecord> comb
     }
     try {
       if (combineRecord.isPresent() && !combineRecord.get().isDelete(schema, 
config.getProps()) && !isDelete) {
-        writeToFile(newRecord.getKey(), combineRecord.get(), schema, prop, 
preserveMetadata && useWriterSchemaForCompaction);
-        recordsWritten++;
+        // Last-minute check.
+        Pair<Boolean, Boolean> decision = 
recordMerger.shouldFlush(combineRecord.get(), schema);
+
+        if (decision.getLeft()) { // CASE (1): Flush the merged record.
+          writeToFile(newRecord.getKey(), combineRecord.get(), schema, prop, 
preserveMetadata && useWriterSchemaForCompaction);
+          recordsWritten++;
+        } else {
+          if (decision.getRight()) { // CASE (2): Flush the old record only.
+            return false;

Review Comment:
   @danny0405 since the returned value is only used in mergehandle, we should 
add some tests for mergehandle. Let me find how to do that.



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