You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2015/03/17 18:43:55 UTC
incubator-tinkerpop git commit: The Giraph configuration is no longer
stored with the Vertex.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/master f8ec9573a -> bbd0c68a8
The Giraph configuration is no longer stored with the Vertex.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/bbd0c68a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/bbd0c68a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/bbd0c68a
Branch: refs/heads/master
Commit: bbd0c68a8f8fba1588ac10311e34e6d01f6428df
Parents: f8ec957
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Tue Mar 17 11:43:52 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Tue Mar 17 11:43:52 2015 -0600
----------------------------------------------------------------------
.../computer/giraph/GiraphComputeVertex.java | 16 ++++++++++++----
.../computer/giraph/GiraphWorkerContext.java | 7 +++++++
2 files changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bbd0c68a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/GiraphComputeVertex.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/GiraphComputeVertex.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/GiraphComputeVertex.java
index a0252c9..4b707d1 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/GiraphComputeVertex.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/GiraphComputeVertex.java
@@ -18,6 +18,7 @@
*/
package org.apache.tinkerpop.gremlin.hadoop.process.computer.giraph;
+import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
import org.apache.giraph.graph.Vertex;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
@@ -47,19 +48,26 @@ public final class GiraphComputeVertex extends Vertex<LongWritable, VertexWritab
final VertexWritable newWritable = new VertexWritable();
newWritable.set(vertexWritable.get());
this.initialize(new LongWritable(Long.valueOf(newWritable.get().id().toString())), newWritable, EmptyOutEdges.instance());
+
+ }
+
+ @Override
+ public void setConf(final ImmutableClassesGiraphConfiguration<LongWritable, VertexWritable, NullWritable, ObjectWritable> configuration) {
+ // do nothing -- no need to store the configuration with the giraph vertex
}
@Override
public void compute(final Iterable<ObjectWritable> messages) {
- final VertexProgram vertexProgram = ((GiraphWorkerContext) this.getWorkerContext()).getVertexProgram();
- final GiraphMemory memory = ((GiraphWorkerContext) this.getWorkerContext()).getMemory();
- final GiraphMessenger messenger = ((GiraphWorkerContext) this.getWorkerContext()).getMessenger(this, messages);
+ final GiraphWorkerContext workerContext = (GiraphWorkerContext) this.getWorkerContext();
+ final VertexProgram vertexProgram = workerContext.getVertexProgram();
+ final GiraphMemory memory = workerContext.getMemory();
+ final GiraphMessenger messenger = workerContext.getMessenger(this, messages);
if (null == this.wrappedVertex)
this.wrappedVertex = ComputerDataStrategy.wrapVertex(this.getValue().get(), vertexProgram);
///////////
if (!(Boolean) ((RuleWritable) this.getAggregatedValue(Constants.GREMLIN_HADOOP_HALT)).getObject())
vertexProgram.execute(this.wrappedVertex, messenger, memory); // TODO provide a wrapper around TinkerVertex for Edge and non-ComputeKeys manipulation
- else if (this.getConf().getBoolean(Constants.GREMLIN_HADOOP_DERIVE_MEMORY, false)) {
+ else if (workerContext.deriveMemory()) {
final MapMemory mapMemory = new MapMemory();
memory.asMap().forEach(mapMemory::set);
mapMemory.setIteration(memory.getIteration() - 1);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bbd0c68a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/GiraphWorkerContext.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/GiraphWorkerContext.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/GiraphWorkerContext.java
index 91e7423..55dd82c 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/GiraphWorkerContext.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/GiraphWorkerContext.java
@@ -19,6 +19,7 @@
package org.apache.tinkerpop.gremlin.hadoop.process.computer.giraph;
import org.apache.giraph.worker.WorkerContext;
+import org.apache.tinkerpop.gremlin.hadoop.Constants;
import org.apache.tinkerpop.gremlin.hadoop.structure.io.ObjectWritable;
import org.apache.tinkerpop.gremlin.hadoop.structure.util.ConfUtil;
import org.apache.tinkerpop.gremlin.process.computer.VertexProgram;
@@ -32,6 +33,7 @@ public final class GiraphWorkerContext extends WorkerContext {
private VertexProgram<?> vertexProgram;
private GiraphMemory memory;
private GiraphMessenger messenger;
+ private boolean deriveMemory;
public GiraphWorkerContext() {
// Giraph ReflectionUtils requires this to be public at minimum
@@ -41,6 +43,7 @@ public final class GiraphWorkerContext extends WorkerContext {
this.vertexProgram = VertexProgram.createVertexProgram(ConfUtil.makeApacheConfiguration(this.getContext().getConfiguration()));
this.memory = new GiraphMemory(this, this.vertexProgram);
this.messenger = new GiraphMessenger();
+ this.deriveMemory = this.getContext().getConfiguration().getBoolean(Constants.GREMLIN_HADOOP_DERIVE_MEMORY, false);
}
public void postApplication() {
@@ -67,4 +70,8 @@ public final class GiraphWorkerContext extends WorkerContext {
this.messenger.setCurrentVertex(giraphComputeVertex, messages);
return this.messenger;
}
+
+ public boolean deriveMemory() {
+ return this.deriveMemory;
+ }
}