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


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java:
##########
@@ -1159,10 +1161,27 @@ protected boolean 
validateTimelineBeforeSchedulingCompaction(Option<String> inFl
    * @param writeStatuses {@code WriteStatus} from the write operation
    */
   private HoodieData<HoodieRecord> 
getRecordIndexUpdates(HoodieData<WriteStatus> writeStatuses) {
-    return writeStatuses.flatMap(writeStatus -> {
-      List<HoodieRecord> recordList = new LinkedList<>();
-      for (HoodieRecordDelegate recordDelegate : 
writeStatus.getWrittenRecordDelegates()) {
-        if (!writeStatus.isErrored(recordDelegate.getHoodieKey())) {
+    // 1. List<HoodieRecordDelegate>
+    // 2. Reduce by key: accept keys only when new location is not
+    return writeStatuses.map(writeStatus -> 
writeStatus.getWrittenRecordDelegates().stream()
+            .map(recordDelegate -> Pair.of(recordDelegate.getRecordKey(), 
recordDelegate)))
+        .flatMapToPair(Stream::iterator)
+        .reduceByKey((recordDelegate1, recordDelegate2) -> {

Review Comment:
   Yeah, wondering whether we have better algorithm to tackle the deduplication 
~



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