giraph-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apre...@apache.org
Subject svn commit: r1399043 - in /giraph/trunk: CHANGELOG giraph/src/main/java/org/apache/giraph/examples/SimpleMutateGraphVertex.java giraph/src/main/java/org/apache/giraph/graph/MutableVertex.java giraph/src/main/java/org/apache/giraph/graph/Vertex.java
Date Tue, 16 Oct 2012 23:26:10 GMT
Author: apresta
Date: Tue Oct 16 23:26:09 2012
New Revision: 1399043

URL: http://svn.apache.org/viewvc?rev=1399043&view=rev
Log:
GIRAPH-375: Cleaner MutableVertex API (apresta)

Modified:
    giraph/trunk/CHANGELOG
    giraph/trunk/giraph/src/main/java/org/apache/giraph/examples/SimpleMutateGraphVertex.java
    giraph/trunk/giraph/src/main/java/org/apache/giraph/graph/MutableVertex.java
    giraph/trunk/giraph/src/main/java/org/apache/giraph/graph/Vertex.java

Modified: giraph/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/giraph/trunk/CHANGELOG?rev=1399043&r1=1399042&r2=1399043&view=diff
==============================================================================
--- giraph/trunk/CHANGELOG (original)
+++ giraph/trunk/CHANGELOG Tue Oct 16 23:26:09 2012
@@ -1,6 +1,8 @@
 Giraph Change Log
 
 Release 0.2.0 - unreleased
+  GIRAPH-375: Cleaner MutableVertex API (apresta)
+
   GIRAPH-371: Replace BspUtils in giraph-formats-contrib for
   speed. (aching)
 

Modified: giraph/trunk/giraph/src/main/java/org/apache/giraph/examples/SimpleMutateGraphVertex.java
URL: http://svn.apache.org/viewvc/giraph/trunk/giraph/src/main/java/org/apache/giraph/examples/SimpleMutateGraphVertex.java?rev=1399043&r1=1399042&r2=1399043&view=diff
==============================================================================
--- giraph/trunk/giraph/src/main/java/org/apache/giraph/examples/SimpleMutateGraphVertex.java
(original)
+++ giraph/trunk/giraph/src/main/java/org/apache/giraph/examples/SimpleMutateGraphVertex.java
Tue Oct 16 23:26:09 2012
@@ -20,7 +20,6 @@ package org.apache.giraph.examples;
 
 import org.apache.giraph.graph.Edge;
 import org.apache.giraph.graph.EdgeListVertex;
-import org.apache.giraph.graph.Vertex;
 import org.apache.giraph.graph.WorkerContext;
 import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.FloatWritable;
@@ -85,10 +84,7 @@ public class SimpleMutateGraphVertex ext
       // Create vertices that are sure not to exist (doubling vertices)
       LongWritable vertexIndex =
           new LongWritable(rangeVertexIdStart(3) + getId().get());
-      Vertex<LongWritable, DoubleWritable,
-            FloatWritable, DoubleWritable> vertex =
-        instantiateVertex(vertexIndex, new DoubleWritable(0.0), null);
-      addVertexRequest(vertex);
+      addVertexRequest(vertexIndex, new DoubleWritable(0.0));
       // Add edges to those remote vertices as well
       addEdgeRequest(vertexIndex,
           new Edge<LongWritable, FloatWritable>(

Modified: giraph/trunk/giraph/src/main/java/org/apache/giraph/graph/MutableVertex.java
URL: http://svn.apache.org/viewvc/giraph/trunk/giraph/src/main/java/org/apache/giraph/graph/MutableVertex.java?rev=1399043&r1=1399042&r2=1399043&view=diff
==============================================================================
--- giraph/trunk/giraph/src/main/java/org/apache/giraph/graph/MutableVertex.java (original)
+++ giraph/trunk/giraph/src/main/java/org/apache/giraph/graph/MutableVertex.java Tue Oct 16
23:26:09 2012
@@ -22,6 +22,7 @@ import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.io.WritableComparable;
 
 import java.io.IOException;
+import java.util.Collections;
 import java.util.Map;
 
 /**
@@ -56,33 +57,29 @@ public abstract class MutableVertex<I ex
   public abstract E removeEdge(I targetVertexId);
 
   /**
-   * Create a vertex to add to the graph.  Calls initialize() for the vertex
-   * as well.
+   * Sends a request to create a vertex that will be available during the
+   * next superstep.
    *
-   * @param vertexId Id of the new vertex.
-   * @param vertexValue Value of the new vertex.
-   * @param edges Map of edges to be added to this vertex.
-   * @return A new vertex for adding to the graph
-   */
-  public Vertex<I, V, E, M> instantiateVertex(
-      I vertexId, V vertexValue, Map<I, E> edges) {
-    MutableVertex<I, V, E, M> mutableVertex =
-        (MutableVertex<I, V, E, M>) getConf().createVertex();
-    mutableVertex.setGraphState(getGraphState());
-    mutableVertex.initialize(vertexId, vertexValue, edges);
-    return mutableVertex;
+   * @param id Vertex id
+   * @param value Vertex value
+   * @param edges Initial edges
+   */
+  public void addVertexRequest(I id, V value, Map<I, E> edges)
+    throws IOException {
+    Vertex<I, V, E, M> vertex = getConf().createVertex();
+    vertex.initialize(id, value, edges);
+    getGraphState().getWorkerCommunications().addVertexRequest(vertex);
   }
 
   /**
    * Sends a request to create a vertex that will be available during the
-   * next superstep.  Use instantiateVertex() to do the instantiation.
+   * next superstep.
    *
-   * @param vertex User created vertex
+   * @param id Vertex id
+   * @param value Vertex value
    */
-  public void addVertexRequest(Vertex<I, V, E, M> vertex)
-    throws IOException {
-    getGraphState().getWorkerCommunications().
-        addVertexRequest(vertex);
+  public void addVertexRequest(I id, V value) throws IOException {
+    addVertexRequest(id, value, Collections.<I, E>emptyMap());
   }
 
   /**
@@ -92,8 +89,7 @@ public abstract class MutableVertex<I ex
    * @param vertexId Id of the vertex to be removed.
    */
   public void removeVertexRequest(I vertexId) throws IOException {
-    getGraphState().getWorkerCommunications().
-        removeVertexRequest(vertexId);
+    getGraphState().getWorkerCommunications().removeVertexRequest(vertexId);
   }
 
   /**

Modified: giraph/trunk/giraph/src/main/java/org/apache/giraph/graph/Vertex.java
URL: http://svn.apache.org/viewvc/giraph/trunk/giraph/src/main/java/org/apache/giraph/graph/Vertex.java?rev=1399043&r1=1399042&r2=1399043&view=diff
==============================================================================
--- giraph/trunk/giraph/src/main/java/org/apache/giraph/graph/Vertex.java (original)
+++ giraph/trunk/giraph/src/main/java/org/apache/giraph/graph/Vertex.java Tue Oct 16 23:26:09
2012
@@ -27,11 +27,11 @@ import org.apache.hadoop.io.WritableComp
 import org.apache.hadoop.mapreduce.Mapper;
 
 import com.google.common.collect.Iterables;
-import com.google.common.collect.Maps;
 
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -85,7 +85,7 @@ public abstract class Vertex<I extends W
   public void initialize(I id, V value) {
     this.id = id;
     this.value = value;
-    setEdges(Maps.<I, E>newHashMapWithExpectedSize(0));
+    setEdges(Collections.<I, E>emptyMap());
   }
 
   /**



Mime
View raw message