You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@giraph.apache.org by ap...@apache.org on 2013/04/16 03:12:06 UTC
[2/2] git commit: updated refs/heads/trunk to 158c0b1
GIRAPH-633: Rename VertexEdges to OutEdges (apresta)
Project: http://git-wip-us.apache.org/repos/asf/giraph/repo
Commit: http://git-wip-us.apache.org/repos/asf/giraph/commit/158c0b11
Tree: http://git-wip-us.apache.org/repos/asf/giraph/tree/158c0b11
Diff: http://git-wip-us.apache.org/repos/asf/giraph/diff/158c0b11
Branch: refs/heads/trunk
Commit: 158c0b1180fa8f01bffd119df49b982fdda22771
Parents: 38f1f17
Author: Alessandro Presta <al...@fb.com>
Authored: Mon Apr 15 11:40:47 2013 -0700
Committer: Alessandro Presta <al...@fb.com>
Committed: Mon Apr 15 13:53:47 2013 -0700
----------------------------------------------------------------------
.../apache/giraph/benchmark/PageRankBenchmark.java | 2 +-
.../giraph/benchmark/ShortestPathsBenchmark.java | 6 +-
.../benchmark/WeightedPageRankBenchmark.java | 16 ++--
.../java/org/apache/giraph/conf/GiraphClasses.java | 48 ++++----
.../apache/giraph/conf/GiraphConfiguration.java | 34 +++---
.../org/apache/giraph/conf/GiraphConstants.java | 14 +-
.../conf/ImmutableClassesGiraphConfiguration.java | 95 ++++++++-------
.../org/apache/giraph/edge/ArrayListEdges.java | 6 +-
.../org/apache/giraph/edge/ByteArrayEdges.java | 6 +-
.../apache/giraph/edge/ConfigurableOutEdges.java | 36 ++++++
.../giraph/edge/ConfigurableVertexEdges.java | 36 ------
.../java/org/apache/giraph/edge/EdgeStore.java | 52 ++++----
.../java/org/apache/giraph/edge/HashMapEdges.java | 8 +-
.../org/apache/giraph/edge/HashMultimapEdges.java | 6 +-
.../org/apache/giraph/edge/IntNullArrayEdges.java | 4 +-
.../apache/giraph/edge/LongDoubleArrayEdges.java | 6 +-
.../apache/giraph/edge/LongDoubleHashMapEdges.java | 8 +-
.../org/apache/giraph/edge/LongNullArrayEdges.java | 6 +-
.../apache/giraph/edge/LongNullHashSetEdges.java | 6 +-
.../giraph/edge/MultiRandomAccessOutEdges.java | 41 ++++++
.../giraph/edge/MultiRandomAccessVertexEdges.java | 41 ------
.../apache/giraph/edge/MutableEdgesIterable.java | 6 +-
.../apache/giraph/edge/MutableEdgesWrapper.java | 24 ++--
.../org/apache/giraph/edge/MutableOutEdges.java | 42 +++++++
.../org/apache/giraph/edge/MutableVertexEdges.java | 42 -------
.../main/java/org/apache/giraph/edge/OutEdges.java | 84 +++++++++++++
.../apache/giraph/edge/ReuseObjectsOutEdges.java | 34 +++++
.../giraph/edge/ReuseObjectsVertexEdges.java | 34 -----
.../giraph/edge/StrictRandomAccessOutEdges.java | 51 ++++++++
.../giraph/edge/StrictRandomAccessVertexEdges.java | 51 --------
.../java/org/apache/giraph/edge/VertexEdges.java | 84 -------------
.../main/java/org/apache/giraph/graph/Vertex.java | 55 ++++----
.../io/formats/PseudoRandomEdgeInputFormat.java | 12 +-
.../PseudoRandomIntNullVertexInputFormat.java | 6 +-
.../io/formats/PseudoRandomVertexInputFormat.java | 8 +-
.../giraph/job/GiraphConfigurationValidator.java | 34 +++---
.../giraph/partition/ByteArrayPartition.java | 4 +-
.../giraph/partition/DiskBackedPartitionStore.java | 16 ++--
.../apache/giraph/utils/ConfigurationUtils.java | 12 +-
.../org/apache/giraph/utils/WritableUtils.java | 8 +-
.../apache/giraph/edge/TestMultiGraphEdges.java | 18 ++--
.../giraph/edge/TestMultiRandomAccessEdges.java | 20 ++--
.../org/apache/giraph/edge/TestNullValueEdges.java | 28 ++--
.../apache/giraph/edge/TestStrictGraphEdges.java | 18 ++--
.../giraph/edge/TestStrictRandomAccessEdges.java | 20 ++--
.../apache/giraph/graph/TestVertexAndEdges.java | 96 +++++++-------
.../java/org/apache/giraph/io/TestEdgeInput.java | 18 ++--
.../apache/giraph/master/TestMasterObserver.java | 2 +-
.../partition/TestGiraphTransferRegulator.java | 4 +-
.../examples/ConnectedComponentsVertexTest.java | 2 +-
.../ConnectedComponentsVertexTestInMemory.java | 2 +-
.../apache/giraph/examples/PageRankVertexTest.java | 2 +-
.../examples/RandomWalkWithRestartVertexTest.java | 4 +-
.../examples/SimpleShortestPathsVertexTest.java | 2 +-
.../examples/TryMultiIpcBindingPortsTest.java | 2 +-
src/site/xdoc/io.xml | 33 +++---
56 files changed, 679 insertions(+), 676 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/benchmark/PageRankBenchmark.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/benchmark/PageRankBenchmark.java b/giraph-core/src/main/java/org/apache/giraph/benchmark/PageRankBenchmark.java
index 3a755c8..0f8d284 100644
--- a/giraph-core/src/main/java/org/apache/giraph/benchmark/PageRankBenchmark.java
+++ b/giraph-core/src/main/java/org/apache/giraph/benchmark/PageRankBenchmark.java
@@ -45,7 +45,7 @@ public class PageRankBenchmark extends GiraphBenchmark {
protected void prepareConfiguration(GiraphConfiguration conf,
CommandLine cmd) {
conf.setVertexClass(PageRankVertex.class);
- conf.setVertexEdgesClass(IntNullArrayEdges.class);
+ conf.setOutEdgesClass(IntNullArrayEdges.class);
conf.setCombinerClass(FloatSumCombiner.class);
conf.setVertexInputFormatClass(
PseudoRandomIntNullVertexInputFormat.class);
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/benchmark/ShortestPathsBenchmark.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/benchmark/ShortestPathsBenchmark.java b/giraph-core/src/main/java/org/apache/giraph/benchmark/ShortestPathsBenchmark.java
index df53ee6..8e6c877 100644
--- a/giraph-core/src/main/java/org/apache/giraph/benchmark/ShortestPathsBenchmark.java
+++ b/giraph-core/src/main/java/org/apache/giraph/benchmark/ShortestPathsBenchmark.java
@@ -41,7 +41,7 @@ public class ShortestPathsBenchmark extends GiraphBenchmark {
private static final Logger LOG =
Logger.getLogger(ShortestPathsBenchmark.class);
- /** Option for VertexEdges class */
+ /** Option for OutEdges class */
private static final BenchmarkOption EDGES_CLASS = new BenchmarkOption(
"c", "edgesClass", true,
"Vertex edges class (0 for HashMapEdges, 1 for ArrayListEdges)");
@@ -60,9 +60,9 @@ public class ShortestPathsBenchmark extends GiraphBenchmark {
CommandLine cmd) {
conf.setVertexClass(ShortestPathsVertex.class);
if (EDGES_CLASS.getOptionIntValue(cmd, 1) == 1) {
- conf.setVertexEdgesClass(ArrayListEdges.class);
+ conf.setOutEdgesClass(ArrayListEdges.class);
} else {
- conf.setVertexEdgesClass(HashMapEdges.class);
+ conf.setOutEdgesClass(HashMapEdges.class);
}
LOG.info("Using class " + GiraphConstants.VERTEX_CLASS.get(conf));
conf.setVertexInputFormatClass(PseudoRandomVertexInputFormat.class);
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/benchmark/WeightedPageRankBenchmark.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/benchmark/WeightedPageRankBenchmark.java b/giraph-core/src/main/java/org/apache/giraph/benchmark/WeightedPageRankBenchmark.java
index 9de10b5..3fc514a 100644
--- a/giraph-core/src/main/java/org/apache/giraph/benchmark/WeightedPageRankBenchmark.java
+++ b/giraph-core/src/main/java/org/apache/giraph/benchmark/WeightedPageRankBenchmark.java
@@ -45,7 +45,7 @@ public class WeightedPageRankBenchmark extends GiraphBenchmark {
private static final Logger LOG =
Logger.getLogger(WeightedPageRankBenchmark.class);
- /** Option for VertexEdges class */
+ /** Option for OutEdges class */
private static final BenchmarkOption EDGES_CLASS = new BenchmarkOption(
"c", "edgesClass", true,
"Vertex edges class (0 for LongDoubleArrayEdges," +
@@ -92,25 +92,25 @@ public class WeightedPageRankBenchmark extends GiraphBenchmark {
int edgesClassOption = EDGES_CLASS.getOptionIntValue(cmd, 1);
switch (edgesClassOption) {
case 0:
- configuration.setVertexEdgesClass(LongDoubleArrayEdges.class);
+ configuration.setOutEdgesClass(LongDoubleArrayEdges.class);
break;
case 1:
- configuration.setVertexEdgesClass(ByteArrayEdges.class);
+ configuration.setOutEdgesClass(ByteArrayEdges.class);
break;
case 2:
- configuration.setVertexEdgesClass(ByteArrayEdges.class);
+ configuration.setOutEdgesClass(ByteArrayEdges.class);
configuration.useUnsafeSerialization(true);
break;
case 3:
- configuration.setVertexEdgesClass(ArrayListEdges.class);
+ configuration.setOutEdgesClass(ArrayListEdges.class);
break;
case 4:
- configuration.setVertexEdgesClass(HashMapEdges.class);
+ configuration.setOutEdgesClass(HashMapEdges.class);
break;
default:
- LOG.info("Unknown VertexEdges class, " +
+ LOG.info("Unknown OutEdges class, " +
"defaulting to LongDoubleArrayEdges");
- configuration.setVertexEdgesClass(LongDoubleArrayEdges.class);
+ configuration.setOutEdgesClass(LongDoubleArrayEdges.class);
}
LOG.info("Using edges class " +
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/conf/GiraphClasses.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/conf/GiraphClasses.java b/giraph-core/src/main/java/org/apache/giraph/conf/GiraphClasses.java
index 95499bd..4a0e8f7 100644
--- a/giraph-core/src/main/java/org/apache/giraph/conf/GiraphClasses.java
+++ b/giraph-core/src/main/java/org/apache/giraph/conf/GiraphClasses.java
@@ -21,7 +21,7 @@ import org.apache.giraph.aggregators.AggregatorWriter;
import org.apache.giraph.aggregators.TextAggregatorWriter;
import org.apache.giraph.combiner.Combiner;
import org.apache.giraph.edge.ByteArrayEdges;
-import org.apache.giraph.edge.VertexEdges;
+import org.apache.giraph.edge.OutEdges;
import org.apache.giraph.graph.DefaultVertexResolver;
import org.apache.giraph.graph.DefaultVertexValueFactory;
import org.apache.giraph.graph.Vertex;
@@ -70,9 +70,9 @@ public class GiraphClasses<I extends WritableComparable,
/** Message value class - cached for fast access */
protected Class<M> messageValueClass;
/** Vertex edges class - cached for fast access */
- protected Class<? extends VertexEdges<I, E>> vertexEdgesClass;
+ protected Class<? extends OutEdges<I, E>> outEdgesClass;
/** Input vertex edges class - cached for fast access */
- protected Class<? extends VertexEdges<I, E>> inputVertexEdgesClass;
+ protected Class<? extends OutEdges<I, E>> inputOutEdgesClass;
/** Vertex value factory class - cached for fast access */
protected Class<? extends VertexValueFactory<V>> vertexValueFactoryClass;
@@ -114,9 +114,9 @@ public class GiraphClasses<I extends WritableComparable,
public GiraphClasses() {
// Note: the cast to Object is required in order for javac to accept the
// downcast.
- vertexEdgesClass = (Class<? extends VertexEdges<I, E>>) (Object)
+ outEdgesClass = (Class<? extends OutEdges<I, E>>) (Object)
ByteArrayEdges.class;
- inputVertexEdgesClass = (Class<? extends VertexEdges<I, E>>) (Object)
+ inputOutEdgesClass = (Class<? extends OutEdges<I, E>>) (Object)
ByteArrayEdges.class;
vertexValueFactoryClass = (Class<? extends VertexValueFactory<V>>) (Object)
DefaultVertexValueFactory.class;
@@ -157,10 +157,10 @@ public class GiraphClasses<I extends WritableComparable,
edgeValueClass = (Class<E>) classList.get(2);
messageValueClass = (Class<M>) classList.get(3);
- vertexEdgesClass = (Class<? extends VertexEdges<I, E>>)
+ outEdgesClass = (Class<? extends OutEdges<I, E>>)
VERTEX_EDGES_CLASS.get(conf);
- inputVertexEdgesClass = (Class<? extends VertexEdges<I, E>>)
- INPUT_VERTEX_EDGES_CLASS.getWithDefault(conf, vertexEdgesClass);
+ inputOutEdgesClass = (Class<? extends OutEdges<I, E>>)
+ INPUT_VERTEX_EDGES_CLASS.getWithDefault(conf, outEdgesClass);
vertexValueFactoryClass = (Class<? extends VertexValueFactory<V>>)
VERTEX_VALUE_FACTORY_CLASS.get(conf);
@@ -237,16 +237,16 @@ public class GiraphClasses<I extends WritableComparable,
*
* @return Vertex edges class.
*/
- public Class<? extends VertexEdges<I, E>> getVertexEdgesClass() {
- return vertexEdgesClass;
+ public Class<? extends OutEdges<I, E>> getOutEdgesClass() {
+ return outEdgesClass;
}
/* Get Vertex edges class used during edge-based input
*
* @return Vertex edges class.
*/
- public Class<? extends VertexEdges<I, E>> getInputVertexEdgesClass() {
- return inputVertexEdgesClass;
+ public Class<? extends OutEdges<I, E>> getInputOutEdgesClass() {
+ return inputOutEdgesClass;
}
@@ -508,29 +508,29 @@ public class GiraphClasses<I extends WritableComparable,
}
/**
- * Set VertexEdges class held
+ * Set OutEdges class held
*
- * @param vertexEdgesClass Vertex edges class to set
+ * @param outEdgesClass Vertex edges class to set
* @return this
*/
- public GiraphClasses setVertexEdgesClass(
- Class<? extends VertexEdges> vertexEdgesClass) {
- this.vertexEdgesClass =
- (Class<? extends VertexEdges<I, E>>) vertexEdgesClass;
+ public GiraphClasses setOutEdgesClass(
+ Class<? extends OutEdges> outEdgesClass) {
+ this.outEdgesClass =
+ (Class<? extends OutEdges<I, E>>) outEdgesClass;
return this;
}
/**
- * Set VertexEdges class used during edge-input (if different from the one
+ * Set OutEdges class used during edge-input (if different from the one
* used for computation)
*
- * @param inputVertexEdgesClass Input vertex edges class to set
+ * @param inputOutEdgesClass Input vertex edges class to set
* @return this
*/
- public GiraphClasses setInputVertexEdgesClass(
- Class<? extends VertexEdges> inputVertexEdgesClass) {
- this.inputVertexEdgesClass =
- (Class<? extends VertexEdges<I, E>>) inputVertexEdgesClass;
+ public GiraphClasses setInputOutEdgesClass(
+ Class<? extends OutEdges> inputOutEdgesClass) {
+ this.inputOutEdgesClass =
+ (Class<? extends OutEdges<I, E>>) inputOutEdgesClass;
return this;
}
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConfiguration.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConfiguration.java b/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConfiguration.java
index c527595..7f9e38e 100644
--- a/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConfiguration.java
+++ b/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConfiguration.java
@@ -20,8 +20,8 @@ package org.apache.giraph.conf;
import org.apache.giraph.aggregators.AggregatorWriter;
import org.apache.giraph.combiner.Combiner;
-import org.apache.giraph.edge.ReuseObjectsVertexEdges;
-import org.apache.giraph.edge.VertexEdges;
+import org.apache.giraph.edge.OutEdges;
+import org.apache.giraph.edge.ReuseObjectsOutEdges;
import org.apache.giraph.graph.Vertex;
import org.apache.giraph.graph.VertexResolver;
import org.apache.giraph.graph.VertexValueFactory;
@@ -100,36 +100,36 @@ public class GiraphConfiguration extends Configuration
*
* @return vertex edges class
*/
- public Class<? extends VertexEdges> getVertexEdgesClass() {
+ public Class<? extends OutEdges> getOutEdgesClass() {
return VERTEX_EDGES_CLASS.get(this);
}
/**
* Set the vertex edges class
*
- * @param vertexEdgesClass Determines the way edges are stored
+ * @param outEdgesClass Determines the way edges are stored
*/
- public final void setVertexEdgesClass(
- Class<? extends VertexEdges> vertexEdgesClass) {
- VERTEX_EDGES_CLASS.set(this, vertexEdgesClass);
+ public final void setOutEdgesClass(
+ Class<? extends OutEdges> outEdgesClass) {
+ VERTEX_EDGES_CLASS.set(this, outEdgesClass);
}
/**
* Set the vertex edges class used during edge-based input (if different
* from the one used during computation)
*
- * @param inputVertexEdgesClass Determines the way edges are stored
+ * @param inputOutEdgesClass Determines the way edges are stored
*/
- public final void setInputVertexEdgesClass(
- Class<? extends VertexEdges> inputVertexEdgesClass) {
- INPUT_VERTEX_EDGES_CLASS.set(this, inputVertexEdgesClass);
+ public final void setInputOutEdgesClass(
+ Class<? extends OutEdges> inputOutEdgesClass) {
+ INPUT_VERTEX_EDGES_CLASS.set(this, inputOutEdgesClass);
}
/**
- * True if the {@link VertexEdges} implementation copies the passed edges
- * to its own data structure, i.e. it doesn't keep references to Edge
- * objects, target vertex ids or edge values passed to add() or
- * initialize().
+ * True if the {@link org.apache.giraph.edge.OutEdges} implementation
+ * copies the passed edges to its own data structure,
+ * i.e. it doesn't keep references to Edge objects, target vertex ids or edge
+ * values passed to add() or initialize().
* This makes it possible to reuse edge objects passed to the data
* structure, to minimize object instantiation (see for example
* EdgeStore#addPartitionEdges()).
@@ -137,8 +137,8 @@ public class GiraphConfiguration extends Configuration
* @return True iff we can reuse the edge objects
*/
public boolean reuseEdgeObjects() {
- return ReuseObjectsVertexEdges.class.isAssignableFrom(
- getVertexEdgesClass());
+ return ReuseObjectsOutEdges.class.isAssignableFrom(
+ getOutEdgesClass());
}
/**
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConstants.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConstants.java b/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConstants.java
index a55a2a2..6a5949e 100644
--- a/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConstants.java
+++ b/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConstants.java
@@ -21,7 +21,7 @@ import org.apache.giraph.aggregators.AggregatorWriter;
import org.apache.giraph.aggregators.TextAggregatorWriter;
import org.apache.giraph.combiner.Combiner;
import org.apache.giraph.edge.ByteArrayEdges;
-import org.apache.giraph.edge.VertexEdges;
+import org.apache.giraph.edge.OutEdges;
import org.apache.giraph.graph.DefaultVertexResolver;
import org.apache.giraph.graph.DefaultVertexValueFactory;
import org.apache.giraph.graph.Vertex;
@@ -66,13 +66,13 @@ public interface GiraphConstants {
ClassConfOption.create("giraph.vertexValueFactoryClass",
DefaultVertexValueFactory.class, VertexValueFactory.class);
/** Vertex edges class - optional */
- ClassConfOption<VertexEdges> VERTEX_EDGES_CLASS =
- ClassConfOption.create("giraph.vertexEdgesClass", ByteArrayEdges.class,
- VertexEdges.class);
+ ClassConfOption<OutEdges> VERTEX_EDGES_CLASS =
+ ClassConfOption.create("giraph.outEdgesClass", ByteArrayEdges.class,
+ OutEdges.class);
/** Vertex edges class to be used during edge input only - optional */
- ClassConfOption<VertexEdges> INPUT_VERTEX_EDGES_CLASS =
- ClassConfOption.create("giraph.inputVertexEdgesClass",
- ByteArrayEdges.class, VertexEdges.class);
+ ClassConfOption<OutEdges> INPUT_VERTEX_EDGES_CLASS =
+ ClassConfOption.create("giraph.inputOutEdgesClass",
+ ByteArrayEdges.class, OutEdges.class);
/** Class for Master - optional */
ClassConfOption<MasterCompute> MASTER_COMPUTE_CLASS =
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/conf/ImmutableClassesGiraphConfiguration.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/conf/ImmutableClassesGiraphConfiguration.java b/giraph-core/src/main/java/org/apache/giraph/conf/ImmutableClassesGiraphConfiguration.java
index dc3a26f..8dfe546 100644
--- a/giraph-core/src/main/java/org/apache/giraph/conf/ImmutableClassesGiraphConfiguration.java
+++ b/giraph-core/src/main/java/org/apache/giraph/conf/ImmutableClassesGiraphConfiguration.java
@@ -22,8 +22,8 @@ import org.apache.giraph.aggregators.AggregatorWriter;
import org.apache.giraph.combiner.Combiner;
import org.apache.giraph.edge.Edge;
import org.apache.giraph.edge.EdgeFactory;
+import org.apache.giraph.edge.OutEdges;
import org.apache.giraph.edge.ReusableEdge;
-import org.apache.giraph.edge.VertexEdges;
import org.apache.giraph.graph.GraphState;
import org.apache.giraph.graph.Vertex;
import org.apache.giraph.graph.VertexResolver;
@@ -588,96 +588,99 @@ public class ImmutableClassesGiraphConfiguration<I extends WritableComparable,
}
@Override
- public Class<? extends VertexEdges<I, E>> getVertexEdgesClass() {
- return classes.getVertexEdgesClass();
+ public Class<? extends OutEdges<I, E>> getOutEdgesClass() {
+ return classes.getOutEdgesClass();
}
/**
- * Get the user's subclassed {@link VertexEdges} used for input
+ * Get the user's subclassed {@link org.apache.giraph.edge.OutEdges} used for
+ * input
*
* @return User's input vertex edges class
*/
- public Class<? extends VertexEdges<I, E>> getInputVertexEdgesClass() {
- return classes.getInputVertexEdgesClass();
+ public Class<? extends OutEdges<I, E>> getInputOutEdgesClass() {
+ return classes.getInputOutEdgesClass();
}
/**
- * Check whether the user has specified a different {@link VertexEdges}
- * class to be used during edge-based input.
+ * Check whether the user has specified a different
+ * {@link org.apache.giraph.edge.OutEdges} class to be used during
+ * edge-based input.
*
* @return True iff there is a special edges class for input
*/
- public boolean useInputVertexEdges() {
- return classes.getInputVertexEdgesClass() != classes.getVertexEdgesClass();
+ public boolean useInputOutEdges() {
+ return classes.getInputOutEdgesClass() != classes.getOutEdgesClass();
}
/**
- * Create a user {@link VertexEdges}
+ * Create a user {@link org.apache.giraph.edge.OutEdges}
*
- * @return Instantiated user VertexEdges
+ * @return Instantiated user OutEdges
*/
- public VertexEdges<I, E> createVertexEdges() {
- return ReflectionUtils.newInstance(getVertexEdgesClass(), this);
+ public OutEdges<I, E> createOutEdges() {
+ return ReflectionUtils.newInstance(getOutEdgesClass(), this);
}
/**
- * Create a {@link VertexEdges} instance and initialize it with the default
- * capacity.
+ * Create a {@link org.apache.giraph.edge.OutEdges} instance and initialize
+ * it with the default capacity.
*
- * @return Instantiated VertexEdges
+ * @return Instantiated OutEdges
*/
- public VertexEdges<I, E> createAndInitializeVertexEdges() {
- VertexEdges<I, E> vertexEdges = createVertexEdges();
- vertexEdges.initialize();
- return vertexEdges;
+ public OutEdges<I, E> createAndInitializeOutEdges() {
+ OutEdges<I, E> outEdges = createOutEdges();
+ outEdges.initialize();
+ return outEdges;
}
/**
- * Create a {@link VertexEdges} instance and initialize it with the given
- * capacity (the number of edges that will be added).
+ * Create a {@link org.apache.giraph.edge.OutEdges} instance and initialize
+ * it with the given capacity (the number of edges that will be added).
*
* @param capacity Number of edges that will be added
- * @return Instantiated VertexEdges
+ * @return Instantiated OutEdges
*/
- public VertexEdges<I, E> createAndInitializeVertexEdges(int capacity) {
- VertexEdges<I, E> vertexEdges = createVertexEdges();
- vertexEdges.initialize(capacity);
- return vertexEdges;
+ public OutEdges<I, E> createAndInitializeOutEdges(int capacity) {
+ OutEdges<I, E> outEdges = createOutEdges();
+ outEdges.initialize(capacity);
+ return outEdges;
}
/**
- * Create a {@link VertexEdges} instance and initialize it with the given
- * iterable of edges.
+ * Create a {@link org.apache.giraph.edge.OutEdges} instance and initialize
+ * it with the given iterable of edges.
*
* @param edges Iterable of edges to add
- * @return Instantiated VertexEdges
+ * @return Instantiated OutEdges
*/
- public VertexEdges<I, E> createAndInitializeVertexEdges(
+ public OutEdges<I, E> createAndInitializeOutEdges(
Iterable<Edge<I, E>> edges) {
- VertexEdges<I, E> vertexEdges = createVertexEdges();
- vertexEdges.initialize(edges);
- return vertexEdges;
+ OutEdges<I, E> outEdges = createOutEdges();
+ outEdges.initialize(edges);
+ return outEdges;
}
/**
- * Create a user {@link VertexEdges} used during edge-based input
+ * Create a user {@link org.apache.giraph.edge.OutEdges} used during
+ * edge-based input
*
- * @return Instantiated user input VertexEdges
+ * @return Instantiated user input OutEdges
*/
- public VertexEdges<I, E> createInputVertexEdges() {
- return ReflectionUtils.newInstance(getInputVertexEdgesClass(), this);
+ public OutEdges<I, E> createInputOutEdges() {
+ return ReflectionUtils.newInstance(getInputOutEdgesClass(), this);
}
/**
- * Create an input {@link VertexEdges} instance and initialize it with the
- * default capacity.
+ * Create an input {@link org.apache.giraph.edge.OutEdges} instance and
+ * initialize it with the default capacity.
*
- * @return Instantiated input VertexEdges
+ * @return Instantiated input OutEdges
*/
- public VertexEdges<I, E> createAndInitializeInputVertexEdges() {
- VertexEdges<I, E> vertexEdges = createInputVertexEdges();
- vertexEdges.initialize();
- return vertexEdges;
+ public OutEdges<I, E> createAndInitializeInputOutEdges() {
+ OutEdges<I, E> outEdges = createInputOutEdges();
+ outEdges.initialize();
+ return outEdges;
}
/**
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/ArrayListEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/ArrayListEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/ArrayListEdges.java
index dda7568..4eb3378 100644
--- a/giraph-core/src/main/java/org/apache/giraph/edge/ArrayListEdges.java
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/ArrayListEdges.java
@@ -30,15 +30,15 @@ import java.util.ArrayList;
import java.util.Iterator;
/**
- * {@link VertexEdges} implementation backed by an {@link ArrayList}.
+ * {@link OutEdges} implementation backed by an {@link ArrayList}.
* Parallel edges are allowed.
*
* @param <I> Vertex id
* @param <E> Edge value
*/
public class ArrayListEdges<I extends WritableComparable, E extends Writable>
- extends ConfigurableVertexEdges<I, E>
- implements MutableVertexEdges<I, E> {
+ extends ConfigurableOutEdges<I, E>
+ implements MutableOutEdges<I, E> {
/** List of edges. */
private ArrayList<Edge<I, E>> edgeList;
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/ByteArrayEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/ByteArrayEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/ByteArrayEdges.java
index 16748ef..b9d1f6c 100644
--- a/giraph-core/src/main/java/org/apache/giraph/edge/ByteArrayEdges.java
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/ByteArrayEdges.java
@@ -33,7 +33,7 @@ import java.util.LinkedList;
import java.util.List;
/**
- * {@link VertexEdges} implementation backed by a byte array.
+ * {@link OutEdges} implementation backed by a byte array.
* Parallel edges are allowed.
* Note: this implementation is optimized for space usage,
* but edge removals are expensive.
@@ -42,8 +42,8 @@ import java.util.List;
* @param <E> Edge value
*/
public class ByteArrayEdges<I extends WritableComparable, E extends Writable>
- extends ConfigurableVertexEdges<I, E>
- implements ReuseObjectsVertexEdges<I, E> {
+ extends ConfigurableOutEdges<I, E>
+ implements ReuseObjectsOutEdges<I, E> {
/** Serialized edges. */
private byte[] serializedEdges;
/** Number of bytes used in serializedEdges. */
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/ConfigurableOutEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/ConfigurableOutEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/ConfigurableOutEdges.java
new file mode 100644
index 0000000..631b209
--- /dev/null
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/ConfigurableOutEdges.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.giraph.edge;
+
+import org.apache.giraph.conf.DefaultImmutableClassesGiraphConfigurable;
+import org.apache.hadoop.io.Writable;
+import org.apache.hadoop.io.WritableComparable;
+
+/**
+ * Common base class for {@link OutEdges} implementations that require a
+ * configuration.
+ *
+ * @param <I> Vertex id
+ * @param <E> Edge value
+ */
+public abstract class ConfigurableOutEdges<I extends WritableComparable,
+ E extends Writable>
+ extends DefaultImmutableClassesGiraphConfigurable<I, Writable, E,
+ Writable> implements OutEdges<I, E> {
+}
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/ConfigurableVertexEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/ConfigurableVertexEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/ConfigurableVertexEdges.java
deleted file mode 100644
index f05e0d7..0000000
--- a/giraph-core/src/main/java/org/apache/giraph/edge/ConfigurableVertexEdges.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.giraph.edge;
-
-import org.apache.giraph.conf.DefaultImmutableClassesGiraphConfigurable;
-import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.io.WritableComparable;
-
-/**
- * Common base class for {@link VertexEdges} implementations that require a
- * configuration.
- *
- * @param <I> Vertex id
- * @param <E> Edge value
- */
-public abstract class ConfigurableVertexEdges<I extends WritableComparable,
- E extends Writable>
- extends DefaultImmutableClassesGiraphConfigurable<I, Writable, E,
- Writable> implements VertexEdges<I, E> {
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/EdgeStore.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/EdgeStore.java b/giraph-core/src/main/java/org/apache/giraph/edge/EdgeStore.java
index e8cb620..81044bd 100644
--- a/giraph-core/src/main/java/org/apache/giraph/edge/EdgeStore.java
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/EdgeStore.java
@@ -55,17 +55,17 @@ public class EdgeStore<I extends WritableComparable,
private Progressable progressable;
/** Map used to temporarily store incoming edges. */
private ConcurrentMap<Integer,
- ConcurrentMap<I, VertexEdges<I, E>>> transientEdges;
+ ConcurrentMap<I, OutEdges<I, E>>> transientEdges;
/**
- * Whether the chosen {@link VertexEdges} implementation allows for Edge
+ * Whether the chosen {@link OutEdges} implementation allows for Edge
* reuse.
*/
private boolean reuseEdgeObjects;
/**
- * Whether the {@link VertexEdges} class used during input is different
+ * Whether the {@link OutEdges} class used during input is different
* from the one used during computation.
*/
- private boolean useInputVertexEdges;
+ private boolean useInputOutEdges;
/**
* Constructor.
@@ -84,7 +84,7 @@ public class EdgeStore<I extends WritableComparable,
transientEdges = new MapMaker().concurrencyLevel(
configuration.getNettyServerExecutionConcurrency()).makeMap();
reuseEdgeObjects = configuration.reuseEdgeObjects();
- useInputVertexEdges = configuration.useInputVertexEdges();
+ useInputOutEdges = configuration.useInputOutEdges();
}
/**
@@ -96,10 +96,10 @@ public class EdgeStore<I extends WritableComparable,
*/
public void addPartitionEdges(
int partitionId, ByteArrayVertexIdEdges<I, E> edges) {
- ConcurrentMap<I, VertexEdges<I, E>> partitionEdges =
+ ConcurrentMap<I, OutEdges<I, E>> partitionEdges =
transientEdges.get(partitionId);
if (partitionEdges == null) {
- ConcurrentMap<I, VertexEdges<I, E>> newPartitionEdges =
+ ConcurrentMap<I, OutEdges<I, E>> newPartitionEdges =
new MapMaker().concurrencyLevel(
configuration.getNettyServerExecutionConcurrency()).makeMap();
partitionEdges = transientEdges.putIfAbsent(partitionId,
@@ -116,38 +116,38 @@ public class EdgeStore<I extends WritableComparable,
Edge<I, E> edge = reuseEdgeObjects ?
vertexIdEdgeIterator.getCurrentEdge() :
vertexIdEdgeIterator.releaseCurrentEdge();
- VertexEdges<I, E> vertexEdges = partitionEdges.get(vertexId);
- if (vertexEdges == null) {
- VertexEdges<I, E> newVertexEdges =
- configuration.createAndInitializeInputVertexEdges();
- vertexEdges = partitionEdges.putIfAbsent(vertexId, newVertexEdges);
- if (vertexEdges == null) {
- vertexEdges = newVertexEdges;
+ OutEdges<I, E> outEdges = partitionEdges.get(vertexId);
+ if (outEdges == null) {
+ OutEdges<I, E> newOutEdges =
+ configuration.createAndInitializeInputOutEdges();
+ outEdges = partitionEdges.putIfAbsent(vertexId, newOutEdges);
+ if (outEdges == null) {
+ outEdges = newOutEdges;
// Since we had to use the vertex id as a new key in the map,
// we need to release the object.
vertexIdEdgeIterator.releaseCurrentVertexId();
}
}
- synchronized (vertexEdges) {
- vertexEdges.add(edge);
+ synchronized (outEdges) {
+ outEdges.add(edge);
}
}
}
/**
- * Convert the input edges to the {@link VertexEdges} data structure used
+ * Convert the input edges to the {@link OutEdges} data structure used
* for computation (if different).
*
* @param inputEdges Input edges
* @return Compute edges
*/
- private VertexEdges<I, E> convertInputToComputeEdges(
- VertexEdges<I, E> inputEdges) {
- if (!useInputVertexEdges) {
+ private OutEdges<I, E> convertInputToComputeEdges(
+ OutEdges<I, E> inputEdges) {
+ if (!useInputOutEdges) {
return inputEdges;
} else {
- VertexEdges<I, E> computeEdges =
- configuration.createAndInitializeVertexEdges(inputEdges.size());
+ OutEdges<I, E> computeEdges =
+ configuration.createAndInitializeOutEdges(inputEdges.size());
for (Edge<I, E> edge : inputEdges) {
computeEdges.add(edge);
}
@@ -186,10 +186,10 @@ public class EdgeStore<I extends WritableComparable,
while ((partitionId = partitionIdQueue.poll()) != null) {
Partition<I, V, E, M> partition =
service.getPartitionStore().getPartition(partitionId);
- ConcurrentMap<I, VertexEdges<I, E>> partitionEdges =
+ ConcurrentMap<I, OutEdges<I, E>> partitionEdges =
transientEdges.remove(partitionId);
for (I vertexId : partitionEdges.keySet()) {
- VertexEdges<I, E> vertexEdges = convertInputToComputeEdges(
+ OutEdges<I, E> outEdges = convertInputToComputeEdges(
partitionEdges.remove(vertexId));
Vertex<I, V, E, M> vertex = partition.getVertex(vertexId);
// If the source vertex doesn't exist, create it. Otherwise,
@@ -197,10 +197,10 @@ public class EdgeStore<I extends WritableComparable,
if (vertex == null) {
vertex = configuration.createVertex();
vertex.initialize(vertexId, configuration.createVertexValue(),
- vertexEdges);
+ outEdges);
partition.putVertex(vertex);
} else {
- vertex.setEdges(vertexEdges);
+ vertex.setEdges(outEdges);
// Some Partition implementations (e.g. ByteArrayPartition)
// require us to put back the vertex after modifying it.
partition.saveVertex(vertex);
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/HashMapEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/HashMapEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/HashMapEdges.java
index 9fa7b64..fc23cf0 100644
--- a/giraph-core/src/main/java/org/apache/giraph/edge/HashMapEdges.java
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/HashMapEdges.java
@@ -31,7 +31,7 @@ import java.util.Iterator;
import java.util.Map;
/**
- * {@link VertexEdges} implementation backed by a {@link HashMap}.
+ * {@link OutEdges} implementation backed by a {@link HashMap}.
* Parallel edges are not allowed.
* Note: this implementation is optimized for fast random access and mutations,
* but uses more space.
@@ -40,9 +40,9 @@ import java.util.Map;
* @param <E> Edge value
*/
public class HashMapEdges<I extends WritableComparable, E extends Writable>
- extends ConfigurableVertexEdges<I, E>
- implements StrictRandomAccessVertexEdges<I, E>,
- MutableVertexEdges<I, E> {
+ extends ConfigurableOutEdges<I, E>
+ implements StrictRandomAccessOutEdges<I, E>,
+ MutableOutEdges<I, E> {
/** Map from target vertex id to edge value. */
private HashMap<I, E> edgeMap;
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/HashMultimapEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/HashMultimapEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/HashMultimapEdges.java
index 123d49f..abe6151 100644
--- a/giraph-core/src/main/java/org/apache/giraph/edge/HashMultimapEdges.java
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/HashMultimapEdges.java
@@ -31,7 +31,7 @@ import java.util.Iterator;
import java.util.Map;
/**
- * {@link VertexEdges} implementation backed by an {@link ArrayListMultimap}.
+ * {@link OutEdges} implementation backed by an {@link ArrayListMultimap}.
* Parallel edges are allowed.
* Note: this implementation is optimized for fast mutations,
* but uses more space.
@@ -40,8 +40,8 @@ import java.util.Map;
* @param <E> Edge value
*/
public class HashMultimapEdges<I extends WritableComparable, E extends Writable>
- extends ConfigurableVertexEdges<I, E>
- implements MultiRandomAccessVertexEdges<I, E> {
+ extends ConfigurableOutEdges<I, E>
+ implements MultiRandomAccessOutEdges<I, E> {
/** Multimap from target vertex id to edge values. */
private ArrayListMultimap<I, E> edgeMultimap;
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/IntNullArrayEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/IntNullArrayEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/IntNullArrayEdges.java
index 2363caf..9867771 100644
--- a/giraph-core/src/main/java/org/apache/giraph/edge/IntNullArrayEdges.java
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/IntNullArrayEdges.java
@@ -33,14 +33,14 @@ import java.util.Collection;
import java.util.Iterator;
/**
- * Implementation of {@link VertexEdges} with int ids and null edge
+ * Implementation of {@link OutEdges} with int ids and null edge
* values, backed by dynamic primitive array.
* Parallel edges are allowed.
* Note: this implementation is optimized for space usage,
* but edge removals are expensive.
*/
public class IntNullArrayEdges
- implements ReuseObjectsVertexEdges<IntWritable, NullWritable> {
+ implements ReuseObjectsOutEdges<IntWritable, NullWritable> {
/** Array of target vertex ids */
private IntArrayList neighbors;
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleArrayEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleArrayEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleArrayEdges.java
index 6ce85d5..45d182e 100644
--- a/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleArrayEdges.java
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleArrayEdges.java
@@ -33,15 +33,15 @@ import java.util.Collection;
import java.util.Iterator;
/**
- * Implementation of {@link VertexEdges} with long ids and double edge
+ * Implementation of {@link OutEdges} with long ids and double edge
* values, backed by dynamic primitive arrays.
* Parallel edges are allowed.
* Note: this implementation is optimized for space usage,
* but edge removals are expensive.
*/
public class LongDoubleArrayEdges
- implements ReuseObjectsVertexEdges<LongWritable, DoubleWritable>,
- MutableVertexEdges<LongWritable, DoubleWritable> {
+ implements ReuseObjectsOutEdges<LongWritable, DoubleWritable>,
+ MutableOutEdges<LongWritable, DoubleWritable> {
/** Array of target vertex ids. */
private LongArrayList neighbors;
/** Array of edge values. */
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleHashMapEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleHashMapEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleHashMapEdges.java
index 908ad25..c33200d 100644
--- a/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleHashMapEdges.java
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleHashMapEdges.java
@@ -32,7 +32,7 @@ import java.util.Collection;
import java.util.Iterator;
/**
- * {@link VertexEdges} implementation with long ids and double edge values,
+ * {@link OutEdges} implementation with long ids and double edge values,
* backed by a {@link Long2DoubleOpenHashMap}.
* Parallel edges are not allowed.
* Note: this implementation is optimized for fast random access and mutations,
@@ -40,9 +40,9 @@ import java.util.Iterator;
* {@link LongDoubleArrayEdges}.
*/
public class LongDoubleHashMapEdges
- implements StrictRandomAccessVertexEdges<LongWritable, DoubleWritable>,
- ReuseObjectsVertexEdges<LongWritable, DoubleWritable>,
- MutableVertexEdges<LongWritable, DoubleWritable> {
+ implements StrictRandomAccessOutEdges<LongWritable, DoubleWritable>,
+ ReuseObjectsOutEdges<LongWritable, DoubleWritable>,
+ MutableOutEdges<LongWritable, DoubleWritable> {
/** Hash map from target vertex id to edge value. */
private Long2DoubleOpenHashMap edgeMap;
/** Representative edge value object, used by getEdgeValue(). */
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/LongNullArrayEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/LongNullArrayEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/LongNullArrayEdges.java
index fee27f1..d753588 100644
--- a/giraph-core/src/main/java/org/apache/giraph/edge/LongNullArrayEdges.java
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/LongNullArrayEdges.java
@@ -30,15 +30,15 @@ import java.util.Collection;
import java.util.Iterator;
/**
- * Implementation of {@link VertexEdges} with long ids and null edge
+ * Implementation of {@link OutEdges} with long ids and null edge
* values, backed by a dynamic primitive array.
* Parallel edges are allowed.
* Note: this implementation is optimized for space usage,
* but random access and edge removals are expensive.
*/
public class LongNullArrayEdges
- implements ReuseObjectsVertexEdges<LongWritable, NullWritable>,
- MutableVertexEdges<LongWritable, NullWritable> {
+ implements ReuseObjectsOutEdges<LongWritable, NullWritable>,
+ MutableOutEdges<LongWritable, NullWritable> {
/** Array of target vertex ids. */
private LongArrayList neighbors;
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/LongNullHashSetEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/LongNullHashSetEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/LongNullHashSetEdges.java
index f374e36..ef0302c 100644
--- a/giraph-core/src/main/java/org/apache/giraph/edge/LongNullHashSetEdges.java
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/LongNullHashSetEdges.java
@@ -30,7 +30,7 @@ import java.util.Collection;
import java.util.Iterator;
/**
- * {@link VertexEdges} implementation with long ids and null edge values,
+ * {@link OutEdges} implementation with long ids and null edge values,
* backed by a {@link LongOpenHashSet}.
* Parallel edges are not allowed.
* Note: this implementation is optimized for fast random access and mutations,
@@ -38,8 +38,8 @@ import java.util.Iterator;
* {@link LongNullArrayEdges}.
*/
public class LongNullHashSetEdges
- implements ReuseObjectsVertexEdges<LongWritable, NullWritable>,
- MutableVertexEdges<LongWritable, NullWritable> {
+ implements ReuseObjectsOutEdges<LongWritable, NullWritable>,
+ MutableOutEdges<LongWritable, NullWritable> {
/** Hash set of target vertex ids. */
private LongOpenHashSet neighbors;
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/MultiRandomAccessOutEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/MultiRandomAccessOutEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/MultiRandomAccessOutEdges.java
new file mode 100644
index 0000000..e3fc16b
--- /dev/null
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/MultiRandomAccessOutEdges.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.giraph.edge;
+
+import org.apache.hadoop.io.Writable;
+import org.apache.hadoop.io.WritableComparable;
+
+/**
+ * Interface for {@link OutEdges} implementations that provide efficient
+ * random access to the edges given the target vertex id.
+ * This version is for multigraphs (i.e. there can be parallel edges).
+ *
+ * @param <I> Vertex id
+ * @param <E> Edge value
+ */
+public interface MultiRandomAccessOutEdges<I extends WritableComparable,
+ E extends Writable> extends OutEdges<I, E> {
+ /**
+ * Return an iterable over the edge values for a given target vertex id.
+ *
+ * @param targetVertexId Target vertex id
+ * @return Iterable of edge values
+ */
+ Iterable<E> getAllEdgeValues(I targetVertexId);
+}
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/MultiRandomAccessVertexEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/MultiRandomAccessVertexEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/MultiRandomAccessVertexEdges.java
deleted file mode 100644
index 9f8658e..0000000
--- a/giraph-core/src/main/java/org/apache/giraph/edge/MultiRandomAccessVertexEdges.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.giraph.edge;
-
-import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.io.WritableComparable;
-
-/**
- * Interface for {@link VertexEdges} implementations that provide efficient
- * random access to the edges given the target vertex id.
- * This version is for multigraphs (i.e. there can be parallel edges).
- *
- * @param <I> Vertex id
- * @param <E> Edge value
- */
-public interface MultiRandomAccessVertexEdges<I extends WritableComparable,
- E extends Writable> extends VertexEdges<I, E> {
- /**
- * Return an iterable over the edge values for a given target vertex id.
- *
- * @param targetVertexId Target vertex id
- * @return Iterable of edge values
- */
- Iterable<E> getAllEdgeValues(I targetVertexId);
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/MutableEdgesIterable.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/MutableEdgesIterable.java b/giraph-core/src/main/java/org/apache/giraph/edge/MutableEdgesIterable.java
index 9dab09c..82486f4 100644
--- a/giraph-core/src/main/java/org/apache/giraph/edge/MutableEdgesIterable.java
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/MutableEdgesIterable.java
@@ -26,7 +26,7 @@ import java.util.Iterator;
/**
* Helper class to provide a mutable iterable over the edges when the chosen
- * {@link VertexEdges} doesn't offer a specialized one.
+ * {@link OutEdges} doesn't offer a specialized one.
*
* @param <I> Vertex id
* @param <E> Edge value
@@ -48,7 +48,7 @@ public class MutableEdgesIterable<I extends WritableComparable,
@Override
public Iterator<MutableEdge<I, E>> iterator() {
final MutableEdgesWrapper<I, E> mutableEdgesWrapper =
- MutableEdgesWrapper.wrap((VertexEdges<I, E>) vertex.getEdges(),
+ MutableEdgesWrapper.wrap((OutEdges<I, E>) vertex.getEdges(),
vertex.getConf());
vertex.setEdges(mutableEdgesWrapper);
@@ -57,7 +57,7 @@ public class MutableEdgesIterable<I extends WritableComparable,
private Iterator<Edge<I, E>> oldEdgesIterator =
mutableEdgesWrapper.getOldEdgesIterator();
/** New edges data structure. */
- private VertexEdges<I, E> newEdges = mutableEdgesWrapper.getNewEdges();
+ private OutEdges<I, E> newEdges = mutableEdgesWrapper.getNewEdges();
@Override
public boolean hasNext() {
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/MutableEdgesWrapper.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/MutableEdgesWrapper.java b/giraph-core/src/main/java/org/apache/giraph/edge/MutableEdgesWrapper.java
index 5b20bf7..cd845d0 100644
--- a/giraph-core/src/main/java/org/apache/giraph/edge/MutableEdgesWrapper.java
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/MutableEdgesWrapper.java
@@ -31,8 +31,8 @@ import java.util.Iterator;
* Helper class that wraps the current out-edges and inserts them into a new
* data structure as they are iterated over.
* Used by Vertex to provide a mutable iterator when the chosen
- * {@link VertexEdges} doesn't offer a specialized one.
- * The edges are "unwrapped" back to the chosen {@link VertexEdges} data
+ * {@link OutEdges} doesn't offer a specialized one.
+ * The edges are "unwrapped" back to the chosen {@link OutEdges} data
* structure as soon as possible: either when the iterator is exhausted,
* or after compute() if iteration has been terminated early.
*
@@ -40,9 +40,9 @@ import java.util.Iterator;
* @param <E> Edge value
*/
public class MutableEdgesWrapper<I extends WritableComparable,
- E extends Writable> implements VertexEdges<I, E> {
+ E extends Writable> implements OutEdges<I, E> {
/** New edges data structure (initially empty). */
- private final VertexEdges<I, E> newEdges;
+ private final OutEdges<I, E> newEdges;
/** Iterator over the old edges. */
private final Iterator<Edge<I, E>> oldEdgesIterator;
/** Last edge that was returned during iteration. */
@@ -55,8 +55,8 @@ public class MutableEdgesWrapper<I extends WritableComparable,
* @param oldEdges Current out-edges
* @param newEdges New (empty) edges data structure
*/
- private MutableEdgesWrapper(VertexEdges<I, E> oldEdges,
- VertexEdges<I, E> newEdges) {
+ private MutableEdgesWrapper(OutEdges<I, E> oldEdges,
+ OutEdges<I, E> newEdges) {
oldEdgesIterator = oldEdges.iterator();
this.newEdges = newEdges;
}
@@ -72,19 +72,19 @@ public class MutableEdgesWrapper<I extends WritableComparable,
*/
public static <I extends WritableComparable, E extends Writable>
MutableEdgesWrapper<I, E> wrap(
- VertexEdges<I, E> edges,
+ OutEdges<I, E> edges,
ImmutableClassesGiraphConfiguration<I, ?, E, ?> conf) {
MutableEdgesWrapper<I, E> wrapper = new MutableEdgesWrapper<I, E>(
- edges, conf.createAndInitializeVertexEdges(edges.size()));
+ edges, conf.createAndInitializeOutEdges(edges.size()));
return wrapper;
}
/**
* Moves all the remaining edges to the new data structure, and returns it.
*
- * @return The new {@link VertexEdges} data structure.
+ * @return The new {@link OutEdges} data structure.
*/
- public VertexEdges<I, E> unwrap() {
+ public OutEdges<I, E> unwrap() {
if (currentEdge != null) {
newEdges.add(currentEdge);
currentEdge = null;
@@ -96,11 +96,11 @@ public class MutableEdgesWrapper<I extends WritableComparable,
}
/**
- * Get the new {@link VertexEdges} data structure.
+ * Get the new {@link OutEdges} data structure.
*
* @return New edges
*/
- public VertexEdges<I, E> getNewEdges() {
+ public OutEdges<I, E> getNewEdges() {
return newEdges;
}
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/MutableOutEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/MutableOutEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/MutableOutEdges.java
new file mode 100644
index 0000000..0dcc018
--- /dev/null
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/MutableOutEdges.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.giraph.edge;
+
+import org.apache.hadoop.io.Writable;
+import org.apache.hadoop.io.WritableComparable;
+
+import java.util.Iterator;
+
+/**
+ * Interface for {@link OutEdges} implementations that have an optimized
+ * mutable edge iterator.
+ *
+ * @param <I> Vertex id
+ * @param <E> Edge value
+ */
+public interface MutableOutEdges<I extends WritableComparable,
+ E extends Writable> extends OutEdges<I, E> {
+ /**
+ * Returns an iterator over edges that can be modified in-place,
+ * either by changing the current edge value or by removing the current edge.
+ *
+ * @return A mutable edge iterator
+ */
+ Iterator<MutableEdge<I, E>> mutableIterator();
+}
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/MutableVertexEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/MutableVertexEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/MutableVertexEdges.java
deleted file mode 100644
index 503de92..0000000
--- a/giraph-core/src/main/java/org/apache/giraph/edge/MutableVertexEdges.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.giraph.edge;
-
-import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.io.WritableComparable;
-
-import java.util.Iterator;
-
-/**
- * Interface for {@link VertexEdges} implementations that have an optimized
- * mutable edge iterator.
- *
- * @param <I> Vertex id
- * @param <E> Edge value
- */
-public interface MutableVertexEdges<I extends WritableComparable,
- E extends Writable> extends VertexEdges<I, E> {
- /**
- * Returns an iterator over edges that can be modified in-place,
- * either by changing the current edge value or by removing the current edge.
- *
- * @return A mutable edge iterator
- */
- Iterator<MutableEdge<I, E>> mutableIterator();
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/OutEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/OutEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/OutEdges.java
new file mode 100644
index 0000000..34dc5cb
--- /dev/null
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/OutEdges.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.giraph.edge;
+
+import org.apache.hadoop.io.Writable;
+import org.apache.hadoop.io.WritableComparable;
+
+/**
+ * Interface for data structures that store out-edges for a vertex.
+ *
+ * @param <I> Vertex id
+ * @param <E> Edge value
+ */
+public interface OutEdges<I extends WritableComparable, E extends Writable>
+ extends Iterable<Edge<I, E>>, Writable {
+ /**
+ * Initialize the data structure and set the edges from an iterable.
+ * This method (or one of the two alternatives) must be called
+ * after instantiation, unless readFields() is called.
+ * Note: whether parallel edges are allowed or not depends on the
+ * implementation.
+ *
+ * @param edges Iterable of edges
+ */
+ void initialize(Iterable<Edge<I, E>> edges);
+
+ /**
+ * Initialize the data structure with the specified initial capacity.
+ * This method (or one of the two alternatives) must be called
+ * after instantiation, unless readFields() is called.
+ *
+ * @param capacity Initial capacity
+ */
+ void initialize(int capacity);
+
+ /**
+ * Initialize the data structure with the default initial capacity.
+ * This method (or one of the two alternatives) must be called
+ * after instantiation, unless readFields() is called.
+ *
+ */
+ void initialize();
+
+ /**
+ * Add an edge.
+ * Note: whether parallel edges are allowed or not depends on the
+ * implementation.
+ *
+ * @param edge Edge to add
+ */
+ void add(Edge<I, E> edge);
+
+ /**
+ * Remove all edges to the given target vertex.
+ * Note: the implementation will vary depending on whether parallel edges
+ * are allowed or not.
+ *
+ * @param targetVertexId Target vertex id
+ */
+ void remove(I targetVertexId);
+
+ /**
+ * Return the number of edges.
+ *
+ * @return Number of edges
+ */
+ int size();
+}
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/ReuseObjectsOutEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/ReuseObjectsOutEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/ReuseObjectsOutEdges.java
new file mode 100644
index 0000000..27cf9ca
--- /dev/null
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/ReuseObjectsOutEdges.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.giraph.edge;
+
+import org.apache.hadoop.io.Writable;
+import org.apache.hadoop.io.WritableComparable;
+
+/**
+ * Empty interface to characterize {@link OutEdges} implementations that
+ * don't keep references to the Edge (or id and value) objects they are passed.
+ * The Giraph infrastructure can exploit this characteristic by reusing Edge
+ * objects.
+ *
+ * @param <I> Vertex id
+ * @param <E> Edge value
+ */
+public interface ReuseObjectsOutEdges<I extends WritableComparable,
+ E extends Writable> extends OutEdges<I, E> { }
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/ReuseObjectsVertexEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/ReuseObjectsVertexEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/ReuseObjectsVertexEdges.java
deleted file mode 100644
index 7704baf..0000000
--- a/giraph-core/src/main/java/org/apache/giraph/edge/ReuseObjectsVertexEdges.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.giraph.edge;
-
-import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.io.WritableComparable;
-
-/**
- * Empty interface to characterize {@link VertexEdges} implementations that
- * don't keep references to the Edge (or id and value) objects they are passed.
- * The Giraph infrastructure can exploit this characteristic by reusing Edge
- * objects.
- *
- * @param <I> Vertex id
- * @param <E> Edge value
- */
-public interface ReuseObjectsVertexEdges<I extends WritableComparable,
- E extends Writable> extends VertexEdges<I, E> { }
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/StrictRandomAccessOutEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/StrictRandomAccessOutEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/StrictRandomAccessOutEdges.java
new file mode 100644
index 0000000..800f45b
--- /dev/null
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/StrictRandomAccessOutEdges.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.giraph.edge;
+
+import org.apache.hadoop.io.Writable;
+import org.apache.hadoop.io.WritableComparable;
+
+/**
+ * Interface for {@link OutEdges} implementations that provide efficient
+ * random access to the edges given the target vertex id.
+ * This version is for strict graphs (i.e. assumes no parallel edges).
+ *
+ * @param <I> Vertex id
+ * @param <E> Edge value
+ */
+public interface StrictRandomAccessOutEdges<I extends WritableComparable,
+ E extends Writable> extends OutEdges<I, E> {
+ /**
+ * Return the edge value for the given target vertex id (or null if there
+ * is no edge pointing to it).
+ *
+ * @param targetVertexId Target vertex id
+ * @return Edge value
+ */
+ E getEdgeValue(I targetVertexId);
+
+ /**
+ * Set the edge value for the given target vertex id (if an edge to that
+ * vertex exists).
+ *
+ * @param targetVertexId Target vertex id
+ * @param edgeValue Edge value
+ */
+ void setEdgeValue(I targetVertexId, E edgeValue);
+}
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/StrictRandomAccessVertexEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/StrictRandomAccessVertexEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/StrictRandomAccessVertexEdges.java
deleted file mode 100644
index 5fdc2d2..0000000
--- a/giraph-core/src/main/java/org/apache/giraph/edge/StrictRandomAccessVertexEdges.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.giraph.edge;
-
-import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.io.WritableComparable;
-
-/**
- * Interface for {@link VertexEdges} implementations that provide efficient
- * random access to the edges given the target vertex id.
- * This version is for strict graphs (i.e. assumes no parallel edges).
- *
- * @param <I> Vertex id
- * @param <E> Edge value
- */
-public interface StrictRandomAccessVertexEdges<I extends WritableComparable,
- E extends Writable> extends VertexEdges<I, E> {
- /**
- * Return the edge value for the given target vertex id (or null if there
- * is no edge pointing to it).
- *
- * @param targetVertexId Target vertex id
- * @return Edge value
- */
- E getEdgeValue(I targetVertexId);
-
- /**
- * Set the edge value for the given target vertex id (if an edge to that
- * vertex exists).
- *
- * @param targetVertexId Target vertex id
- * @param edgeValue Edge value
- */
- void setEdgeValue(I targetVertexId, E edgeValue);
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/edge/VertexEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/VertexEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/VertexEdges.java
deleted file mode 100644
index bb885b7..0000000
--- a/giraph-core/src/main/java/org/apache/giraph/edge/VertexEdges.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.giraph.edge;
-
-import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.io.WritableComparable;
-
-/**
- * Interface for data structures that store out-edges for a vertex.
- *
- * @param <I> Vertex id
- * @param <E> Edge value
- */
-public interface VertexEdges<I extends WritableComparable, E extends Writable>
- extends Iterable<Edge<I, E>>, Writable {
- /**
- * Initialize the data structure and set the edges from an iterable.
- * This method (or one of the two alternatives) must be called
- * after instantiation, unless readFields() is called.
- * Note: whether parallel edges are allowed or not depends on the
- * implementation.
- *
- * @param edges Iterable of edges
- */
- void initialize(Iterable<Edge<I, E>> edges);
-
- /**
- * Initialize the data structure with the specified initial capacity.
- * This method (or one of the two alternatives) must be called
- * after instantiation, unless readFields() is called.
- *
- * @param capacity Initial capacity
- */
- void initialize(int capacity);
-
- /**
- * Initialize the data structure with the default initial capacity.
- * This method (or one of the two alternatives) must be called
- * after instantiation, unless readFields() is called.
- *
- */
- void initialize();
-
- /**
- * Add an edge.
- * Note: whether parallel edges are allowed or not depends on the
- * implementation.
- *
- * @param edge Edge to add
- */
- void add(Edge<I, E> edge);
-
- /**
- * Remove all edges to the given target vertex.
- * Note: the implementation will vary depending on whether parallel edges
- * are allowed or not.
- *
- * @param targetVertexId Target vertex id
- */
- void remove(I targetVertexId);
-
- /**
- * Return the number of edges.
- *
- * @return Number of edges
- */
- int size();
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/graph/Vertex.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/graph/Vertex.java b/giraph-core/src/main/java/org/apache/giraph/graph/Vertex.java
index ade25fe..61624e5 100644
--- a/giraph-core/src/main/java/org/apache/giraph/graph/Vertex.java
+++ b/giraph-core/src/main/java/org/apache/giraph/graph/Vertex.java
@@ -21,13 +21,13 @@ package org.apache.giraph.graph;
import com.google.common.collect.UnmodifiableIterator;
import org.apache.giraph.conf.DefaultImmutableClassesGiraphConfigurable;
import org.apache.giraph.edge.Edge;
-import org.apache.giraph.edge.MultiRandomAccessVertexEdges;
+import org.apache.giraph.edge.MultiRandomAccessOutEdges;
import org.apache.giraph.edge.MutableEdge;
import org.apache.giraph.edge.MutableEdgesIterable;
import org.apache.giraph.edge.MutableEdgesWrapper;
-import org.apache.giraph.edge.MutableVertexEdges;
-import org.apache.giraph.edge.StrictRandomAccessVertexEdges;
-import org.apache.giraph.edge.VertexEdges;
+import org.apache.giraph.edge.MutableOutEdges;
+import org.apache.giraph.edge.OutEdges;
+import org.apache.giraph.edge.StrictRandomAccessOutEdges;
import org.apache.giraph.partition.PartitionContext;
import org.apache.giraph.worker.WorkerAggregatorUsage;
import org.apache.giraph.worker.WorkerContext;
@@ -57,7 +57,7 @@ public abstract class Vertex<I extends WritableComparable,
/** Vertex value. */
private V value;
/** Outgoing edges. */
- private VertexEdges<I, E> edges;
+ private OutEdges<I, E> edges;
/** If true, do not do anymore computation on this vertex. */
private boolean halt;
/** Global graph state **/
@@ -89,7 +89,7 @@ public abstract class Vertex<I extends WritableComparable,
public void initialize(I id, V value) {
this.id = id;
this.value = value;
- this.edges = getConf().createAndInitializeVertexEdges(0);
+ this.edges = getConf().createAndInitializeOutEdges(0);
}
/**
@@ -98,13 +98,13 @@ public abstract class Vertex<I extends WritableComparable,
* @param edges Iterable of edges
*/
public void setEdges(Iterable<Edge<I, E>> edges) {
- // If the iterable is actually an instance of VertexEdges,
+ // If the iterable is actually an instance of OutEdges,
// we simply take the reference.
- // Otherwise, we initialize a new VertexEdges.
- if (edges instanceof VertexEdges) {
- this.edges = (VertexEdges<I, E>) edges;
+ // Otherwise, we initialize a new OutEdges.
+ if (edges instanceof OutEdges) {
+ this.edges = (OutEdges<I, E>) edges;
} else {
- this.edges = getConf().createAndInitializeVertexEdges(edges);
+ this.edges = getConf().createAndInitializeOutEdges(edges);
}
}
@@ -195,14 +195,14 @@ public abstract class Vertex<I extends WritableComparable,
* @return An iterable of mutable out-edges
*/
public Iterable<MutableEdge<I, E>> getMutableEdges() {
- // If the VertexEdges implementation has a specialized mutable iterator,
+ // If the OutEdges implementation has a specialized mutable iterator,
// we use that; otherwise, we build a new data structure as we iterate
// over the current edges.
- if (edges instanceof MutableVertexEdges) {
+ if (edges instanceof MutableOutEdges) {
return new Iterable<MutableEdge<I, E>>() {
@Override
public Iterator<MutableEdge<I, E>> iterator() {
- return ((MutableVertexEdges<I, E>) edges).mutableIterator();
+ return ((MutableOutEdges<I, E>) edges).mutableIterator();
}
};
} else {
@@ -212,8 +212,9 @@ public abstract class Vertex<I extends WritableComparable,
/**
* If a {@link MutableEdgesWrapper} was used to provide a mutable iterator,
- * copy any remaining edges to the new {@link VertexEdges} data
- * structure and keep a direct reference to it (thus discarding the wrapper).
+ * copy any remaining edges to the new {@link org.apache.giraph.edge.OutEdges}
+ * data structure and keep a direct reference to it (thus discarding the
+ * wrapper).
* Called by the Giraph infrastructure after computation.
*/
public void unwrapMutableEdges() {
@@ -242,10 +243,10 @@ public abstract class Vertex<I extends WritableComparable,
* @return Edge value (or null if missing)
*/
public E getEdgeValue(I targetVertexId) {
- // If the VertexEdges implementation has a specialized random-access
+ // If the OutEdges implementation has a specialized random-access
// method, we use that; otherwise, we scan the edges.
- if (edges instanceof StrictRandomAccessVertexEdges) {
- return ((StrictRandomAccessVertexEdges<I, E>) edges)
+ if (edges instanceof StrictRandomAccessOutEdges) {
+ return ((StrictRandomAccessOutEdges<I, E>) edges)
.getEdgeValue(targetVertexId);
} else {
for (Edge<I, E> edge : edges) {
@@ -265,10 +266,10 @@ public abstract class Vertex<I extends WritableComparable,
* @param edgeValue Edge value
*/
public void setEdgeValue(I targetVertexId, E edgeValue) {
- // If the VertexEdges implementation has a specialized random-access
+ // If the OutEdges implementation has a specialized random-access
// method, we use that; otherwise, we scan the edges.
- if (edges instanceof StrictRandomAccessVertexEdges) {
- ((StrictRandomAccessVertexEdges<I, E>) edges).setEdgeValue(
+ if (edges instanceof StrictRandomAccessOutEdges) {
+ ((StrictRandomAccessOutEdges<I, E>) edges).setEdgeValue(
targetVertexId, edgeValue);
} else {
for (MutableEdge<I, E> edge : getMutableEdges()) {
@@ -291,10 +292,10 @@ public abstract class Vertex<I extends WritableComparable,
* @return Iterable of edge values
*/
public Iterable<E> getAllEdgeValues(final I targetVertexId) {
- // If the VertexEdges implementation has a specialized random-access
+ // If the OutEdges implementation has a specialized random-access
// method, we use that; otherwise, we scan the edges.
- if (edges instanceof MultiRandomAccessVertexEdges) {
- return ((MultiRandomAccessVertexEdges<I, E>) edges)
+ if (edges instanceof MultiRandomAccessOutEdges) {
+ return ((MultiRandomAccessOutEdges<I, E>) edges)
.getAllEdgeValues(targetVertexId);
} else {
return new Iterable<E>() {
@@ -405,7 +406,7 @@ public abstract class Vertex<I extends WritableComparable,
* @param value Vertex value
* @param edges Initial edges
*/
- public void addVertexRequest(I id, V value, VertexEdges<I, E> edges)
+ public void addVertexRequest(I id, V value, OutEdges<I, E> edges)
throws IOException {
Vertex<I, V, E, M> vertex = getConf().createVertex();
vertex.initialize(id, value, edges);
@@ -420,7 +421,7 @@ public abstract class Vertex<I extends WritableComparable,
* @param value Vertex value
*/
public void addVertexRequest(I id, V value) throws IOException {
- addVertexRequest(id, value, getConf().createAndInitializeVertexEdges());
+ addVertexRequest(id, value, getConf().createAndInitializeOutEdges());
}
/**
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/io/formats/PseudoRandomEdgeInputFormat.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/io/formats/PseudoRandomEdgeInputFormat.java b/giraph-core/src/main/java/org/apache/giraph/io/formats/PseudoRandomEdgeInputFormat.java
index 2cc4dba..48544b0 100644
--- a/giraph-core/src/main/java/org/apache/giraph/io/formats/PseudoRandomEdgeInputFormat.java
+++ b/giraph-core/src/main/java/org/apache/giraph/io/formats/PseudoRandomEdgeInputFormat.java
@@ -72,7 +72,7 @@ public class PseudoRandomEdgeInputFormat
/** Current vertex id. */
private LongWritable currentVertexId = new LongWritable(-1);
/** Edges read for the current vertex. */
- private int currentVertexEdgesRead = 0;
+ private int currentOutEdgesRead = 0;
/** Target vertices of edges for current vertex. */
private Set<LongWritable> currentVertexDestVertices = Sets.newHashSet();
/** Random number generator for the current vertex (for consistency
@@ -131,20 +131,20 @@ public class PseudoRandomEdgeInputFormat
public boolean nextEdge() throws IOException, InterruptedException {
return totalSplitVertices > verticesRead + 1 ||
(totalSplitVertices == verticesRead + 1 &&
- edgesPerVertex > currentVertexEdgesRead);
+ edgesPerVertex > currentOutEdgesRead);
}
@Override
public LongWritable getCurrentSourceId() throws IOException,
InterruptedException {
- if (currentVertexEdgesRead == edgesPerVertex) {
+ if (currentOutEdgesRead == edgesPerVertex) {
++verticesRead;
currentVertexId = new LongWritable(-1);
}
if (currentVertexId.get() == -1) {
currentVertexId.set(startingVertexId + verticesRead);
- currentVertexEdgesRead = 0;
+ currentOutEdgesRead = 0;
// Seed on the vertex id to keep the vertex data the same when
// on different number of workers, but other parameters are the
// same.
@@ -162,7 +162,7 @@ public class PseudoRandomEdgeInputFormat
destVertexId.set(localEdgesHelper.generateDestVertex(
currentVertexId.get(), random));
} while (currentVertexDestVertices.contains(destVertexId));
- ++currentVertexEdgesRead;
+ ++currentOutEdgesRead;
currentVertexDestVertices.add(destVertexId);
if (LOG.isTraceEnabled()) {
LOG.trace("getCurrentEdge: Return edge (" + currentVertexId + ", " +
@@ -178,7 +178,7 @@ public class PseudoRandomEdgeInputFormat
@Override
public float getProgress() throws IOException, InterruptedException {
- return (verticesRead * edgesPerVertex + currentVertexEdgesRead) *
+ return (verticesRead * edgesPerVertex + currentOutEdgesRead) *
100.0f / (totalSplitVertices * edgesPerVertex);
}
}
http://git-wip-us.apache.org/repos/asf/giraph/blob/158c0b11/giraph-core/src/main/java/org/apache/giraph/io/formats/PseudoRandomIntNullVertexInputFormat.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/io/formats/PseudoRandomIntNullVertexInputFormat.java b/giraph-core/src/main/java/org/apache/giraph/io/formats/PseudoRandomIntNullVertexInputFormat.java
index b27fcc8..c9390ba 100644
--- a/giraph-core/src/main/java/org/apache/giraph/io/formats/PseudoRandomIntNullVertexInputFormat.java
+++ b/giraph-core/src/main/java/org/apache/giraph/io/formats/PseudoRandomIntNullVertexInputFormat.java
@@ -20,8 +20,8 @@ package org.apache.giraph.io.formats;
import org.apache.giraph.bsp.BspInputSplit;
import org.apache.giraph.edge.Edge;
+import org.apache.giraph.edge.OutEdges;
import org.apache.giraph.edge.ReusableEdge;
-import org.apache.giraph.edge.VertexEdges;
import org.apache.giraph.graph.Vertex;
import org.apache.giraph.io.VertexInputFormat;
import org.apache.giraph.io.VertexReader;
@@ -121,8 +121,8 @@ public class PseudoRandomIntNullVertexInputFormat extends
Vertex<IntWritable, FloatWritable, NullWritable, ?> vertex =
getConf().createVertex();
int vertexId = startingVertexId + verticesRead;
- VertexEdges<IntWritable, NullWritable> edges =
- getConf().createVertexEdges();
+ OutEdges<IntWritable, NullWritable> edges =
+ getConf().createOutEdges();
edges.initialize(edgesPerVertex);
destVertices.clear();
for (int i = 0; i < edgesPerVertex; ++i) {