You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by la...@apache.org on 2020/04/18 04:51:46 UTC

[incubator-hudi] branch master updated: [MINOR] use Option and fix description in toString method (#1527)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 7552365  [MINOR] use Option and fix description in toString method (#1527)
7552365 is described below

commit 75523657a4b5c67209e48c1c989a4dd017b4fdd1
Author: baobaoyeye <ba...@gmail.com>
AuthorDate: Sat Apr 18 12:51:37 2020 +0800

    [MINOR] use Option and fix description in toString method (#1527)
    
    * [MINOR] fix some places are not elegant, as a newcomer
    
    * [MINOR] fix some places are not elegant, as a newcomer
---
 .../hudi/table/action/commit/InsertBucket.java     |  4 ++--
 .../hudi/table/action/rollback/RollbackHelper.java | 26 ++++++----------------
 .../hudi/common/table/timeline/HoodieTimeline.java |  0
 3 files changed, 9 insertions(+), 21 deletions(-)

diff --git a/hudi-client/src/main/java/org/apache/hudi/table/action/commit/InsertBucket.java b/hudi-client/src/main/java/org/apache/hudi/table/action/commit/InsertBucket.java
index d5dcec8..2cedbe8 100644
--- a/hudi-client/src/main/java/org/apache/hudi/table/action/commit/InsertBucket.java
+++ b/hudi-client/src/main/java/org/apache/hudi/table/action/commit/InsertBucket.java
@@ -32,10 +32,10 @@ public class InsertBucket implements Serializable {
 
   @Override
   public String toString() {
-    final StringBuilder sb = new StringBuilder("WorkloadStat {");
+    final StringBuilder sb = new StringBuilder("InsertBucket {");
     sb.append("bucketNumber=").append(bucketNumber).append(", ");
     sb.append("weight=").append(weight);
     sb.append('}');
     return sb.toString();
   }
-}
\ No newline at end of file
+}
diff --git a/hudi-client/src/main/java/org/apache/hudi/table/action/rollback/RollbackHelper.java b/hudi-client/src/main/java/org/apache/hudi/table/action/rollback/RollbackHelper.java
index 7c42e67..f64483a 100644
--- a/hudi-client/src/main/java/org/apache/hudi/table/action/rollback/RollbackHelper.java
+++ b/hudi-client/src/main/java/org/apache/hudi/table/action/rollback/RollbackHelper.java
@@ -28,6 +28,7 @@ import org.apache.hudi.common.table.log.block.HoodieCommandBlock;
 import org.apache.hudi.common.table.log.block.HoodieCommandBlock.HoodieCommandBlockTypeEnum;
 import org.apache.hudi.common.table.log.block.HoodieLogBlock.HeaderMetadataType;
 import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.util.Option;
 import org.apache.hudi.common.util.ValidationUtils;
 import org.apache.hudi.config.HoodieWriteConfig;
 import org.apache.hudi.exception.HoodieRollbackException;
@@ -151,25 +152,12 @@ public class RollbackHelper implements Serializable {
     final List<String> successDeleteFiles = new ArrayList<>();
     final List<String> failedDeleteFiles = new ArrayList<>();
     final Map<FileStatus, Long> commandBlocksCount = new HashMap<>();
-
-    if (stat1.getSuccessDeleteFiles() != null) {
-      successDeleteFiles.addAll(stat1.getSuccessDeleteFiles());
-    }
-    if (stat2.getSuccessDeleteFiles() != null) {
-      successDeleteFiles.addAll(stat2.getSuccessDeleteFiles());
-    }
-    if (stat1.getFailedDeleteFiles() != null) {
-      failedDeleteFiles.addAll(stat1.getFailedDeleteFiles());
-    }
-    if (stat2.getFailedDeleteFiles() != null) {
-      failedDeleteFiles.addAll(stat2.getFailedDeleteFiles());
-    }
-    if (stat1.getCommandBlocksCount() != null) {
-      commandBlocksCount.putAll(stat1.getCommandBlocksCount());
-    }
-    if (stat2.getCommandBlocksCount() != null) {
-      commandBlocksCount.putAll(stat2.getCommandBlocksCount());
-    }
+    Option.ofNullable(stat1.getSuccessDeleteFiles()).ifPresent(successDeleteFiles::addAll);
+    Option.ofNullable(stat2.getSuccessDeleteFiles()).ifPresent(successDeleteFiles::addAll);
+    Option.ofNullable(stat1.getFailedDeleteFiles()).ifPresent(failedDeleteFiles::addAll);
+    Option.ofNullable(stat2.getFailedDeleteFiles()).ifPresent(failedDeleteFiles::addAll);
+    Option.ofNullable(stat1.getCommandBlocksCount()).ifPresent(commandBlocksCount::putAll);
+    Option.ofNullable(stat2.getCommandBlocksCount()).ifPresent(commandBlocksCount::putAll);
     return new HoodieRollbackStat(stat1.getPartitionPath(), successDeleteFiles, failedDeleteFiles, commandBlocksCount);
   }
 
diff --git a/hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieTimeline.java b/hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieTimeline.java
old mode 100755
new mode 100644