giraph-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ach...@apache.org
Subject svn commit: r1359532 - in /giraph/trunk: ./ src/main/java/org/apache/giraph/graph/
Date Tue, 10 Jul 2012 09:12:16 GMT
Author: aching
Date: Tue Jul 10 09:12:15 2012
New Revision: 1359532

URL: http://svn.apache.org/viewvc?rev=1359532&view=rev
Log:
GIRAPH-238: BasicVertex should have default Writable implementation
(apresta via aching)


Modified:
    giraph/trunk/CHANGELOG
    giraph/trunk/src/main/java/org/apache/giraph/graph/BasicVertex.java
    giraph/trunk/src/main/java/org/apache/giraph/graph/EdgeListVertex.java
    giraph/trunk/src/main/java/org/apache/giraph/graph/HashMapVertex.java
    giraph/trunk/src/main/java/org/apache/giraph/graph/IntIntNullIntVertex.java
    giraph/trunk/src/main/java/org/apache/giraph/graph/LongDoubleFloatDoubleVertex.java

Modified: giraph/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/giraph/trunk/CHANGELOG?rev=1359532&r1=1359531&r2=1359532&view=diff
==============================================================================
--- giraph/trunk/CHANGELOG (original)
+++ giraph/trunk/CHANGELOG Tue Jul 10 09:12:15 2012
@@ -2,10 +2,13 @@ Giraph Change Log
 
 Release 0.2.0 - unreleased
 
+  GIRAPH-238: BasicVertex should have default Writable implementation
+  (apresta via aching)
+
   GIRAPH-233: Small errors found by FindBugs (Jan van der Lugt via hyunsik)
   
-  GIRAPH-216: NullWritable as VertexData, EdgeData or MessageData should be allowed.
-  (Jan van der Lugt via jghoman)
+  GIRAPH-216: NullWritable as VertexData, EdgeData or MessageData
+  should be allowed.  (Jan van der Lugt via jghoman)
 
   GIRAPH-221: Make iteration over edges more explicit (apresta via aching).
 
@@ -27,10 +30,11 @@ Release 0.2.0 - unreleased
   GIRAPH-217: Add SimpleTriangleClosingVertex to Giraph examples. 
   (Eli Reisman via jghoman)  
 
-  GIRAPH-219: pom in giraph-formats-contrib should have groupId 'org.apache.giraph'.
-  (Brian Femiano via jghoman)
+  GIRAPH-219: pom in giraph-formats-contrib should have groupId
+  'org.apache.giraph'.  (Brian Femiano via jghoman)
 
-  GIRAPH-215: Update site to use Giraph logo and remove 'incubator' text (ekoontz)
+  GIRAPH-215: Update site to use Giraph logo and remove 'incubator'
+  text (ekoontz)
 
   GIRAPH-205: Move Giraph jar to root level of tar.gz. 
   (Roman Shaposhnik via jghoman)

Modified: giraph/trunk/src/main/java/org/apache/giraph/graph/BasicVertex.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/main/java/org/apache/giraph/graph/BasicVertex.java?rev=1359532&r1=1359531&r2=1359532&view=diff
==============================================================================
--- giraph/trunk/src/main/java/org/apache/giraph/graph/BasicVertex.java (original)
+++ giraph/trunk/src/main/java/org/apache/giraph/graph/BasicVertex.java Tue Jul 10 09:12:15
2012
@@ -24,8 +24,13 @@ import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.io.WritableComparable;
 import org.apache.hadoop.mapreduce.Mapper;
 
+import java.io.DataInput;
+import java.io.DataOutput;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -214,6 +219,12 @@ public abstract class BasicVertex<I exte
   abstract void putMessages(Iterable<M> messages);
 
   /**
+   * Get the number of incoming messages.
+   * @return the number of messages.
+   */
+  abstract int getNumMessages();
+
+  /**
    * Release unnecessary resources (will be called after vertex returns from
    * {@link #compute()})
    */
@@ -284,4 +295,54 @@ public abstract class BasicVertex<I exte
   public void setConf(Configuration conf) {
     this.conf = conf;
   }
+
+  @Override
+  public void readFields(DataInput in) throws IOException {
+    I vertexId = BspUtils.<I>createVertexIndex(getConf());
+    vertexId.readFields(in);
+    V vertexValue = BspUtils.<V>createVertexValue(getConf());
+    vertexValue.readFields(in);
+
+    int numEdges = in.readInt();
+    Map<I, E> edges = new HashMap<I, E>(numEdges);
+    for (int i = 0; i < numEdges; ++i) {
+      I targetVertexId = BspUtils.<I>createVertexIndex(getConf());
+      targetVertexId.readFields(in);
+      E edgeValue = BspUtils.<E>createEdgeValue(getConf());
+      edgeValue.readFields(in);
+      edges.put(targetVertexId, edgeValue);
+    }
+
+    int numMessages = in.readInt();
+    List<M> messages = new ArrayList<M>(numMessages);
+    for (int i = 0; i < numMessages; ++i) {
+      M message = BspUtils.<M>createMessageValue(getConf());
+      message.readFields(in);
+      messages.add(message);
+    }
+
+    initialize(vertexId, vertexValue, edges, messages);
+
+    halt = in.readBoolean();
+  }
+
+  @Override
+  public void write(DataOutput out) throws IOException {
+    getVertexId().write(out);
+    getVertexValue().write(out);
+
+    out.writeInt(getNumOutEdges());
+    for (Iterator<I> edges = getOutEdgesIterator(); edges.hasNext();) {
+      I targetVertexId = edges.next();
+      targetVertexId.write(out);
+      getEdgeValue(targetVertexId).write(out);
+    }
+
+    out.writeInt(getNumMessages());
+    for (M message : getMessages()) {
+      message.write(out);
+    }
+
+    out.writeBoolean(halt);
+  }
 }

Modified: giraph/trunk/src/main/java/org/apache/giraph/graph/EdgeListVertex.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/main/java/org/apache/giraph/graph/EdgeListVertex.java?rev=1359532&r1=1359531&r2=1359532&view=diff
==============================================================================
--- giraph/trunk/src/main/java/org/apache/giraph/graph/EdgeListVertex.java (original)
+++ giraph/trunk/src/main/java/org/apache/giraph/graph/EdgeListVertex.java Tue Jul 10 09:12:15
2012
@@ -18,12 +18,12 @@
 
 package org.apache.giraph.graph;
 
-import com.google.common.collect.Iterables;
 import org.apache.giraph.utils.ComparisonUtils;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.io.WritableComparable;
 import org.apache.log4j.Logger;
 
+import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 
 import java.io.DataInput;
@@ -300,6 +300,11 @@ public abstract class EdgeListVertex<I e
   }
 
   @Override
+  public int getNumMessages() {
+    return msgList.size();
+  }
+
+  @Override
   void releaseResources() {
     // Hint to GC to free the messages
     msgList.clear();

Modified: giraph/trunk/src/main/java/org/apache/giraph/graph/HashMapVertex.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/main/java/org/apache/giraph/graph/HashMapVertex.java?rev=1359532&r1=1359531&r2=1359532&view=diff
==============================================================================
--- giraph/trunk/src/main/java/org/apache/giraph/graph/HashMapVertex.java (original)
+++ giraph/trunk/src/main/java/org/apache/giraph/graph/HashMapVertex.java Tue Jul 10 09:12:15
2012
@@ -18,12 +18,13 @@
 
 package org.apache.giraph.graph;
 
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.io.WritableComparable;
 import org.apache.log4j.Logger;
 
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
@@ -229,6 +230,11 @@ public abstract class HashMapVertex<I ex
   }
 
   @Override
+  public int getNumMessages() {
+    return msgList.size();
+  }
+
+  @Override
   void releaseResources() {
     // Hint to GC to free the messages
     msgList.clear();

Modified: giraph/trunk/src/main/java/org/apache/giraph/graph/IntIntNullIntVertex.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/main/java/org/apache/giraph/graph/IntIntNullIntVertex.java?rev=1359532&r1=1359531&r2=1359532&view=diff
==============================================================================
--- giraph/trunk/src/main/java/org/apache/giraph/graph/IntIntNullIntVertex.java (original)
+++ giraph/trunk/src/main/java/org/apache/giraph/graph/IntIntNullIntVertex.java Tue Jul 10
09:12:15 2012
@@ -18,11 +18,12 @@
 
 package org.apache.giraph.graph;
 
-import com.google.common.collect.Iterables;
 import org.apache.giraph.utils.UnmodifiableIntArrayIterator;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.NullWritable;
 
+import com.google.common.collect.Iterables;
+
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
@@ -134,6 +135,11 @@ public abstract class IntIntNullIntVerte
   }
 
   @Override
+  public int getNumMessages() {
+    return messages.length;
+  }
+
+  @Override
   void releaseResources() {
     messages = new int[0];
   }

Modified: giraph/trunk/src/main/java/org/apache/giraph/graph/LongDoubleFloatDoubleVertex.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/main/java/org/apache/giraph/graph/LongDoubleFloatDoubleVertex.java?rev=1359532&r1=1359531&r2=1359532&view=diff
==============================================================================
--- giraph/trunk/src/main/java/org/apache/giraph/graph/LongDoubleFloatDoubleVertex.java (original)
+++ giraph/trunk/src/main/java/org/apache/giraph/graph/LongDoubleFloatDoubleVertex.java Tue
Jul 10 09:12:15 2012
@@ -17,7 +17,6 @@
  */
 package org.apache.giraph.graph;
 
-import com.google.common.collect.UnmodifiableIterator;
 import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.FloatWritable;
 import org.apache.hadoop.io.LongWritable;
@@ -28,6 +27,8 @@ import org.apache.mahout.math.function.L
 import org.apache.mahout.math.list.DoubleArrayList;
 import org.apache.mahout.math.map.OpenLongFloatHashMap;
 
+import com.google.common.collect.UnmodifiableIterator;
+
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
@@ -275,6 +276,11 @@ public abstract class LongDoubleFloatDou
   }
 
   @Override
+  public int getNumMessages() {
+    return messageList.size();
+  }
+
+  @Override
   public String toString() {
     return "Vertex(id=" + getVertexId() + ",value=" + getVertexValue() +
         ",#edges=" + getNumOutEdges() + ")";



Mime
View raw message