wzx140 commented on code in PR #7769:
URL: https://github.com/apache/hudi/pull/7769#discussion_r1089861400


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/commit/HoodieMergeHelper.java:
##########
@@ -139,20 +139,25 @@ public void runMerge(HoodieTable<?, ?, ?, ?> table,
         recordSchema = isPureProjection ? writerSchema : readerSchema;
       }
 
+      boolean isBufferingRecords = 
ExecutorFactory.isBufferingRecords(writeConfig);
+
       wrapper = ExecutorFactory.create(writeConfig, recordIterator, new 
UpdateHandler(mergeHandle), record -> {
-        // NOTE: Record have to be cloned here to make sure if it holds 
low-level engine-specific
-        //       payload pointing into a shared, mutable (underlying) buffer 
we get a clean copy of
-        //       it since these records will be put into queue of 
QueueBasedExecutorFactory.
+        HoodieRecord newRecord;
         if (shouldRewriteInWriterSchema) {
           try {
-            return record.rewriteRecordWithNewSchema(recordSchema, 
writeConfig.getProps(), writerSchema).copy();
+            newRecord = record.rewriteRecordWithNewSchema(recordSchema, 
writeConfig.getProps(), writerSchema);
           } catch (IOException e) {
             LOG.error("Error rewrite record with new schema", e);
             throw new HoodieException(e);
           }
         } else {
-          return record.copy();
+          newRecord = record;
         }
+
+        // NOTE: Record have to be cloned here to make sure if it holds 
low-level engine-specific
+        //       payload pointing into a shared, mutable (underlying) buffer 
we get a clean copy of
+        //       it since these records will be put into queue of 
QueueBasedExecutorFactory.
+        return isBufferingRecords ? newRecord.copy() : newRecord;

Review Comment:
   :thumbsup:



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