danny0405 commented on code in PR #7626:
URL: https://github.com/apache/hudi/pull/7626#discussion_r1080788718


##########
hudi-client/hudi-flink-client/src/main/java/org/apache/hudi/client/HoodieFlinkWriteClient.java:
##########
@@ -496,4 +474,67 @@ private List<String> 
getAllExistingFileIds(HoodieFlinkTable<T> table, String par
     // because new commit is not complete. it is safe to mark all existing 
file Ids as old files
     return 
table.getSliceView().getLatestFileSlices(partitionPath).map(FileSlice::getFileId).distinct().collect(Collectors.toList());
   }
+
+  private List<WriteStatus> performWriteOperation(
+      List<HoodieRecord<T>> records,
+      String instantTime,
+      WriteOperationType operationType,
+      WriteOperationAction<T> writeOperationAction
+  ) {
+    HoodieFlinkTable<T> table = initTable(operationType, instantTime);
+    return performWriteOperation(table, records, instantTime, operationType, 
writeOperationAction);
+  }
+
+  private List<WriteStatus> performWriteOperation(
+      HoodieFlinkTable<T> table,
+      List<HoodieRecord<T>> records,
+      String instantTime,
+      WriteOperationType operationType,
+      WriteOperationAction<T> writeOperationAction
+  ) {
+    HoodieWriteMetadata<List<WriteStatus>> result;
+    HoodieWriteHandle<?, ?, ?, ?> writeHandle = null;
+    try {
+      writeHandle = getOrCreateWriteHandle(records.get(0), getConfig(), 
instantTime, table, records.listIterator());
+      result = writeOperationAction.perform(table, writeHandle);
+    } finally {
+      if (writeHandle != null) {
+        // ensure the writer is closed
+        ((MiniBatchHandle) writeHandle).closeGracefully();

Review Comment:
   Check for `writeHandle != null` seems better?



-- 
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: commits-unsubscr...@hudi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to