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 2020/01/07 08:16:01 UTC

[incubator-nemo] branch master updated: [NEMO-429] SWPP TEAM11 Code Smell Fix (#276)

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 57e4d59  [NEMO-429] SWPP TEAM11 Code Smell Fix (#276)
57e4d59 is described below

commit 57e4d591fc0d856afb1333f2feff1ff806a3376d
Author: Donghyun Kim <kd...@snu.ac.kr>
AuthorDate: Tue Jan 7 17:15:54 2020 +0900

    [NEMO-429] SWPP TEAM11 Code Smell Fix (#276)
    
    JIRA: [NEMO-429: TEAM11](https://issues.apache.org/jira/projects/NEMO/issues/NEMO-429)
    
    **Major changes:**
    - Fixed code smells (SWPP Code Smell session)
    
    Co-authored-by: wonook <wo...@apache.org>
---
 common/src/main/java/org/apache/nemo/common/dag/DAG.java            | 2 +-
 common/src/main/java/org/apache/nemo/common/dag/DAGInterface.java   | 4 +---
 common/src/main/java/org/apache/nemo/common/ir/IRDAG.java           | 3 +--
 common/src/main/java/org/apache/nemo/common/pass/Pass.java          | 3 +--
 .../pass/compiletime/reshaping/SamplingSkewReshapingPass.java       | 4 ++--
 .../java/org/apache/nemo/examples/beam/AlternatingLeastSquare.java  | 4 ++--
 .../runtime/executor/task/MultiThreadParentTaskDataFetcher.java     | 6 ++----
 7 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/common/src/main/java/org/apache/nemo/common/dag/DAG.java b/common/src/main/java/org/apache/nemo/common/dag/DAG.java
index 004e2ad..a1e3962 100644
--- a/common/src/main/java/org/apache/nemo/common/dag/DAG.java
+++ b/common/src/main/java/org/apache/nemo/common/dag/DAG.java
@@ -153,7 +153,7 @@ public final class DAG<V extends Vertex, E extends Edge<V>> implements DAGInterf
   }
 
   @Override
-  public E getEdgeBetween(final String srcVertexId, final String dstVertexId) throws IllegalEdgeOperationException {
+  public E getEdgeBetween(final String srcVertexId, final String dstVertexId) {
     for (E e : incomingEdges.get(dstVertexId)) {
       if (e.getSrc().getId().equals(srcVertexId)) {
         return e;
diff --git a/common/src/main/java/org/apache/nemo/common/dag/DAGInterface.java b/common/src/main/java/org/apache/nemo/common/dag/DAGInterface.java
index c85300f..b115cfe 100644
--- a/common/src/main/java/org/apache/nemo/common/dag/DAGInterface.java
+++ b/common/src/main/java/org/apache/nemo/common/dag/DAGInterface.java
@@ -19,7 +19,6 @@
 package org.apache.nemo.common.dag;
 
 import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.apache.nemo.common.exception.IllegalEdgeOperationException;
 import org.apache.nemo.common.ir.vertex.LoopVertex;
 
 import java.io.Serializable;
@@ -132,9 +131,8 @@ public interface DAGInterface<V extends Vertex, E extends Edge<V>> extends Seria
    * @param srcVertexId the ID of the source vertex.
    * @param dstVertexId the ID of the destination vertex.
    * @return the edge if exists.
-   * @throws IllegalEdgeOperationException otherwise.
    */
-  E getEdgeBetween(String srcVertexId, String dstVertexId) throws IllegalEdgeOperationException;
+  E getEdgeBetween(String srcVertexId, String dstVertexId);
 
   /**
    * Gets the DAG's vertices in topologically sorted order.
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 3e15fbd..36ef6d0 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
@@ -28,7 +28,6 @@ import org.apache.nemo.common.dag.DAG;
 import org.apache.nemo.common.dag.DAGBuilder;
 import org.apache.nemo.common.dag.DAGInterface;
 import org.apache.nemo.common.exception.CompileTimeOptimizationException;
-import org.apache.nemo.common.exception.IllegalEdgeOperationException;
 import org.apache.nemo.common.ir.edge.IREdge;
 import org.apache.nemo.common.ir.edge.executionproperty.*;
 import org.apache.nemo.common.ir.vertex.IRVertex;
@@ -710,7 +709,7 @@ public final class IRDAG implements DAGInterface<IRVertex, IREdge> {
 
   @Override
   public IREdge getEdgeBetween(final String srcVertexId,
-                               final String dstVertexId) throws IllegalEdgeOperationException {
+                               final String dstVertexId) {
     return modifiedDAG.getEdgeBetween(srcVertexId, dstVertexId);
   }
 
diff --git a/common/src/main/java/org/apache/nemo/common/pass/Pass.java b/common/src/main/java/org/apache/nemo/common/pass/Pass.java
index 3cdbd8f..4c78654 100644
--- a/common/src/main/java/org/apache/nemo/common/pass/Pass.java
+++ b/common/src/main/java/org/apache/nemo/common/pass/Pass.java
@@ -20,13 +20,12 @@ package org.apache.nemo.common.pass;
 
 import org.apache.nemo.common.ir.IRDAG;
 
-import java.io.Serializable;
 import java.util.function.Predicate;
 
 /**
  * Abstract class for optimization passes. All passes basically extends this class.
  */
-public abstract class Pass implements Serializable {
+public abstract class Pass {
   private Predicate<IRDAG> condition;
 
   /**
diff --git a/compiler/optimizer/src/main/java/org/apache/nemo/compiler/optimizer/pass/compiletime/reshaping/SamplingSkewReshapingPass.java b/compiler/optimizer/src/main/java/org/apache/nemo/compiler/optimizer/pass/compiletime/reshaping/SamplingSkewReshapingPass.java
index a90c1f8..4c0cf29 100644
--- a/compiler/optimizer/src/main/java/org/apache/nemo/compiler/optimizer/pass/compiletime/reshaping/SamplingSkewReshapingPass.java
+++ b/compiler/optimizer/src/main/java/org/apache/nemo/compiler/optimizer/pass/compiletime/reshaping/SamplingSkewReshapingPass.java
@@ -107,13 +107,13 @@ public final class SamplingSkewReshapingPass extends ReshapingPass {
           final SamplingVertex rightBeforeShuffle = samplingVertices.stream()
             .filter(sv -> sv.getOriginalVertexId().equals(e.getSrc().getId()))
             .findFirst()
-            .orElseThrow(() -> new IllegalStateException());
+            .orElseThrow(IllegalStateException::new);
           final IREdge clonedShuffleEdge = rightBeforeShuffle.getCloneOfOriginalEdge(e);
 
           final KeyExtractor keyExtractor = e.getPropertyValue(KeyExtractorProperty.class).get();
           dag.insert(
             new TriggerVertex<>(SkewHandlingUtil.getMessageGenerator(keyExtractor)),
-            new MessageAggregatorVertex(() -> new HashMap<>(), SkewHandlingUtil.getMessageAggregator()),
+            new MessageAggregatorVertex(HashMap::new, SkewHandlingUtil.getMessageAggregator()),
             SkewHandlingUtil.getEncoder(e),
             SkewHandlingUtil.getDecoder(e),
             new HashSet<>(Arrays.asList(clonedShuffleEdge)), // this works although the clone is not in the dag
diff --git a/examples/beam/src/main/java/org/apache/nemo/examples/beam/AlternatingLeastSquare.java b/examples/beam/src/main/java/org/apache/nemo/examples/beam/AlternatingLeastSquare.java
index e990f16..d917310 100644
--- a/examples/beam/src/main/java/org/apache/nemo/examples/beam/AlternatingLeastSquare.java
+++ b/examples/beam/src/main/java/org/apache/nemo/examples/beam/AlternatingLeastSquare.java
@@ -268,8 +268,8 @@ public final class AlternatingLeastSquare {
     extends LoopCompositeTransform<PCollection<KV<Integer, float[]>>, PCollection<KV<Integer, float[]>>> {
     private final Integer numFeatures;
     private final double lambda;
-    private final PCollection<KV<Integer, KV<int[], float[]>>> parsedUserData;
-    private final PCollection<KV<Integer, KV<int[], float[]>>> parsedItemData;
+    private final transient PCollection<KV<Integer, KV<int[], float[]>>> parsedUserData;
+    private final transient PCollection<KV<Integer, KV<int[], float[]>>> parsedItemData;
 
     /**
      * Constructor of UpdateUserAndItemMatrix CompositeTransform.
diff --git a/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/task/MultiThreadParentTaskDataFetcher.java b/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/task/MultiThreadParentTaskDataFetcher.java
index 4cdea10..4e460f9 100644
--- a/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/task/MultiThreadParentTaskDataFetcher.java
+++ b/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/task/MultiThreadParentTaskDataFetcher.java
@@ -110,7 +110,7 @@ class MultiThreadParentTaskDataFetcher extends DataFetcher {
       inputWatermarkManager = new SingleInputWatermarkManager(new WatermarkCollector());
     }
 
-    futures.forEach(compFuture -> compFuture.whenComplete((iterator, exception) -> {
+    futures.forEach(compFuture -> compFuture.whenComplete((iterator, exception) ->
       // A thread for each iterator
       queueInsertionThreads.submit(() -> {
         if (exception == null) {
@@ -139,9 +139,7 @@ class MultiThreadParentTaskDataFetcher extends DataFetcher {
           LOG.error(exception.getMessage());
           throw new RuntimeException(exception);
         }
-      });
-
-    }));
+      })));
   }
 
   final long getSerializedBytes() {