[NEMO-429] SWPP TEAM12 Code Smell Fix (#274)
JIRA: [NEMO-429: TEAM12](https://issues.apache.org/jira/projects/NEMO/issues/NEMO-429)
Major changes:
- Fixed code smells (SWPP Code Smell session)
diff --git a/common/src/main/java/org/apache/nemo/common/ir/vertex/LoopVertex.java b/common/src/main/java/org/apache/nemo/common/ir/vertex/LoopVertex.java
index 00280ed..e0dd0e3 100644
--- a/common/src/main/java/org/apache/nemo/common/ir/vertex/LoopVertex.java
+++ b/common/src/main/java/org/apache/nemo/common/ir/vertex/LoopVertex.java
@@ -56,7 +56,7 @@
private final Map<IREdge, IREdge> edgeWithLoopToEdgeWithInternalVertex = new HashMap<>();
private final Map<IREdge, IREdge> edgeWithInternalVertexToEdgeWithLoop = new HashMap<>();
private Integer maxNumberOfIterations;
- private IntPredicate terminationCondition;
+ private transient IntPredicate terminationCondition;
/**
* The LoopVertex constructor.
diff --git a/compiler/frontend/spark/src/main/java/org/apache/nemo/compiler/frontend/spark/transform/HDFSTextFileTransform.java b/compiler/frontend/spark/src/main/java/org/apache/nemo/compiler/frontend/spark/transform/HDFSTextFileTransform.java
index 849860d..fef13d6 100644
--- a/compiler/frontend/spark/src/main/java/org/apache/nemo/compiler/frontend/spark/transform/HDFSTextFileTransform.java
+++ b/compiler/frontend/spark/src/main/java/org/apache/nemo/compiler/frontend/spark/transform/HDFSTextFileTransform.java
@@ -38,8 +38,8 @@
*/
public final class HDFSTextFileTransform<I> extends NoWatermarkEmitTransform<I, String> {
private final String path;
- private Path fileName;
- private List<I> elements;
+ private transient Path fileName;
+ private transient List<I> elements;
/**
* Constructor.
diff --git a/compiler/optimizer/src/main/java/org/apache/nemo/compiler/optimizer/pass/compiletime/reshaping/SkewReshapingPass.java b/compiler/optimizer/src/main/java/org/apache/nemo/compiler/optimizer/pass/compiletime/reshaping/SkewReshapingPass.java
index 08a61f5..eb0ec39 100644
--- a/compiler/optimizer/src/main/java/org/apache/nemo/compiler/optimizer/pass/compiletime/reshaping/SkewReshapingPass.java
+++ b/compiler/optimizer/src/main/java/org/apache/nemo/compiler/optimizer/pass/compiletime/reshaping/SkewReshapingPass.java
@@ -58,9 +58,8 @@
// TODO #210: Data-aware dynamic optimization at run-time
dag.topologicalDo(v -> {
// Incoming shuffle edges grouped by the AdditionalOutputTagProperty.
- final Function<IREdge, String> groupingFunction = irEdge -> {
- return irEdge.getPropertyValue(AdditionalOutputTagProperty.class).orElse(MAIN_OUTPUT_TAG);
- };
+ final Function<IREdge, String> groupingFunction = irEdge ->
+ irEdge.getPropertyValue(AdditionalOutputTagProperty.class).orElse(MAIN_OUTPUT_TAG);
final Map<String, Set<IREdge>> shuffleEdgesGroupedByTag = dag.getIncomingEdgesOf(v).stream()
.filter(e -> CommunicationPatternProperty.Value.SHUFFLE
.equals(e.getPropertyValue(CommunicationPatternProperty.class).get()))
@@ -76,7 +75,7 @@
// Insert the vertices
final TriggerVertex trigger = new TriggerVertex<>(SkewHandlingUtil.getMessageGenerator(keyExtractor));
final MessageAggregatorVertex mav =
- new MessageAggregatorVertex(() -> new HashMap(), SkewHandlingUtil.getMessageAggregator());
+ new MessageAggregatorVertex(HashMap::new, SkewHandlingUtil.getMessageAggregator());
dag.insert(trigger, mav, SkewHandlingUtil.getEncoder(representativeEdge),
SkewHandlingUtil.getDecoder(representativeEdge), shuffleEdgeGroup, shuffleEdgeGroup);
}
diff --git a/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/data/stores/LocalFileStore.java b/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/data/stores/LocalFileStore.java
index efbad9b..e530a02 100644
--- a/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/data/stores/LocalFileStore.java
+++ b/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/data/stores/LocalFileStore.java
@@ -76,7 +76,7 @@
* @throws BlockWriteException if fail to write.
*/
@Override
- public void writeBlock(final Block block) throws BlockWriteException {
+ public void writeBlock(final Block block) {
if (!(block instanceof FileBlock)) {
throw new BlockWriteException(new Throwable(
this.toString() + "only accept " + FileBlock.class.getName()));
@@ -94,7 +94,7 @@
* @return whether the block exists or not.
*/
@Override
- public boolean deleteBlock(final String blockId) throws BlockFetchException {
+ public boolean deleteBlock(final String blockId) {
final FileBlock fileBlock = (FileBlock) getBlockMap().remove(blockId);
if (fileBlock == null) {
return false;
diff --git a/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/task/SourceVertexDataFetcher.java b/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/task/SourceVertexDataFetcher.java
index 9ec850a..791f761 100644
--- a/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/task/SourceVertexDataFetcher.java
+++ b/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/task/SourceVertexDataFetcher.java
@@ -55,9 +55,9 @@
if (!bounded) {
this.watermarkTriggerService = Executors.newScheduledThreadPool(1);
- this.watermarkTriggerService.scheduleAtFixedRate(() -> {
- watermarkTriggered = true;
- }, WATERMARK_PERIOD, WATERMARK_PERIOD, TimeUnit.MILLISECONDS);
+ this.watermarkTriggerService.scheduleAtFixedRate(() ->
+ watermarkTriggered = true,
+ WATERMARK_PERIOD, WATERMARK_PERIOD, TimeUnit.MILLISECONDS);
} else {
this.watermarkTriggerService = null;
}