hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r1555059 - /hama/trunk/graph/src/main/java/org/apache/hama/graph/ListVerticesInfo.java
Date Fri, 03 Jan 2014 11:55:55 GMT
Author: edwardyoon
Date: Fri Jan  3 11:55:54 2014
New Revision: 1555059

URL: http://svn.apache.org/r1555059
Log:
HAMA-783: Improvement of ListVerticesInfo

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

Modified: hama/trunk/graph/src/main/java/org/apache/hama/graph/ListVerticesInfo.java
URL: http://svn.apache.org/viewvc/hama/trunk/graph/src/main/java/org/apache/hama/graph/ListVerticesInfo.java?rev=1555059&r1=1555058&r2=1555059&view=diff
==============================================================================
--- hama/trunk/graph/src/main/java/org/apache/hama/graph/ListVerticesInfo.java (original)
+++ hama/trunk/graph/src/main/java/org/apache/hama/graph/ListVerticesInfo.java Fri Jan  3
11:55:54 2014
@@ -96,13 +96,13 @@ public final class ListVerticesInfo<V ex
           throws IOException {
 
         if (it.hasNext()) {
-          V vertexKey = it.next();
-          v = deserialize(verticesMap.get(vertexKey));
+          V vertexID = it.next();
+          v = deserialize(vertexID, verticesMap.get(vertexID));
 
           while (!strat.accept(v, msgId)) {
             if (it.hasNext()) {
-              vertexKey = it.next();
-              v = deserialize(verticesMap.get(vertexKey));
+              vertexID = it.next();
+              v = deserialize(vertexID, verticesMap.get(vertexID));
             } else {
               return false;
             }
@@ -131,19 +131,26 @@ public final class ListVerticesInfo<V ex
   }
 
   public byte[] serialize(Vertex<V, E, M> vertex) throws IOException {
+    v = GraphJobRunner.<V, E, M> newVertexInstance(GraphJobRunner.VERTEX_CLASS);
+    v.setEdges(vertex.getEdges());
+    v.setValue(vertex.getValue());
+    if(vertex.isHalted()) {
+      v.voteToHalt();
+    }
     bos = new ByteArrayOutputStream();
     dos = new DataOutputStream(bos);
-    vertex.write(dos);
+    v.write(dos);
     return bos.toByteArray();
   }
 
-  public Vertex<V, E, M> deserialize(byte[] serialized) throws IOException {
+  public Vertex<V, E, M> deserialize(V vertexID, byte[] serialized) throws IOException
{
     bis = new ByteArrayInputStream(serialized);
     dis = new DataInputStream(bis);
     v = GraphJobRunner.<V, E, M> newVertexInstance(GraphJobRunner.VERTEX_CLASS);
 
     v.readFields(dis);
     v.setRunner(runner);
+    v.setVertexID(vertexID);
     return v;
   }
 



Mime
View raw message