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/04/29 01:46:51 UTC
svn commit: r1676649 - in
/hama/trunk/graph/src/main/java/org/apache/hama/graph: MapVerticesInfo.java
Vertex.java
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 {