Return-Path: X-Original-To: apmail-hama-commits-archive@www.apache.org Delivered-To: apmail-hama-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DAC4510443 for ; Fri, 7 Mar 2014 01:53:06 +0000 (UTC) Received: (qmail 27915 invoked by uid 500); 7 Mar 2014 01:53:06 -0000 Delivered-To: apmail-hama-commits-archive@hama.apache.org Received: (qmail 27867 invoked by uid 500); 7 Mar 2014 01:53:05 -0000 Mailing-List: contact commits-help@hama.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hama.apache.org Delivered-To: mailing list commits@hama.apache.org Received: (qmail 27859 invoked by uid 99); 7 Mar 2014 01:53:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Mar 2014 01:53:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Mar 2014 01:53:03 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 95535238890D; Fri, 7 Mar 2014 01:52:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1575117 - /hama/trunk/src/site/xdoc/hama_graph_tutorial.xml Date: Fri, 07 Mar 2014 01:52:41 -0000 To: commits@hama.apache.org From: edwardyoon@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140307015241.95535238890D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: edwardyoon Date: Fri Mar 7 01:52:41 2014 New Revision: 1575117 URL: http://svn.apache.org/r1575117 Log: Add vertex writer API guide Modified: hama/trunk/src/site/xdoc/hama_graph_tutorial.xml Modified: hama/trunk/src/site/xdoc/hama_graph_tutorial.xml URL: http://svn.apache.org/viewvc/hama/trunk/src/site/xdoc/hama_graph_tutorial.xml?rev=1575117&r1=1575116&r2=1575117&view=diff ============================================================================== --- hama/trunk/src/site/xdoc/hama_graph_tutorial.xml (original) +++ hama/trunk/src/site/xdoc/hama_graph_tutorial.xml Fri Mar 7 01:52:41 2014 @@ -41,8 +41,8 @@ xsi:schemaLocation="http://maven.apache.

The user overrides the Compute() method, which will be executed at each active vertex in every superstep. Predefined Vertex methods allow Compute() to query information about the current vertex and its edges, and to send messages to other vertices. Compute() can inspect the value associated with its vertex via GetValue().

- -

You can create your own VertexReader for your data format by exending org.apache.hama.graph.VertexInputReader class. + +

Hama Graph provides very flexible input and output options. You can create your own VertexReader for your data format by exending org.apache.hama.graph.VertexInputReader class. For example, an sequence file contains a linked list of Vertex, can be parse as following:

@@ -63,6 +63,20 @@ xsi:schemaLocation="http://maven.apache. } } + + And also, you can create your own Writer by implementing org.apache.hama.graph.VertexOutputWriter class. + See the SemiClusterVertexOutputWriter example: +
+  @Override
+  public void write(Vertex<V, E, M> vertex,
+      BSPPeer<Writable, Writable, KEYOUT, VALUEOUT, GraphJobMessage> peer)
+      throws IOException {
+    SemiClusterMessage vertexValue = (SemiClusterMessage) vertex.getValue();
+    peer.write((KEYOUT) vertex.getVertexID(), (VALUEOUT) new Text(vertexValue
+        .getSemiClusterContainThis().toString()));
+  }
+  
+

Sending a message to another vertex that exists on a different machine has some overhead. However if the algorithm doesn't require each message explicitly but a function of it (example sum) then combiners can be used.

Write your own Combiner

@@ -96,7 +110,7 @@ xsi:schemaLocation="http://maven.apache. this.getAggregatedValue(index);

Write your own aggregators

-

To write your own aggregator, you have to extend AbstractAggregator class and implement the methods of #aggregate(M value) and #getValue(). For more, please see the default implementation of aggregators in org.apache.hama.graph package.

+

To write your own aggregator, you have to extend org.apache.hama.graph.AbstractAggregator class and implement the methods of #aggregate(M value) and #getValue(). For more, please see the default implementation of aggregators in org.apache.hama.graph package.

To solve the Page Rank problem using Hama Graph, you can extends the Vertex class to create a PageRankVertex class. In this example, the algorithm described Google's Pregel paper was used. The value of a vertex represents the tentative page rank of the vertex. The graph is intialized with each vertex value equal to 1/numOfVertices. In each of the first 30 supersteps, each vertex sends its tentative page rank along all of its outgoing edges.