hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r1676649 - in /hama/trunk/graph/src/main/java/org/apache/hama/graph: MapVerticesInfo.java Vertex.java
Date Tue, 28 Apr 2015 23:46:51 GMT
Author: edwardyoon
Date: Tue Apr 28 23:46:51 2015
New Revision: 1676649

URL: http://svn.apache.org/r1676649
Log:
code optimization.

Modified:
    hama/trunk/graph/src/main/java/org/apache/hama/graph/MapVerticesInfo.java
    hama/trunk/graph/src/main/java/org/apache/hama/graph/Vertex.java

Modified: hama/trunk/graph/src/main/java/org/apache/hama/graph/MapVerticesInfo.java
URL: http://svn.apache.org/viewvc/hama/trunk/graph/src/main/java/org/apache/hama/graph/MapVerticesInfo.java?rev=1676649&r1=1676648&r2=1676649&view=diff
==============================================================================
--- hama/trunk/graph/src/main/java/org/apache/hama/graph/MapVerticesInfo.java (original)
+++ hama/trunk/graph/src/main/java/org/apache/hama/graph/MapVerticesInfo.java Tue Apr 28 23:46:51
2015
@@ -141,9 +141,6 @@ public final class MapVerticesInfo<V ext
   @Override
   public void finishSuperstep() throws IOException {
     activeVertices = 0;
-    for (Vertex<V, E, M> v : vertices.values()) {
-      v.resetComputedFlag();
-    }
   }
 
   public int getActiveVerticesNum() {

Modified: hama/trunk/graph/src/main/java/org/apache/hama/graph/Vertex.java
URL: http://svn.apache.org/viewvc/hama/trunk/graph/src/main/java/org/apache/hama/graph/Vertex.java?rev=1676649&r1=1676648&r2=1676649&view=diff
==============================================================================
--- hama/trunk/graph/src/main/java/org/apache/hama/graph/Vertex.java (original)
+++ hama/trunk/graph/src/main/java/org/apache/hama/graph/Vertex.java Tue Apr 28 23:46:51 2015
@@ -59,7 +59,7 @@ public abstract class Vertex<V extends W
   private List<Edge<V, E>> edges;
 
   private boolean votedToHalt = false;
-  private boolean computed = false;
+  private long lastComputedSuperstep = 0;
   
   public HamaConfiguration getConf() {
     return runner.getPeer().getConfiguration();
@@ -198,15 +198,11 @@ public abstract class Vertex<V extends W
   }
 
   void setComputed() {
-    this.computed = true;
-  }
-  
-  void resetComputedFlag() {
-    this.computed = false;
+    this.lastComputedSuperstep = this.getSuperstepCount();
   }
   
   public boolean isComputed() {
-    return computed;
+    return (lastComputedSuperstep == this.getSuperstepCount()) ? true : false;
   }
   
   void setVotedToHalt(boolean votedToHalt) {
@@ -256,6 +252,8 @@ public abstract class Vertex<V extends W
       this.value.readFields(in);
     }
 
+    this.lastComputedSuperstep = in.readLong();
+    
     this.edges = new ArrayList<Edge<V, E>>();
     if (in.readBoolean()) {
       int num = in.readInt();
@@ -286,13 +284,16 @@ public abstract class Vertex<V extends W
       out.writeBoolean(true);
       vertexID.write(out);
     }
-
+    
     if (value == null) {
       out.writeBoolean(false);
     } else {
       out.writeBoolean(true);
       value.write(out);
     }
+    
+    out.writeLong(lastComputedSuperstep);
+    
     if (this.edges == null) {
       out.writeBoolean(false);
     } else {



Mime
View raw message