incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tjungb...@apache.org
Subject svn commit: r1292317 - in /incubator/hama/trunk: ./ examples/src/main/java/org/apache/hama/examples/ graph/src/main/java/org/apache/hama/graph/
Date Wed, 22 Feb 2012 14:35:22 GMT
Author: tjungblut
Date: Wed Feb 22 14:35:22 2012
New Revision: 1292317

URL: http://svn.apache.org/viewvc?rev=1292317&view=rev
Log:
[HAMA-510]: Add sendMessageToNeighbors() to Vertex

Modified:
    incubator/hama/trunk/CHANGES.txt
    incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/InlinkCount.java
    incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/PageRank.java
    incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/Vertex.java
    incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/VertexInterface.java

Modified: incubator/hama/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/CHANGES.txt?rev=1292317&r1=1292316&r2=1292317&view=diff
==============================================================================
--- incubator/hama/trunk/CHANGES.txt (original)
+++ incubator/hama/trunk/CHANGES.txt Wed Feb 22 14:35:22 2012
@@ -11,7 +11,8 @@ Release 0.5 - Unreleased
   BUG FIXES
 
   IMPROVEMENTS
-
+    
+    HAMA-510: Add sendMessageToNeighbors() to Vertex (tjungblut)
     HAMA-502: Message API Improvement (edwardyoon)
   
 Release 0.4 - February 5, 2012

Modified: incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/InlinkCount.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/InlinkCount.java?rev=1292317&r1=1292316&r2=1292317&view=diff
==============================================================================
--- incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/InlinkCount.java
(original)
+++ incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/InlinkCount.java
Wed Feb 22 14:35:22 2012
@@ -26,7 +26,6 @@ import org.apache.hama.HamaConfiguration
 import org.apache.hama.bsp.HashPartitioner;
 import org.apache.hama.bsp.SequenceFileInputFormat;
 import org.apache.hama.bsp.SequenceFileOutputFormat;
-import org.apache.hama.graph.Edge;
 import org.apache.hama.graph.GraphJob;
 import org.apache.hama.graph.Vertex;
 import org.apache.hama.graph.VertexArrayWritable;
@@ -38,9 +37,7 @@ public class InlinkCount extends Vertex<
   public void compute(Iterator<IntWritable> messages) throws IOException {
 
     if (getSuperstepCount() == 0L) {
-      for (Edge e : getOutEdges()) {
-        sendMessage(e, new IntWritable(1));
-      }
+      sendMessageToNeighbors(new IntWritable(1));
     } else {
       while (messages.hasNext()) {
         IntWritable msg = messages.next();

Modified: incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/PageRank.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/PageRank.java?rev=1292317&r1=1292316&r2=1292317&view=diff
==============================================================================
--- incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/PageRank.java (original)
+++ incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/PageRank.java Wed
Feb 22 14:35:22 2012
@@ -28,7 +28,6 @@ import org.apache.hama.HamaConfiguration
 import org.apache.hama.bsp.HashPartitioner;
 import org.apache.hama.bsp.SequenceFileInputFormat;
 import org.apache.hama.bsp.SequenceFileOutputFormat;
-import org.apache.hama.graph.Edge;
 import org.apache.hama.graph.GraphJob;
 import org.apache.hama.graph.Vertex;
 
@@ -55,10 +54,8 @@ public class PageRank {
 
       if (this.getSuperstepCount() < this.getMaxIteration()) {
         int numEdges = this.getOutEdges().size();
-        for (Edge e : this.getOutEdges()) {
-          this.sendMessage(e, new DoubleWritable(this.getValue().get()
-              / numEdges));
-        }
+        sendMessageToNeighbors(new DoubleWritable(this.getValue().get()
+            / numEdges));
       }
     }
   }

Modified: incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/Vertex.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/Vertex.java?rev=1292317&r1=1292316&r2=1292317&view=diff
==============================================================================
--- incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/Vertex.java (original)
+++ incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/Vertex.java Wed Feb 22
14:35:22 2012
@@ -26,8 +26,7 @@ import org.apache.hadoop.io.Text;
 import org.apache.hadoop.io.Writable;
 import org.apache.hama.bsp.BSPPeer;
 
-public abstract class Vertex<M extends Writable> implements
-    VertexInterface<M> {
+public abstract class Vertex<M extends Writable> implements VertexInterface<M>
{
   private M value;
   private String vertexID;
   protected BSPPeer<?, ?, ?, ?, MapWritable> peer;
@@ -52,6 +51,14 @@ public abstract class Vertex<M extends W
   }
 
   @Override
+  public void sendMessageToNeighbors(M msg) throws IOException {
+    final List<Edge> outEdges = this.getOutEdges();
+    for (Edge e : outEdges) {
+      sendMessage(e, msg);
+    }
+  }
+
+  @Override
   public long getSuperstepCount() {
     return peer.getSuperstepCount();
   }

Modified: incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/VertexInterface.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/VertexInterface.java?rev=1292317&r1=1292316&r2=1292317&view=diff
==============================================================================
--- incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/VertexInterface.java (original)
+++ incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/VertexInterface.java Wed
Feb 22 14:35:22 2012
@@ -34,6 +34,8 @@ public interface VertexInterface<MSGTYPE
 
   public void sendMessage(Edge e, MSGTYPE msg) throws IOException;
 
+  public void sendMessageToNeighbors(MSGTYPE msg) throws IOException;
+
   public long getSuperstepCount();
 
   public void setValue(MSGTYPE value);



Mime
View raw message