hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r1620830 - /hama/trunk/graph/src/main/java/org/apache/hama/graph/MapVerticesInfo.java
Date Wed, 27 Aug 2014 09:20:35 GMT
Author: edwardyoon
Date: Wed Aug 27 09:20:35 2014
New Revision: 1620830

URL: http://svn.apache.org/r1620830
Log: (empty)

Modified:
    hama/trunk/graph/src/main/java/org/apache/hama/graph/MapVerticesInfo.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=1620830&r1=1620829&r2=1620830&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 Wed Aug 27 09:20:35
2014
@@ -17,10 +17,6 @@
  */
 package org.apache.hama.graph;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.Iterator;
 import java.util.SortedMap;
@@ -30,6 +26,7 @@ import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.io.WritableComparable;
 import org.apache.hama.HamaConfiguration;
 import org.apache.hama.bsp.TaskAttemptID;
+import org.apache.hama.util.KryoSerializer;
 
 /**
  * Stores the vertices into a memory-based tree map. This implementation allows
@@ -48,11 +45,6 @@ public final class MapVerticesInfo<V ext
 
   private final SortedMap<V, byte[]> verticesMap = new TreeMap<V, byte[]>();
 
-  private ByteArrayOutputStream bos = null;
-  private DataOutputStream dos = null;
-  private ByteArrayInputStream bis = null;
-  private DataInputStream dis = null;
-
   @Override
   public void init(GraphJobRunner<V, E, M> runner, HamaConfiguration conf,
       TaskAttemptID attempt) throws IOException {
@@ -133,20 +125,16 @@ public final class MapVerticesInfo<V ext
     };
   }
 
+  private final KryoSerializer kryo = new KryoSerializer(GraphJobRunner.VERTEX_CLASS);
+  
   public byte[] serialize(Vertex<V, E, M> vertex) throws IOException {
-    bos = new ByteArrayOutputStream();
-    dos = new DataOutputStream(bos);
-    vertex.write(dos);
-    return bos.toByteArray();
+    return kryo.serialize(vertex);
   }
 
+  @SuppressWarnings("unchecked")
   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 = (Vertex<V, E, M>) kryo.deserialize(serialized);
     v.setRunner(runner);
     v.setVertexID(vertexID);
     return v;



Mime
View raw message