1
0

[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
This commit is contained in:
baobaoyeye
2020-04-18 12:51:37 +08:00
committed by GitHub
parent acb1ada2f7
commit 75523657a4
3 changed files with 9 additions and 21 deletions

View File

@@ -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();
}
}
}

View File

@@ -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);
}