You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nemo.apache.org by wo...@apache.org on 2019/11/04 06:45:44 UTC
[incubator-nemo] branch master updated: Fix SonarCloud bugs related
to Optional (#247)
This is an automated email from the ASF dual-hosted git repository.
wonook pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nemo.git
The following commit(s) were added to refs/heads/master by this push:
new 1eefd9d Fix SonarCloud bugs related to Optional (#247)
1eefd9d is described below
commit 1eefd9d1060996530ef8e3117be2e2eb69907abf
Author: Sanha Lee <sa...@gmail.com>
AuthorDate: Mon Nov 4 15:45:38 2019 +0900
Fix SonarCloud bugs related to Optional (#247)
JIRA: [NEMO-422: SonarCloud issues](https://issues.apache.org/jira/projects/NEMO/issues/NEMO-422)
**Major changes:**
- Fix some SonarCloud bugs related to `Optional`
**Minor changes to note:**
- None
**Tests for the changes:**
- None
**Other comments:**
- None
Closes #247
---
common/src/main/java/org/apache/nemo/common/ir/IRDAG.java | 15 +++++++++------
.../compiletime/annotating/DefaultParallelismPass.java | 3 ++-
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/common/src/main/java/org/apache/nemo/common/ir/IRDAG.java b/common/src/main/java/org/apache/nemo/common/ir/IRDAG.java
index 0334375..3e15fbd 100644
--- a/common/src/main/java/org/apache/nemo/common/ir/IRDAG.java
+++ b/common/src/main/java/org/apache/nemo/common/ir/IRDAG.java
@@ -216,13 +216,16 @@ public final class IRDAG implements DAGInterface<IRVertex, IREdge> {
modifiedDAG = builder.buildWithoutSourceSinkCheck();
} else if (vertexToDelete instanceof MessageAggregatorVertex || vertexToDelete instanceof TriggerVertex) {
modifiedDAG = rebuildExcluding(modifiedDAG, vertexGroupToDelete).buildWithoutSourceSinkCheck();
- final int deletedMessageId = vertexGroupToDelete.stream()
+ final Optional<Integer> deletedMessageIdOptional = vertexGroupToDelete.stream()
.filter(vtd -> vtd instanceof MessageAggregatorVertex)
- .map(vtd -> ((MessageAggregatorVertex) vtd).getPropertyValue(MessageIdVertexProperty.class).get())
- .findAny().get();
- modifiedDAG.getEdges().stream()
- .filter(e -> e.getPropertyValue(MessageIdEdgeProperty.class).isPresent())
- .forEach(e -> e.getPropertyValue(MessageIdEdgeProperty.class).get().remove(deletedMessageId));
+ .map(vtd -> vtd.getPropertyValue(MessageIdVertexProperty.class).orElseThrow(
+ () -> new IllegalArgumentException(
+ "MessageAggregatorVertex " + vtd.getId() + " does not have MessageIdVertexProperty.")))
+ .findAny();
+ deletedMessageIdOptional.ifPresent(deletedMessageId ->
+ modifiedDAG.getEdges().forEach(e ->
+ e.getPropertyValue(MessageIdEdgeProperty.class).ifPresent(
+ hashSet -> hashSet.remove(deletedMessageId))));
} else if (vertexToDelete instanceof SamplingVertex) {
modifiedDAG = rebuildExcluding(modifiedDAG, vertexGroupToDelete).buildWithoutSourceSinkCheck();
} else {
diff --git a/compiler/optimizer/src/main/java/org/apache/nemo/compiler/optimizer/pass/compiletime/annotating/DefaultParallelismPass.java b/compiler/optimizer/src/main/java/org/apache/nemo/compiler/optimizer/pass/compiletime/annotating/DefaultParallelismPass.java
index c2615f4..48b9d33 100644
--- a/compiler/optimizer/src/main/java/org/apache/nemo/compiler/optimizer/pass/compiletime/annotating/DefaultParallelismPass.java
+++ b/compiler/optimizer/src/main/java/org/apache/nemo/compiler/optimizer/pass/compiletime/annotating/DefaultParallelismPass.java
@@ -124,7 +124,8 @@ public final class DefaultParallelismPass extends AnnotatingPass {
.mapToInt(inVertex -> recursivelySynchronizeO2OParallelism(dag, inVertex, parallelism))
.max().orElse(1);
final Integer maxParallelism = ancestorParallelism > parallelism ? ancestorParallelism : parallelism;
- final Integer myParallelism = vertex.getPropertyValue(ParallelismProperty.class).get();
+ final Integer myParallelism = vertex.getPropertyValue(ParallelismProperty.class)
+ .orElseThrow(() -> new IllegalArgumentException("No ParallelismProperty for the vertex " + vertex.getId()));
// update the vertex with the max value.
if (maxParallelism > myParallelism) {