This is an automated email from the ASF dual-hosted git repository.

danny0405 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git


The following commit(s) were added to refs/heads/master by this push:
     new bab75b6c60c [HUDI-4911] Following the first patch, fix the inefficient 
code (#8127)
bab75b6c60c is described below

commit bab75b6c60cad862d4c5ca628856ab486cdae450
Author: Danny Chan <[email protected]>
AuthorDate: Thu Mar 9 13:40:36 2023 +0800

    [HUDI-4911] Following the first patch, fix the inefficient code (#8127)
---
 .../src/main/java/org/apache/hudi/BaseHoodieTableFileIndex.java   | 3 +--
 .../main/java/org/apache/hudi/common/util/CollectionUtils.java    | 5 +++--
 .../java/org/apache/hudi/metadata/HoodieBackedTableMetadata.java  | 8 --------
 3 files changed, 4 insertions(+), 12 deletions(-)

diff --git 
a/hudi-common/src/main/java/org/apache/hudi/BaseHoodieTableFileIndex.java 
b/hudi-common/src/main/java/org/apache/hudi/BaseHoodieTableFileIndex.java
index 3769f23a4b1..91c5e001660 100644
--- a/hudi-common/src/main/java/org/apache/hudi/BaseHoodieTableFileIndex.java
+++ b/hudi-common/src/main/java/org/apache/hudi/BaseHoodieTableFileIndex.java
@@ -51,7 +51,6 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
@@ -343,7 +342,7 @@ public abstract class BaseHoodieTableFileIndex implements 
AutoCloseable {
             .collect(Collectors.toMap(Pair::getKey, p -> p.getRight().get()));
 
     Set<Path> missingPartitionPaths =
-        CollectionUtils.diffSet(new HashSet<>(partitionPaths), 
cachedPartitionPaths.keySet());
+        CollectionUtils.diffSet(partitionPaths, cachedPartitionPaths.keySet());
 
     // NOTE: We're constructing a mapping of absolute form of the 
partition-path into
     //       its relative one, such that we don't need to reconstruct these 
again later on
diff --git 
a/hudi-common/src/main/java/org/apache/hudi/common/util/CollectionUtils.java 
b/hudi-common/src/main/java/org/apache/hudi/common/util/CollectionUtils.java
index cbda19ffec7..59e25e8afbe 100644
--- a/hudi-common/src/main/java/org/apache/hudi/common/util/CollectionUtils.java
+++ b/hudi-common/src/main/java/org/apache/hudi/common/util/CollectionUtils.java
@@ -184,9 +184,10 @@ public class CollectionUtils {
   }
 
   /**
-   * Returns difference b/w {@code one} {@link Set} of elements and {@code 
another}
+   * Returns difference b/w {@code one} {@link Collection} of elements and 
{@code another}
+   * The elements in collection {@code one} are also duplicated and returned 
as a {@link Set}.
    */
-  public static <E> Set<E> diffSet(Set<E> one, Set<E> another) {
+  public static <E> Set<E> diffSet(Collection<E> one, Set<E> another) {
     Set<E> diff = new HashSet<>(one);
     diff.removeAll(another);
     return diff;
diff --git 
a/hudi-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadata.java
 
b/hudi-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadata.java
index 454fa900bec..fe4efacd0ca 100644
--- 
a/hudi-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadata.java
+++ 
b/hudi-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadata.java
@@ -43,7 +43,6 @@ import org.apache.hudi.common.table.timeline.HoodieTimeline;
 import org.apache.hudi.common.table.timeline.TimelineMetadataUtils;
 import org.apache.hudi.common.table.view.HoodieTableFileSystemView;
 import org.apache.hudi.common.util.collection.ClosableIterator;
-import org.apache.hudi.common.util.CollectionUtils;
 import org.apache.hudi.common.util.HoodieTimer;
 import org.apache.hudi.common.util.Option;
 import org.apache.hudi.common.util.SpillableMapUtils;
@@ -287,13 +286,6 @@ public class HoodieBackedTableMetadata extends 
BaseTableMetadata {
                 .map(record -> Pair.of(record.getRecordKey(), 
Option.of(record)))
                 .collect(Collectors.toList());
 
-    // Second, back-fill keys not present in the log-blocks (such that map 
holds
-    // a record for every key being looked up)
-    List<String> missingKeys = CollectionUtils.diff(keys, logRecords.keySet());
-    for (String key : missingKeys) {
-      logRecords.put(key, Option.empty());
-    }
-
     for (Pair<String, Option<HoodieRecord<HoodieMetadataPayload>>> entry : 
logRecordsList) {
       logRecords.put(entry.getKey(), entry.getValue());
     }

Reply via email to