You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hama.apache.org by ed...@apache.org on 2015/02/05 06:38:58 UTC

svn commit: r1657478 - in /hama/trunk/graph/src/main/java/org/apache/hama/graph: GraphJobMessage.java GraphJobRunner.java

Author: edwardyoon
Date: Thu Feb  5 05:38:58 2015
New Revision: 1657478

URL: http://svn.apache.org/r1657478
Log:
Remove duplicate codes

Modified:
    hama/trunk/graph/src/main/java/org/apache/hama/graph/GraphJobMessage.java
    hama/trunk/graph/src/main/java/org/apache/hama/graph/GraphJobRunner.java

Modified: hama/trunk/graph/src/main/java/org/apache/hama/graph/GraphJobMessage.java
URL: http://svn.apache.org/viewvc/hama/trunk/graph/src/main/java/org/apache/hama/graph/GraphJobMessage.java?rev=1657478&r1=1657477&r2=1657478&view=diff
==============================================================================
--- hama/trunk/graph/src/main/java/org/apache/hama/graph/GraphJobMessage.java (original)
+++ hama/trunk/graph/src/main/java/org/apache/hama/graph/GraphJobMessage.java Thu Feb  5 05:38:58 2015
@@ -113,14 +113,12 @@ public final class GraphJobMessage imple
 
   private ByteArrayInputStream bis = null;
   private DataInputStream dis = null;
-  List<Writable> valuesCache;
+  List<Writable> valuesCache = new ArrayList<Writable>();
 
   public List<Writable> getValues() {
     bis = new ByteArrayInputStream(byteBuffer.toByteArray());
     dis = new DataInputStream(bis);
 
-    valuesCache = new ArrayList<Writable>();
-
     if (valuesCache.isEmpty()) {
       for (int i = 0; i < numOfValues; i++) {
         try {

Modified: hama/trunk/graph/src/main/java/org/apache/hama/graph/GraphJobRunner.java
URL: http://svn.apache.org/viewvc/hama/trunk/graph/src/main/java/org/apache/hama/graph/GraphJobRunner.java?rev=1657478&r1=1657477&r2=1657478&view=diff
==============================================================================
--- hama/trunk/graph/src/main/java/org/apache/hama/graph/GraphJobRunner.java (original)
+++ hama/trunk/graph/src/main/java/org/apache/hama/graph/GraphJobRunner.java Thu Feb  5 05:38:58 2015
@@ -226,7 +226,7 @@ public final class GraphJobRunner<V exte
     int activeVertices = 0;
     this.changedVertexCnt = 0;
     vertices.startSuperstep();
-    
+
     notComputedVertices = new HashSet();
     notComputedVertices.addAll(vertices.keySet());
 
@@ -235,7 +235,7 @@ public final class GraphJobRunner<V exte
 
     while (currentMessage != null) {
       vertex = vertices.get((V) currentMessage.getVertexId());
-      
+
       msgs = (List<M>) currentMessage.getValues();
       if (vertex.isHalted()) {
         vertex.setActive();
@@ -275,7 +275,7 @@ public final class GraphJobRunner<V exte
       throws IOException {
     this.changedVertexCnt = 0;
     vertices.startSuperstep();
-    
+
     Iterator<Vertex<V, E, M>> iterator = vertices.iterator();
 
     while (iterator.hasNext()) {
@@ -283,11 +283,11 @@ public final class GraphJobRunner<V exte
 
       // Calls setup method.
       vertex.setup(conf);
-      
+
       vertex.compute(Collections.singleton(vertex.getValue()));
       vertices.finishVertexComputation(vertex);
     }
-    
+
     vertices.finishSuperstep();
     getAggregationRunner().sendAggregatorValues(peer, 1, this.changedVertexCnt);
     iteration++;
@@ -351,8 +351,6 @@ public final class GraphJobRunner<V exte
   private void loadVertices(
       BSPPeer<Writable, Writable, Writable, Writable, GraphJobMessage> peer)
       throws IOException, SyncException, InterruptedException {
-    final boolean selfReference = conf.getBoolean("hama.graph.self.ref", false);
-
     RecordConverter converter = org.apache.hadoop.util.ReflectionUtils
         .newInstance(conf.getClass(Constants.RUNTIME_PARTITION_RECORDCONVERTER,
             DefaultRecordConverter.class, RecordConverter.class), conf);
@@ -383,19 +381,12 @@ public final class GraphJobRunner<V exte
                 "The records of split aren't in order by vertex ID.");
           }
 
-          if (selfReference) {
-            vertex.addEdge(new Edge<V, E>(vertex.getVertexID(), null));
-          }
-
           addVertex(vertex);
           vertex = currentVertex;
         }
       }
     }
     // add last vertex.
-    if (selfReference) {
-      vertex.addEdge(new Edge<V, E>(vertex.getVertexID(), null));
-    }
     addVertex(vertex);
 
     LOG.info(vertices.size() + " vertices are loaded into "
@@ -412,8 +403,9 @@ public final class GraphJobRunner<V exte
     if (conf.getBoolean("hama.graph.self.ref", false)) {
       vertex.addEdge(new Edge<V, E>(vertex.getVertexID(), null));
     }
+
     vertices.put(vertex);
-    
+
     LOG.debug("Added VertexID: " + vertex.getVertexID() + " in peer "
         + peer.getPeerName());
   }
@@ -468,7 +460,7 @@ public final class GraphJobRunner<V exte
     GraphJobMessage msg = null;
     boolean dynamicAdditions = false;
     boolean dynamicRemovals = false;
-    
+
     while ((msg = peer.getCurrentMessage()) != null) {
       // either this is a vertex message or a directive that must be read
       // as map
@@ -519,7 +511,7 @@ public final class GraphJobRunner<V exte
       }
 
     }
-    
+
     // If we applied any changes to vertices, we need to call finishAdditions
     // and finishRemovals in the end.
     if (dynamicAdditions) {