giraph-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apre...@apache.org
Subject [3/8] GIRAPH-528: Decouple vertex implementation from edge storage (apresta)
Date Thu, 07 Mar 2013 05:37:42 GMT
http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/comm/TestMessageStores.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/comm/TestMessageStores.java b/giraph-core/src/test/java/org/apache/giraph/comm/TestMessageStores.java
index 5ce7a89..92fd49b 100644
--- a/giraph-core/src/test/java/org/apache/giraph/comm/TestMessageStores.java
+++ b/giraph-core/src/test/java/org/apache/giraph/comm/TestMessageStores.java
@@ -21,23 +21,6 @@ package org.apache.giraph.comm;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Random;
-import java.util.SortedMap;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import org.apache.giraph.conf.GiraphConfiguration;
-import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
 import org.apache.giraph.bsp.CentralizedServiceWorker;
 import org.apache.giraph.comm.messages.BasicMessageStore;
 import org.apache.giraph.comm.messages.ByteArrayMessagesPerVertexStore;
@@ -47,10 +30,12 @@ import org.apache.giraph.comm.messages.FlushableMessageStore;
 import org.apache.giraph.comm.messages.MessageStore;
 import org.apache.giraph.comm.messages.MessageStoreFactory;
 import org.apache.giraph.comm.messages.SequentialFileMessageStore;
-import org.apache.giraph.vertex.EdgeListVertex;
+import org.apache.giraph.conf.GiraphConfiguration;
+import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
 import org.apache.giraph.utils.ByteArrayVertexIdMessages;
 import org.apache.giraph.utils.CollectionUtils;
 import org.apache.giraph.utils.MockUtils;
+import org.apache.giraph.graph.Vertex;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.Writable;
@@ -59,6 +44,22 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Random;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
 import static org.junit.Assert.assertTrue;
 
 /** Test for different types of message stores */
@@ -75,8 +76,8 @@ public class TestMessageStores {
    */
   private static final Random RANDOM = new Random(101);
 
-  private static class IntVertex extends EdgeListVertex<IntWritable,
-      IntWritable, IntWritable, IntWritable> {
+  private static class IntVertex extends Vertex<IntWritable,
+        IntWritable, IntWritable, IntWritable> {
 
     @Override
     public void compute(Iterable<IntWritable> messages) throws IOException {

http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/conf/TestObjectCreation.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/conf/TestObjectCreation.java b/giraph-core/src/test/java/org/apache/giraph/conf/TestObjectCreation.java
new file mode 100644
index 0000000..9f0920a
--- /dev/null
+++ b/giraph-core/src/test/java/org/apache/giraph/conf/TestObjectCreation.java
@@ -0,0 +1,191 @@
+/*
+ * 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.conf;
+
+import org.apache.giraph.time.SystemTime;
+import org.apache.giraph.time.Time;
+import org.apache.giraph.time.Times;
+import org.apache.giraph.graph.Vertex;
+import org.apache.hadoop.io.DoubleWritable;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.Writable;
+import org.apache.hadoop.io.WritableComparable;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Benchmark tests to insure that object creation via
+ * {@link ImmutableClassesGiraphConfiguration} is fast
+ */
+public class TestObjectCreation {
+  @Rule
+  public TestName name = new TestName();
+  private static final Time TIME = SystemTime.get();
+  private static final long COUNT = 200000;
+  private long startNanos = -1;
+  private long totalNanos = -1;
+  private long total = 0;
+  private long expected = COUNT * (COUNT - 1) / 2L;
+  private ImmutableClassesGiraphConfiguration<LongWritable, LongWritable,
+      LongWritable, LongWritable> configuration;
+
+  @Before
+  public void setUp() {
+    GiraphConfiguration conf = new GiraphConfiguration();
+    conf.setClass(GiraphConstants.VERTEX_ID_CLASS, IntWritable.class,
+        WritableComparable.class);
+    conf.setClass(GiraphConstants.VERTEX_VALUE_CLASS, LongWritable.class,
+        Writable.class);
+    conf.setClass(GiraphConstants.EDGE_VALUE_CLASS, DoubleWritable.class,
+        Writable.class);
+    conf.setClass(GiraphConstants.MESSAGE_VALUE_CLASS, LongWritable.class,
+        Writable.class);
+    conf.setVertexClass(ImmutableVertex.class);
+    configuration =
+        new ImmutableClassesGiraphConfiguration<LongWritable, LongWritable,
+            LongWritable, LongWritable>(conf);
+    total = 0;
+    System.gc();
+  }
+
+  @After
+  public void cleanUp() {
+    totalNanos = Times.getNanosSince(TIME, startNanos);
+    System.out.println(name.getMethodName() + ": took "
+        + totalNanos +
+        " ns for " + COUNT + " elements " + (totalNanos * 1f / COUNT) +
+        " ns / element");
+    assertEquals(expected, total);
+    System.gc();
+  }
+
+  @Test
+  public void testCreateClass() {
+    startNanos = TIME.getNanoseconds();
+    for (int i = 0; i < COUNT; ++i) {
+      LongWritable value = configuration.createVertexValue();
+      value.set(i);
+      total += value.get();
+    }
+  }
+
+  @Test
+  public void testNativeCreateClass() {
+    startNanos = TIME.getNanoseconds();
+    for (int i = 0; i < COUNT; ++i) {
+      LongWritable value = new LongWritable();
+      value.set(i);
+      total += value.get();
+    }
+  }
+
+  private Class<?> getLongWritableClass() {
+    return LongWritable.class;
+  }
+
+  @Test
+  public void testNewInstance()
+      throws IllegalAccessException, InstantiationException {
+    startNanos = TIME.getNanoseconds();
+    for (int i = 0; i < COUNT; ++i) {
+      LongWritable value = (LongWritable)
+          getLongWritableClass().newInstance();
+      value.set(i);
+      total += value.get();
+    }
+  }
+
+  private synchronized Class<?> getSyncLongWritableClass() {
+    return LongWritable.class;
+  }
+
+  @Test
+  public void testSyncNewInstance()
+      throws IllegalAccessException, InstantiationException {
+    startNanos = TIME.getNanoseconds();
+    for (int i = 0; i < COUNT; ++i) {
+      LongWritable value = (LongWritable)
+          getSyncLongWritableClass().newInstance();
+      value.set(i);
+      total += value.get();
+    }
+  }
+
+  @Test
+  public void testReflectionUtilsNewInstance()
+      throws IllegalAccessException, InstantiationException {
+    // Throwaway to put into cache
+    org.apache.hadoop.util.ReflectionUtils.newInstance(LongWritable.class,
+        null);
+    startNanos = TIME.getNanoseconds();
+    for (int i = 0; i < COUNT; ++i) {
+      LongWritable value = (LongWritable)
+          org.apache.hadoop.util.ReflectionUtils.newInstance(
+              getLongWritableClass(), null);
+      value.set(i);
+      total += value.get();
+    }
+  }
+
+  @Test
+  public void testConstructorNewInstance()
+      throws IllegalAccessException, InstantiationException,
+      NoSuchMethodException, InvocationTargetException {
+    Constructor<?> constructor = LongWritable.class.getDeclaredConstructor
+        (new Class[]{});
+    startNanos = TIME.getNanoseconds();
+    for (int i = 0; i < COUNT; ++i) {
+      LongWritable value = (LongWritable) constructor.newInstance();
+      value.set(i);
+      total += value.get();
+    }
+  }
+
+  private static class ImmutableVertex extends Vertex<LongWritable,
+        LongWritable, LongWritable, LongWritable> {
+    @Override
+    public void compute(Iterable<LongWritable> messages) throws IOException {
+    }
+  }
+
+  private ImmutableClassesGiraphConfiguration<LongWritable, LongWritable,
+      LongWritable, LongWritable> getConfiguration() {
+    return configuration;
+  }
+
+  @Test
+  public void testImmutableClassesGiraphConfigurationNewInstance() {
+    startNanos = TIME.getNanoseconds();
+    for (int i = 0; i < COUNT; ++i) {
+      LongWritable value = getConfiguration().createVertexValue();
+      value.set(i);
+      total += value.get();
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/edge/TestMultiGraphEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/edge/TestMultiGraphEdges.java b/giraph-core/src/test/java/org/apache/giraph/edge/TestMultiGraphEdges.java
new file mode 100644
index 0000000..4eeff01
--- /dev/null
+++ b/giraph-core/src/test/java/org/apache/giraph/edge/TestMultiGraphEdges.java
@@ -0,0 +1,86 @@
+/*
+ * 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 com.google.common.collect.Lists;
+import org.apache.hadoop.io.DoubleWritable;
+import org.apache.hadoop.io.LongWritable;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.List;
+
+import static org.apache.giraph.graph.TestVertexAndEdges.instantiateVertexEdges;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests {@link VertexEdges} implementations that allow parallel edges.
+ */
+public class TestMultiGraphEdges {
+  /** {@link VertexEdges} classes to be tested. */
+  private Collection<Class<? extends VertexEdges>> edgesClasses =
+      Lists.newArrayList();
+
+  @Before
+  public void setUp() {
+    edgesClasses.add(ByteArrayEdges.class);
+    edgesClasses.add(ArrayListEdges.class);
+    edgesClasses.add(HashMultimapEdges.class);
+    edgesClasses.add(LongDoubleArrayEdges.class);
+  }
+
+  /**
+   * Ensures that all multigraph {@link VertexEdges} implementations allow
+   * parallel edges.
+   */
+  @Test
+  public void testParallelEdges() {
+    for (Class<? extends VertexEdges> edgesClass : edgesClasses) {
+      testParallelEdgesClass(edgesClass);
+    }
+  }
+
+  private void testParallelEdgesClass(
+      Class<? extends VertexEdges> edgesClass) {
+    VertexEdges<LongWritable, DoubleWritable> edges =
+        instantiateVertexEdges(edgesClass);
+
+    // Initial edges list contains parallel edges.
+    List<Edge<LongWritable, DoubleWritable>> initialEdges = Lists.newArrayList(
+        EdgeFactory.create(new LongWritable(1), new DoubleWritable(1)),
+        EdgeFactory.create(new LongWritable(2), new DoubleWritable(2)),
+        EdgeFactory.create(new LongWritable(3), new DoubleWritable(3)),
+        EdgeFactory.create(new LongWritable(2), new DoubleWritable(20)));
+
+    edges.initialize(initialEdges);
+
+    // The parallel edges should still be there.
+    assertEquals(4, edges.size());
+
+    // Adding a parallel edge should increase the number of edges.
+    edges.add(EdgeFactory.create(new LongWritable(3), new DoubleWritable(30)));
+    assertEquals(5, edges.size());
+
+    // Removing edges pointing to a given vertex should remove all parallel
+    // edges.
+    edges.remove(new LongWritable(2));
+    assertEquals(3, edges.size());
+  }
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/edge/TestMultiRandomAccessEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/edge/TestMultiRandomAccessEdges.java b/giraph-core/src/test/java/org/apache/giraph/edge/TestMultiRandomAccessEdges.java
new file mode 100644
index 0000000..b86f409
--- /dev/null
+++ b/giraph-core/src/test/java/org/apache/giraph/edge/TestMultiRandomAccessEdges.java
@@ -0,0 +1,81 @@
+/*
+ * 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 com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import org.apache.hadoop.io.DoubleWritable;
+import org.apache.hadoop.io.LongWritable;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.List;
+
+import static org.apache.giraph.graph.TestVertexAndEdges.instantiateVertexEdges;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests {@link MultiRandomAccessVertexEdges} implementations.
+ */
+public class TestMultiRandomAccessEdges {
+  /** {@link MultiRandomAccessVertexEdges} classes to be tested. */
+  private Collection<Class<? extends MultiRandomAccessVertexEdges>>
+      edgesClasses = Lists.newArrayList();
+
+  @Before
+  public void setUp() {
+    edgesClasses.add(HashMultimapEdges.class);
+  }
+
+  /**
+   * Ensures that all {@link MultiRandomAccessVertexEdges} implementations
+   * correctly return edge values.
+   */
+  @Test
+  public void testParallelEdges() {
+    for (Class<? extends MultiRandomAccessVertexEdges> edgesClass :
+        edgesClasses) {
+      testParallelEdgesClass(edgesClass);
+    }
+  }
+
+  private void testParallelEdgesClass(
+      Class<? extends MultiRandomAccessVertexEdges> edgesClass) {
+    MultiRandomAccessVertexEdges<LongWritable, DoubleWritable> edges =
+        (MultiRandomAccessVertexEdges<LongWritable, DoubleWritable>)
+            instantiateVertexEdges(edgesClass);
+
+    // Initial edges list contains parallel edges.
+    List<Edge<LongWritable, DoubleWritable>> initialEdges = Lists.newArrayList(
+        EdgeFactory.create(new LongWritable(1), new DoubleWritable(1)),
+        EdgeFactory.create(new LongWritable(2), new DoubleWritable(2)),
+        EdgeFactory.create(new LongWritable(3), new DoubleWritable(3)),
+        EdgeFactory.create(new LongWritable(2), new DoubleWritable(20)));
+
+    edges.initialize(initialEdges);
+
+    assertEquals(2,
+        Iterables.size(edges.getAllEdgeValues(new LongWritable(2))));
+    assertEquals(1,
+        Iterables.size(edges.getAllEdgeValues(new LongWritable(1))));
+    assertEquals(0,
+        Iterables.size(edges.getAllEdgeValues(new LongWritable(42))));
+  }
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/edge/TestNullValueEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/edge/TestNullValueEdges.java b/giraph-core/src/test/java/org/apache/giraph/edge/TestNullValueEdges.java
new file mode 100644
index 0000000..ef3fbc8
--- /dev/null
+++ b/giraph-core/src/test/java/org/apache/giraph/edge/TestNullValueEdges.java
@@ -0,0 +1,74 @@
+/*
+ * 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 com.google.common.collect.Lists;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.NullWritable;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.List;
+
+import static org.apache.giraph.graph.TestVertexAndEdges.instantiateVertexEdges;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests {@link VertexEdges} implementations with null edge values.
+ */
+public class TestNullValueEdges {
+  /** {@link VertexEdges} classes to be tested. */
+  private Collection<Class<? extends VertexEdges>>
+      edgesClasses = Lists.newArrayList();
+
+  @Before
+  public void setUp() {
+    edgesClasses.add(LongNullArrayEdges.class);
+    edgesClasses.add(LongNullHashSetEdges.class);
+  }
+
+  @Test
+  public void testEdges() {
+    for (Class<? extends VertexEdges> edgesClass : edgesClasses) {
+      testEdgesClass(edgesClass);
+    }
+  }
+
+  private void testEdgesClass(
+      Class<? extends VertexEdges> edgesClass) {
+    VertexEdges<LongWritable, NullWritable> edges =
+        (VertexEdges<LongWritable, NullWritable>)
+            instantiateVertexEdges(edgesClass);
+
+    List<Edge<LongWritable, NullWritable>> initialEdges = Lists.newArrayList(
+        EdgeFactory.create(new LongWritable(1)),
+        EdgeFactory.create(new LongWritable(2)),
+        EdgeFactory.create(new LongWritable(3)));
+
+    edges.initialize(initialEdges);
+    assertEquals(3, edges.size());
+
+    edges.add(EdgeFactory.createMutable(new LongWritable(4)));
+    assertEquals(4, edges.size());
+
+    edges.remove(new LongWritable(2));
+    assertEquals(3, edges.size());
+  }
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/edge/TestStrictGraphEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/edge/TestStrictGraphEdges.java b/giraph-core/src/test/java/org/apache/giraph/edge/TestStrictGraphEdges.java
new file mode 100644
index 0000000..3c57281
--- /dev/null
+++ b/giraph-core/src/test/java/org/apache/giraph/edge/TestStrictGraphEdges.java
@@ -0,0 +1,79 @@
+/*
+ * 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 com.google.common.collect.Lists;
+import org.apache.hadoop.io.DoubleWritable;
+import org.apache.hadoop.io.LongWritable;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.List;
+
+import static org.apache.giraph.graph.TestVertexAndEdges.instantiateVertexEdges;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests {@link VertexEdges} implementations that disallow parallel edges.
+ */
+public class TestStrictGraphEdges {
+  /** {@link VertexEdges} classes to be tested. */
+  private Collection<Class<? extends VertexEdges>> edgesClasses =
+      Lists.newArrayList();
+
+  @Before
+  public void setUp() {
+    edgesClasses.add(HashMapEdges.class);
+    edgesClasses.add(LongDoubleHashMapEdges.class);
+  }
+
+  /**
+   * Ensures that all strict graph {@link VertexEdges} implementations
+   * disallow parallel edges.
+   */
+  @Test
+  public void testParallelEdges() {
+    for (Class<? extends VertexEdges> edgesClass : edgesClasses) {
+      testParallelEdgesClass(edgesClass);
+    }
+  }
+
+  private void testParallelEdgesClass(
+      Class<? extends VertexEdges> edgesClass) {
+    VertexEdges<LongWritable, DoubleWritable> edges =
+        instantiateVertexEdges(edgesClass);
+
+    // Initial edges list contains parallel edges.
+    List<Edge<LongWritable, DoubleWritable>> initialEdges = Lists.newArrayList(
+        EdgeFactory.create(new LongWritable(1), new DoubleWritable(1)),
+        EdgeFactory.create(new LongWritable(2), new DoubleWritable(2)),
+        EdgeFactory.create(new LongWritable(3), new DoubleWritable(3)),
+        EdgeFactory.create(new LongWritable(2), new DoubleWritable(20)));
+
+    edges.initialize(initialEdges);
+
+    // Only one of the two parallel edges should be left.
+    assertEquals(3, edges.size());
+
+    // Adding a parallel edge shouldn't change the number of edges.
+    edges.add(EdgeFactory.create(new LongWritable(3), new DoubleWritable(30)));
+    assertEquals(3, edges.size());
+  }
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/edge/TestStrictRandomAccessEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/edge/TestStrictRandomAccessEdges.java b/giraph-core/src/test/java/org/apache/giraph/edge/TestStrictRandomAccessEdges.java
new file mode 100644
index 0000000..e6daa94
--- /dev/null
+++ b/giraph-core/src/test/java/org/apache/giraph/edge/TestStrictRandomAccessEdges.java
@@ -0,0 +1,78 @@
+/*
+ * 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 com.google.common.collect.Lists;
+import org.apache.hadoop.io.DoubleWritable;
+import org.apache.hadoop.io.LongWritable;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.List;
+
+import static org.apache.giraph.graph.TestVertexAndEdges.instantiateVertexEdges;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+/**
+ * Tests {@link StrictRandomAccessVertexEdges} implementations.
+ */
+public class TestStrictRandomAccessEdges {
+    /** {@link StrictRandomAccessVertexEdges} classes to be tested. */
+    private Collection<Class<? extends StrictRandomAccessVertexEdges>>
+        edgesClasses = Lists.newArrayList();
+
+    @Before
+    public void setUp() {
+      edgesClasses.add(HashMapEdges.class);
+      edgesClasses.add(LongDoubleHashMapEdges.class);
+    }
+
+    /**
+     * Ensures that all {@link StrictRandomAccessVertexEdges} implementations
+     * correctly return edge values.
+     */
+    @Test
+    public void testParallelEdges() {
+      for (Class<? extends StrictRandomAccessVertexEdges> edgesClass :
+          edgesClasses) {
+        testParallelEdgesClass(edgesClass);
+      }
+    }
+
+    private void testParallelEdgesClass(
+        Class<? extends StrictRandomAccessVertexEdges> edgesClass) {
+      StrictRandomAccessVertexEdges<LongWritable, DoubleWritable> edges =
+          (StrictRandomAccessVertexEdges<LongWritable, DoubleWritable>)
+              instantiateVertexEdges(edgesClass);
+
+      // Initial edges list contains parallel edges.
+      List<Edge<LongWritable, DoubleWritable>> initialEdges = Lists.newArrayList(
+          EdgeFactory.create(new LongWritable(1), new DoubleWritable(1)),
+          EdgeFactory.create(new LongWritable(2), new DoubleWritable(2)),
+          EdgeFactory.create(new LongWritable(3), new DoubleWritable(3)),
+          EdgeFactory.create(new LongWritable(2), new DoubleWritable(20)));
+
+      edges.initialize(initialEdges);
+
+      assertEquals(3.0, edges.getEdgeValue(new LongWritable(3)).get(), 0.0);
+      assertNull(edges.getEdgeValue(new LongWritable(55)));
+    }
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/graph/TestVertexAndEdges.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/graph/TestVertexAndEdges.java b/giraph-core/src/test/java/org/apache/giraph/graph/TestVertexAndEdges.java
new file mode 100644
index 0000000..425abe7
--- /dev/null
+++ b/giraph-core/src/test/java/org/apache/giraph/graph/TestVertexAndEdges.java
@@ -0,0 +1,348 @@
+/*
+ * 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.graph;
+
+import com.google.common.collect.Lists;
+import org.apache.giraph.conf.GiraphConfiguration;
+import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
+import org.apache.giraph.edge.ArrayListEdges;
+import org.apache.giraph.edge.ByteArrayEdges;
+import org.apache.giraph.edge.Edge;
+import org.apache.giraph.edge.EdgeFactory;
+import org.apache.giraph.edge.HashMapEdges;
+import org.apache.giraph.edge.HashMultimapEdges;
+import org.apache.giraph.edge.LongDoubleArrayEdges;
+import org.apache.giraph.edge.LongDoubleHashMapEdges;
+import org.apache.giraph.edge.VertexEdges;
+import org.apache.giraph.time.SystemTime;
+import org.apache.giraph.time.Time;
+import org.apache.giraph.time.Times;
+import org.apache.giraph.utils.DynamicChannelBufferInputStream;
+import org.apache.giraph.utils.DynamicChannelBufferOutputStream;
+import org.apache.giraph.utils.EdgeIterables;
+import org.apache.giraph.utils.UnsafeByteArrayInputStream;
+import org.apache.giraph.utils.UnsafeByteArrayOutputStream;
+import org.apache.giraph.utils.WritableUtils;
+import org.apache.hadoop.io.DoubleWritable;
+import org.apache.hadoop.io.FloatWritable;
+import org.apache.hadoop.io.LongWritable;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test {@link Vertex} functionality across the provided {@link org.apache.giraph.edge.VertexEdges}
+ * classes.
+ */
+public class TestVertexAndEdges {
+  /** Number of repetitions. */
+  public static final int REPS = 100;
+  /** {@link org.apache.giraph.edge.VertexEdges} classes to be tested. */
+  private Collection<Class<? extends VertexEdges>> edgesClasses =
+      Lists.newArrayList();
+
+  /**
+   * Dummy concrete vertex.
+   */
+  public static class TestVertex extends Vertex<LongWritable, FloatWritable,
+        DoubleWritable, LongWritable> {
+    @Override
+    public void compute(Iterable<LongWritable> messages) { }
+  }
+
+  @Before
+  public void setUp() {
+    edgesClasses.add(ByteArrayEdges.class);
+    edgesClasses.add(ArrayListEdges.class);
+    edgesClasses.add(HashMapEdges.class);
+    edgesClasses.add(HashMultimapEdges.class);
+    edgesClasses.add(LongDoubleArrayEdges.class);
+    edgesClasses.add(LongDoubleHashMapEdges.class);
+  }
+
+  private Vertex<LongWritable, FloatWritable, DoubleWritable, LongWritable>
+  instantiateVertex(Class<? extends VertexEdges> edgesClass) {
+    GiraphConfiguration giraphConfiguration = new GiraphConfiguration();
+    giraphConfiguration.setVertexClass(TestVertex.class);
+    giraphConfiguration.setVertexEdgesClass(edgesClass);
+    ImmutableClassesGiraphConfiguration immutableClassesGiraphConfiguration =
+        new ImmutableClassesGiraphConfiguration(giraphConfiguration);
+    return immutableClassesGiraphConfiguration.createVertex();
+  }
+
+  /**
+   * Test vertex instantiation, initialization, and updating the vertex value.
+   */
+  @Test
+  public void testVertexIdAndValue() {
+    Vertex<LongWritable, FloatWritable, DoubleWritable, LongWritable> vertex =
+        instantiateVertex(ArrayListEdges.class);
+    assertNotNull(vertex);
+    vertex.initialize(new LongWritable(7), new FloatWritable(3.0f));
+    assertEquals(7, vertex.getId().get());
+    assertEquals(3.0f, vertex.getValue().get(), 0d);
+    vertex.setValue(new FloatWritable(5.5f));
+    assertEquals(5.5f, vertex.getValue().get(), 0d);
+  }
+
+  public static VertexEdges
+  instantiateVertexEdges(Class<? extends VertexEdges> edgesClass) {
+    GiraphConfiguration giraphConfiguration = new GiraphConfiguration();
+    // Needed to extract type arguments in ReflectionUtils.
+    giraphConfiguration.setVertexClass(TestVertex.class);
+    giraphConfiguration.setVertexEdgesClass(edgesClass);
+    ImmutableClassesGiraphConfiguration immutableClassesGiraphConfiguration =
+        new ImmutableClassesGiraphConfiguration(giraphConfiguration);
+    return immutableClassesGiraphConfiguration.createVertexEdges();
+  }
+
+  /**
+   * Test the provided {@link VertexEdges} implementations for instantiation,
+   * initialization, edge addition, and edge removal.
+   */
+  @Test
+  public void testEdges() {
+    for (Class<? extends VertexEdges> edgesClass : edgesClasses) {
+      testEdgesClass(edgesClass);
+    }
+  }
+
+  private void testEdgesClass(Class<? extends VertexEdges> edgesClass) {
+    Vertex<LongWritable, FloatWritable, DoubleWritable, LongWritable> vertex =
+        instantiateVertex(edgesClass);
+    VertexEdges<LongWritable, DoubleWritable> vertexEdges =
+        instantiateVertexEdges(edgesClass);
+    assertNotNull(vertexEdges);
+
+    List<Edge<LongWritable, DoubleWritable>> edges = Lists.newLinkedList();
+    for (int i = 1000; i > 0; --i) {
+      edges.add(EdgeFactory.create(new LongWritable(i),
+          new DoubleWritable(i * 2.0)));
+    }
+
+    vertexEdges.initialize(edges);
+    vertex.initialize(new LongWritable(1), new FloatWritable(1), vertexEdges);
+
+    assertEquals(20.0, vertex.getEdgeValue(new LongWritable(10)).get(), 0.0);
+
+    assertEquals(1000, vertex.getNumEdges());
+    for (Edge<LongWritable, DoubleWritable> edge : vertex.getEdges()) {
+      assertEquals(edge.getTargetVertexId().get() * 2.0d,
+          edge.getValue().get(), 0d);
+    }
+    vertex.removeEdges(new LongWritable(500));
+    assertEquals(999, vertex.getNumEdges());
+    for (Edge<LongWritable, DoubleWritable> edge : vertex.getEdges()) {
+      assert(edge.getTargetVertexId().get() != 500);
+    }
+  }
+
+  /**
+   * Test {@link Vertex} and {@link VertexEdges} serialization.
+   * @throws IOException
+   */
+  @Test
+  public void testSerialize() throws IOException {
+    for (Class<? extends VertexEdges> edgesClass : edgesClasses) {
+      testSerializeVertexEdgesClass(edgesClass);
+      testDynamicChannelBufferSerializeVertexEdgesClass(edgesClass);
+      testUnsafeSerializeVertexEdgesClass(edgesClass);
+    }
+  }
+
+  private Vertex<LongWritable, FloatWritable, DoubleWritable, LongWritable>
+  buildVertex(Class<? extends VertexEdges> edgesClass) {
+    Vertex<LongWritable, FloatWritable, DoubleWritable, LongWritable> vertex =
+        instantiateVertex(edgesClass);
+    VertexEdges<LongWritable, DoubleWritable> vertexEdges =
+        instantiateVertexEdges(edgesClass);
+
+    int edgesCount = 200;
+    List<Edge<LongWritable, DoubleWritable>> edges =
+        Lists.newArrayListWithCapacity(edgesCount);
+    for (int i = edgesCount; i > 0; --i) {
+      edges.add(EdgeFactory.create(new LongWritable(i),
+          new DoubleWritable(i * 2.0)));
+    }
+
+    vertexEdges.initialize(edges);
+    vertex.initialize(new LongWritable(2), new FloatWritable(3.0f),
+        vertexEdges);
+    return vertex;
+  }
+
+  private void testSerializeVertexEdgesClass(
+      Class<? extends VertexEdges> edgesClass) {
+    Vertex<LongWritable, FloatWritable, DoubleWritable, LongWritable> vertex =
+        buildVertex(edgesClass);
+
+    long serializeNanosStart;
+    long serializeNanos = 0;
+    byte[] byteArray = null;
+    for (int i = 0; i < REPS; ++i) {
+      serializeNanosStart = SystemTime.get().getNanoseconds();
+      byteArray = WritableUtils.writeToByteArray(vertex);
+      serializeNanos += Times.getNanosecondsSince(SystemTime.get(),
+          serializeNanosStart);
+    }
+    serializeNanos /= REPS;
+    System.out.println("testSerialize: Serializing took " +
+        serializeNanos + " ns for " + byteArray.length + " bytes " +
+        (byteArray.length * 1f * Time.NS_PER_SECOND / serializeNanos) +
+        " bytes / sec for " + edgesClass.getName());
+
+    Vertex<LongWritable, FloatWritable, DoubleWritable, LongWritable>
+        readVertex = instantiateVertex(edgesClass);
+
+    long deserializeNanosStart;
+    long deserializeNanos = 0;
+    for (int i = 0; i < REPS; ++i) {
+      deserializeNanosStart = SystemTime.get().getNanoseconds();
+      WritableUtils.readFieldsFromByteArray(byteArray, readVertex);
+      deserializeNanos += Times.getNanosecondsSince(SystemTime.get(),
+          deserializeNanosStart);
+    }
+    deserializeNanos /= REPS;
+    System.out.println("testSerialize: Deserializing took " +
+        deserializeNanos + " ns for " + byteArray.length + " bytes " +
+        (byteArray.length * 1f * Time.NS_PER_SECOND / deserializeNanos) +
+        " bytes / sec for " + edgesClass.getName());
+
+    assertEquals(vertex.getId(), readVertex.getId());
+    assertEquals(vertex.getValue(), readVertex.getValue());
+    assertTrue(EdgeIterables.sameEdges(vertex.getEdges(), readVertex.getEdges()));
+  }
+
+  private void testDynamicChannelBufferSerializeVertexEdgesClass(
+      Class<? extends VertexEdges> edgesClass)
+      throws IOException {
+    Vertex<LongWritable, FloatWritable, DoubleWritable, LongWritable> vertex =
+        buildVertex(edgesClass);
+
+    long serializeNanosStart;
+    long serializeNanos = 0;
+    DynamicChannelBufferOutputStream outputStream = null;
+    for (int i = 0; i <
+        REPS; ++i) {
+      serializeNanosStart = SystemTime.get().getNanoseconds();
+      outputStream =
+          new DynamicChannelBufferOutputStream(32);
+      vertex.write(outputStream);
+      serializeNanos += Times.getNanosecondsSince(SystemTime.get(),
+          serializeNanosStart);
+    }
+    serializeNanos /= REPS;
+    System.out.println("testDynamicChannelBufferSerializeVertexEdgesClass: " +
+        "Serializing took " + serializeNanos + " ns for " +
+        outputStream.getDynamicChannelBuffer().writerIndex() + " bytes " +
+        (outputStream.getDynamicChannelBuffer().writerIndex() * 1f *
+            Time.NS_PER_SECOND / serializeNanos) +
+        " bytes / sec for " + edgesClass.getName());
+
+    Vertex<LongWritable, FloatWritable, DoubleWritable, LongWritable>
+        readVertex = instantiateVertex(edgesClass);
+
+    long deserializeNanosStart;
+    long deserializeNanos = 0;
+    for (int i = 0; i < REPS; ++i) {
+      deserializeNanosStart = SystemTime.get().getNanoseconds();
+      DynamicChannelBufferInputStream inputStream = new
+          DynamicChannelBufferInputStream(
+          outputStream.getDynamicChannelBuffer());
+      readVertex.readFields(inputStream);
+      deserializeNanos += Times.getNanosecondsSince(SystemTime.get(),
+          deserializeNanosStart);
+      outputStream.getDynamicChannelBuffer().readerIndex(0);
+    }
+    deserializeNanos /= REPS;
+    System.out.println("testDynamicChannelBufferSerializeVertexEdgesClass: " +
+        "Deserializing took " + deserializeNanos + " ns for " +
+        outputStream.getDynamicChannelBuffer().writerIndex() + " bytes " +
+        (outputStream.getDynamicChannelBuffer().writerIndex() * 1f *
+            Time.NS_PER_SECOND / deserializeNanos) +
+        " bytes / sec for " + edgesClass.getName());
+
+    assertEquals(vertex.getId(), readVertex.getId());
+    assertEquals(vertex.getValue(), readVertex.getValue());
+    assertTrue(EdgeIterables.sameEdges(vertex.getEdges(), readVertex.getEdges()));
+  }
+
+  private void testUnsafeSerializeVertexEdgesClass(
+      Class<? extends VertexEdges> edgesClass)
+      throws IOException {
+    Vertex<LongWritable, FloatWritable, DoubleWritable, LongWritable> vertex =
+        buildVertex(edgesClass);
+
+    long serializeNanosStart;
+    long serializeNanos = 0;
+    UnsafeByteArrayOutputStream outputStream = null;
+    for (int i = 0; i <
+        REPS; ++i) {
+      serializeNanosStart = SystemTime.get().getNanoseconds();
+      outputStream =
+          new UnsafeByteArrayOutputStream(32);
+      vertex.write(outputStream);
+      serializeNanos += Times.getNanosecondsSince(SystemTime.get(),
+          serializeNanosStart);
+    }
+    serializeNanos /= REPS;
+    System.out.println("testUnsafeSerializeVertexEdgesClass: " +
+        "Serializing took " +
+        serializeNanos +
+        " ns for " + outputStream.getPos()
+        + " bytes " +
+        (outputStream.getPos() * 1f *
+            Time.NS_PER_SECOND / serializeNanos) +
+        " bytes / sec for " + edgesClass.getName());
+
+    Vertex<LongWritable, FloatWritable, DoubleWritable, LongWritable>
+        readVertex = instantiateVertex(edgesClass);
+
+    long deserializeNanosStart;
+    long deserializeNanos = 0;
+    for (int i = 0; i < REPS; ++i) {
+      deserializeNanosStart = SystemTime.get().getNanoseconds();
+      UnsafeByteArrayInputStream inputStream = new
+          UnsafeByteArrayInputStream(
+          outputStream.getByteArray(), 0, outputStream.getPos());
+      readVertex.readFields(inputStream);
+      deserializeNanos += Times.getNanosecondsSince(SystemTime.get(),
+          deserializeNanosStart);
+    }
+    deserializeNanos /= REPS;
+    System.out.println("testUnsafeSerializeVertexEdgesClass: " +
+        "Deserializing took " +
+        deserializeNanos +
+        " ns for " + outputStream.getPos() +
+        " bytes " +
+        (outputStream.getPos() * 1f *
+            Time.NS_PER_SECOND / deserializeNanos) +
+        " bytes / sec for " + edgesClass.getName());
+
+    assertEquals(vertex.getId(), readVertex.getId());
+    assertEquals(vertex.getValue(), readVertex.getValue());
+    assertTrue(EdgeIterables.sameEdges(vertex.getEdges(), readVertex.getEdges()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/io/TestAdjacencyListTextVertexOutputFormat.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/io/TestAdjacencyListTextVertexOutputFormat.java b/giraph-core/src/test/java/org/apache/giraph/io/TestAdjacencyListTextVertexOutputFormat.java
index 036924f..60bfac1 100644
--- a/giraph-core/src/test/java/org/apache/giraph/io/TestAdjacencyListTextVertexOutputFormat.java
+++ b/giraph-core/src/test/java/org/apache/giraph/io/TestAdjacencyListTextVertexOutputFormat.java
@@ -17,20 +17,17 @@
  */
 package org.apache.giraph.io;
 
-import org.apache.giraph.graph.Edge;
-import org.apache.giraph.graph.EdgeFactory;
+import com.google.common.collect.Lists;
 import org.apache.giraph.io.formats.AdjacencyListTextVertexOutputFormat;
-import org.apache.giraph.vertex.Vertex;
+import org.apache.giraph.edge.Edge;
+import org.apache.giraph.edge.EdgeFactory;
+import org.apache.giraph.graph.Vertex;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.Text;
-import org.apache.hadoop.io.WritableComparable;
 import org.apache.hadoop.mapreduce.RecordWriter;
 import org.apache.hadoop.mapreduce.TaskAttemptContext;
 import org.junit.Test;
-import org.mockito.Matchers;
-
-import com.google.common.collect.Lists;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -76,7 +73,6 @@ public class TestAdjacencyListTextVertexOutputFormat extends AdjacencyListTextVe
     Text expected = new Text("The Beautiful South\t32.2");
     verify(tw).write(expected, null);
     verify(vertex, times(1)).getEdges();
-    verify(vertex, times(0)).getEdgeValue(Matchers.<WritableComparable>any());
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/io/TestEdgeInput.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/io/TestEdgeInput.java b/giraph-core/src/test/java/org/apache/giraph/io/TestEdgeInput.java
index c080622..55c0c86 100644
--- a/giraph-core/src/test/java/org/apache/giraph/io/TestEdgeInput.java
+++ b/giraph-core/src/test/java/org/apache/giraph/io/TestEdgeInput.java
@@ -18,6 +18,8 @@
 
 package org.apache.giraph.io;
 
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
 import org.apache.giraph.BspCase;
 import org.apache.giraph.conf.GiraphClasses;
 import org.apache.giraph.io.formats.IdWithValueTextOutputFormat;
@@ -25,14 +27,12 @@ import org.apache.giraph.io.formats.IntIntTextVertexValueInputFormat;
 import org.apache.giraph.io.formats.IntNullReverseTextEdgeInputFormat;
 import org.apache.giraph.io.formats.IntNullTextEdgeInputFormat;
 import org.apache.giraph.utils.InternalVertexRunner;
-import org.apache.giraph.vertex.EdgeListVertex;
+import org.apache.giraph.edge.ByteArrayEdges;
+import org.apache.giraph.graph.Vertex;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.NullWritable;
 import org.junit.Test;
 
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
-
 import java.io.IOException;
 import java.util.Map;
 
@@ -60,6 +60,7 @@ public class TestEdgeInput extends BspCase {
 
     GiraphClasses classes = new GiraphClasses();
     classes.setVertexClass(TestVertexWithNumEdges.class);
+    classes.setVertexEdgesClass(ByteArrayEdges.class);
     classes.setEdgeInputFormatClass(IntNullTextEdgeInputFormat.class);
     classes.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class);
     Map<String, String> params = ImmutableMap.of();
@@ -90,6 +91,7 @@ public class TestEdgeInput extends BspCase {
 
     GiraphClasses classes = new GiraphClasses();
     classes.setVertexClass(TestVertexWithNumEdges.class);
+    classes.setVertexEdgesClass(ByteArrayEdges.class);
     classes.setEdgeInputFormatClass(IntNullReverseTextEdgeInputFormat.class);
     classes.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class);
     Map<String, String> params = ImmutableMap.of();
@@ -127,6 +129,7 @@ public class TestEdgeInput extends BspCase {
 
     GiraphClasses classes = new GiraphClasses();
     classes.setVertexClass(TestVertexDoNothing.class);
+    classes.setVertexEdgesClass(ByteArrayEdges.class);
     classes.setVertexInputFormatClass(IntIntTextVertexValueInputFormat.class);
     classes.setEdgeInputFormatClass(IntNullTextEdgeInputFormat.class);
     classes.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class);
@@ -151,6 +154,7 @@ public class TestEdgeInput extends BspCase {
 
     classes = new GiraphClasses();
     classes.setVertexClass(TestVertexWithNumEdges.class);
+    classes.setVertexEdgesClass(ByteArrayEdges.class);
     classes.setVertexInputFormatClass(IntIntTextVertexValueInputFormat.class);
     classes.setEdgeInputFormatClass(IntNullTextEdgeInputFormat.class);
     classes.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class);
@@ -168,8 +172,8 @@ public class TestEdgeInput extends BspCase {
     assertEquals(1, (int) values.get(5));
   }
 
-  public static class TestVertexWithNumEdges extends EdgeListVertex<IntWritable,
-      IntWritable, NullWritable, NullWritable> {
+  public static class TestVertexWithNumEdges extends Vertex<IntWritable,
+        IntWritable, NullWritable, NullWritable> {
     @Override
     public void compute(Iterable<NullWritable> messages) throws IOException {
       setValue(new IntWritable(getNumEdges()));
@@ -177,7 +181,7 @@ public class TestEdgeInput extends BspCase {
     }
   }
 
-  public static class TestVertexDoNothing extends EdgeListVertex<IntWritable,
+  public static class TestVertexDoNothing extends Vertex<IntWritable,
       IntWritable, NullWritable, NullWritable> {
     @Override
     public void compute(Iterable<NullWritable> messages) throws IOException {

http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/io/TestIdWithValueTextOutputFormat.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/io/TestIdWithValueTextOutputFormat.java b/giraph-core/src/test/java/org/apache/giraph/io/TestIdWithValueTextOutputFormat.java
index e770338..3fb4bbe 100644
--- a/giraph-core/src/test/java/org/apache/giraph/io/TestIdWithValueTextOutputFormat.java
+++ b/giraph-core/src/test/java/org/apache/giraph/io/TestIdWithValueTextOutputFormat.java
@@ -18,26 +18,24 @@
 
 package org.apache.giraph.io;
 
-import org.apache.giraph.vertex.Vertex;
 import org.apache.giraph.io.formats.IdWithValueTextOutputFormat;
+import org.apache.giraph.graph.Vertex;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.io.WritableComparable;
 import org.apache.hadoop.mapreduce.RecordWriter;
 import org.apache.hadoop.mapreduce.TaskAttemptContext;
 import org.junit.Test;
-import org.mockito.Matchers;
+
+import java.io.IOException;
+import java.util.ArrayList;
 
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import java.io.IOException;
-import java.util.ArrayList;
-
 public class TestIdWithValueTextOutputFormat extends IdWithValueTextOutputFormat<Text, DoubleWritable, Writable> {
   @Test
   public void testHappyPath() throws IOException, InterruptedException {
@@ -91,6 +89,5 @@ public class TestIdWithValueTextOutputFormat extends IdWithValueTextOutputFormat
 
     verify(tw).write(expected, null);
     verify(vertex, times(0)).getEdges();
-    verify(vertex, times(0)).getEdgeValue(Matchers.<WritableComparable>any());
   }
 }

http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/io/TestJsonBase64Format.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/io/TestJsonBase64Format.java b/giraph-core/src/test/java/org/apache/giraph/io/TestJsonBase64Format.java
index b3c63f6..0117ce9 100644
--- a/giraph-core/src/test/java/org/apache/giraph/io/TestJsonBase64Format.java
+++ b/giraph-core/src/test/java/org/apache/giraph/io/TestJsonBase64Format.java
@@ -17,16 +17,16 @@
  */
 
 package org.apache.giraph.io;
+
 import org.apache.giraph.BspCase;
-import org.apache.giraph.benchmark.EdgeListVertexPageRankBenchmark;
-import org.apache.giraph.benchmark.PageRankComputation;
+import org.apache.giraph.benchmark.PageRankVertex;
 import org.apache.giraph.conf.GiraphClasses;
-import org.apache.giraph.io.formats.PseudoRandomInputFormatConstants;
-import org.apache.giraph.job.GiraphJob;
 import org.apache.giraph.io.formats.GiraphFileInputFormat;
 import org.apache.giraph.io.formats.JsonBase64VertexInputFormat;
 import org.apache.giraph.io.formats.JsonBase64VertexOutputFormat;
+import org.apache.giraph.io.formats.PseudoRandomInputFormatConstants;
 import org.apache.giraph.io.formats.PseudoRandomVertexInputFormat;
+import org.apache.giraph.job.GiraphJob;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.junit.Test;
@@ -62,7 +62,7 @@ public class TestJsonBase64Format extends BspCase {
 
     Path outputPath = getTempPath(getCallingMethodName());
     GiraphClasses classes = new GiraphClasses();
-    classes.setVertexClass(EdgeListVertexPageRankBenchmark.class);
+    classes.setVertexClass(PageRankVertex.class);
     classes.setVertexInputFormatClass(PseudoRandomVertexInputFormat.class);
     classes.setVertexOutputFormatClass(JsonBase64VertexOutputFormat.class);
     GiraphJob job = prepareJob(getCallingMethodName(), classes, outputPath);
@@ -70,24 +70,24 @@ public class TestJsonBase64Format extends BspCase {
         PseudoRandomInputFormatConstants.AGGREGATE_VERTICES, 101);
     job.getConfiguration().setLong(
         PseudoRandomInputFormatConstants.EDGES_PER_VERTEX, 2);
-    job.getConfiguration().setInt(PageRankComputation.SUPERSTEP_COUNT, 2);
+    job.getConfiguration().setInt(PageRankVertex.SUPERSTEP_COUNT, 2);
 
     assertTrue(job.run(true));
 
     Path outputPath2 = getTempPath(getCallingMethodName() + "2");
     classes = new GiraphClasses();
-    classes.setVertexClass(EdgeListVertexPageRankBenchmark.class);
+    classes.setVertexClass(PageRankVertex.class);
     classes.setVertexInputFormatClass(JsonBase64VertexInputFormat.class);
     classes.setVertexOutputFormatClass(JsonBase64VertexOutputFormat.class);
     job = prepareJob(getCallingMethodName(), classes, outputPath2);
-    job.getConfiguration().setInt(PageRankComputation.SUPERSTEP_COUNT, 3);
+    job.getConfiguration().setInt(PageRankVertex.SUPERSTEP_COUNT, 3);
     GiraphFileInputFormat.addVertexInputPath(
       job.getInternalJob().getConfiguration(), outputPath);
     assertTrue(job.run(true));
 
     Path outputPath3 = getTempPath(getCallingMethodName() + "3");
     classes = new GiraphClasses();
-    classes.setVertexClass(EdgeListVertexPageRankBenchmark.class);
+    classes.setVertexClass(PageRankVertex.class);
     classes.setVertexInputFormatClass(PseudoRandomVertexInputFormat.class);
     classes.setVertexOutputFormatClass(JsonBase64VertexOutputFormat.class);
     job = prepareJob(getCallingMethodName(), classes, outputPath3);
@@ -95,7 +95,7 @@ public class TestJsonBase64Format extends BspCase {
         PseudoRandomInputFormatConstants.AGGREGATE_VERTICES, 101);
     job.getConfiguration().setLong(
         PseudoRandomInputFormatConstants.EDGES_PER_VERTEX, 2);
-    job.getConfiguration().setInt(PageRankComputation.SUPERSTEP_COUNT, 5);
+    job.getConfiguration().setInt(PageRankVertex.SUPERSTEP_COUNT, 5);
     assertTrue(job.run(true));
 
     Configuration conf = job.getConfiguration();

http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/io/TestLongDoubleDoubleAdjacencyListVertexInputFormat.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/io/TestLongDoubleDoubleAdjacencyListVertexInputFormat.java b/giraph-core/src/test/java/org/apache/giraph/io/TestLongDoubleDoubleAdjacencyListVertexInputFormat.java
index 7ef8eae..6a0b912 100644
--- a/giraph-core/src/test/java/org/apache/giraph/io/TestLongDoubleDoubleAdjacencyListVertexInputFormat.java
+++ b/giraph-core/src/test/java/org/apache/giraph/io/TestLongDoubleDoubleAdjacencyListVertexInputFormat.java
@@ -18,19 +18,17 @@
 package org.apache.giraph.io;
 
 
-import org.apache.giraph.conf.GiraphConstants;
-import org.apache.giraph.graph.EdgeFactory;
+import org.apache.giraph.conf.GiraphConfiguration;
+import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
 import org.apache.giraph.graph.GraphState;
 import org.apache.giraph.io.formats.AdjacencyListTextVertexInputFormat;
 import org.apache.giraph.io.formats.LongDoubleDoubleAdjacencyListVertexInputFormat;
-import org.apache.giraph.vertex.EdgeListVertex;
-import org.apache.giraph.vertex.Vertex;
-import org.apache.hadoop.conf.Configuration;
+import org.apache.giraph.edge.EdgeFactory;
+import org.apache.giraph.graph.Vertex;
 import org.apache.hadoop.io.BooleanWritable;
 import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.LongWritable;
 import org.apache.hadoop.io.Text;
-import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.mapreduce.InputSplit;
 import org.apache.hadoop.mapreduce.RecordReader;
 import org.apache.hadoop.mapreduce.TaskAttemptContext;
@@ -50,7 +48,8 @@ import static org.mockito.Mockito.when;
 public class TestLongDoubleDoubleAdjacencyListVertexInputFormat extends LongDoubleDoubleAdjacencyListVertexInputFormat<BooleanWritable> {
 
   private RecordReader<LongWritable, Text> rr;
-  private Configuration conf;
+  private ImmutableClassesGiraphConfiguration<LongWritable, DoubleWritable,
+      DoubleWritable, BooleanWritable> conf;
   private TaskAttemptContext tac;
   private GraphState<LongWritable, DoubleWritable, DoubleWritable, BooleanWritable> graphState;
 
@@ -58,10 +57,10 @@ public class TestLongDoubleDoubleAdjacencyListVertexInputFormat extends LongDoub
   public void setUp() throws IOException, InterruptedException {
     rr = mock(RecordReader.class);
     when(rr.nextKeyValue()).thenReturn(true);
-    conf = new Configuration();
-    conf.setClass(GiraphConstants.VERTEX_CLASS, DummyVertex.class, Vertex.class);
-    conf.setClass(GiraphConstants.VERTEX_ID_CLASS, LongWritable.class, Writable.class);
-    conf.setClass(GiraphConstants.VERTEX_VALUE_CLASS, DoubleWritable.class, Writable.class);
+    GiraphConfiguration giraphConf = new GiraphConfiguration();
+    giraphConf.setVertexClass(DummyVertex.class);
+    conf = new ImmutableClassesGiraphConfiguration<LongWritable, DoubleWritable,
+        DoubleWritable, BooleanWritable>(giraphConf);
     graphState = mock(GraphState.class);
     tac = mock(TaskAttemptContext.class);
     when(tac.getConfiguration()).thenReturn(conf);
@@ -163,8 +162,7 @@ public class TestLongDoubleDoubleAdjacencyListVertexInputFormat extends LongDoub
     assertEquals(vertex.getNumEdges(), 1);
   }
 
-  public static class DummyVertex
-      extends EdgeListVertex<LongWritable, DoubleWritable,
+  public static class DummyVertex extends Vertex<LongWritable, DoubleWritable,
       DoubleWritable, BooleanWritable> {
     @Override
     public void compute(Iterable<BooleanWritable> messages) throws IOException {

http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/io/TestTextDoubleDoubleAdjacencyListVertexInputFormat.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/io/TestTextDoubleDoubleAdjacencyListVertexInputFormat.java b/giraph-core/src/test/java/org/apache/giraph/io/TestTextDoubleDoubleAdjacencyListVertexInputFormat.java
index d1e267e..6d81f51 100644
--- a/giraph-core/src/test/java/org/apache/giraph/io/TestTextDoubleDoubleAdjacencyListVertexInputFormat.java
+++ b/giraph-core/src/test/java/org/apache/giraph/io/TestTextDoubleDoubleAdjacencyListVertexInputFormat.java
@@ -17,16 +17,15 @@
  */
 package org.apache.giraph.io;
 
-import org.apache.giraph.bsp.BspUtils;
-import org.apache.giraph.conf.GiraphConstants;
-import org.apache.giraph.graph.Edge;
-import org.apache.giraph.graph.EdgeFactory;
+import org.apache.giraph.conf.GiraphConfiguration;
+import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
 import org.apache.giraph.graph.GraphState;
 import org.apache.giraph.io.formats.AdjacencyListTextVertexInputFormat;
 import org.apache.giraph.io.formats.TextDoubleDoubleAdjacencyListVertexInputFormat;
-import org.apache.giraph.vertex.EdgeListVertex;
-import org.apache.giraph.vertex.Vertex;
-import org.apache.hadoop.conf.Configuration;
+import org.apache.giraph.utils.EdgeIterables;
+import org.apache.giraph.edge.Edge;
+import org.apache.giraph.edge.EdgeFactory;
+import org.apache.giraph.graph.Vertex;
 import org.apache.hadoop.io.BooleanWritable;
 import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.LongWritable;
@@ -39,14 +38,9 @@ import org.apache.hadoop.mapreduce.TaskAttemptContext;
 import org.junit.Before;
 import org.junit.Test;
 
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
 import java.io.IOException;
 import java.lang.reflect.Method;
 import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
@@ -57,7 +51,8 @@ import static org.mockito.Mockito.when;
 public class TestTextDoubleDoubleAdjacencyListVertexInputFormat extends TextDoubleDoubleAdjacencyListVertexInputFormat<BooleanWritable> {
 
   private RecordReader<LongWritable, Text> rr;
-  private Configuration conf;
+  private ImmutableClassesGiraphConfiguration<Text, DoubleWritable,
+      DoubleWritable, BooleanWritable> conf;
   private TaskAttemptContext tac;
   private GraphState<Text, DoubleWritable, DoubleWritable, BooleanWritable> graphState;
 
@@ -65,10 +60,10 @@ public class TestTextDoubleDoubleAdjacencyListVertexInputFormat extends TextDoub
   public void setUp() throws IOException, InterruptedException {
     rr = mock(RecordReader.class);
     when(rr.nextKeyValue()).thenReturn(true).thenReturn(false);
-    conf = new Configuration();
-    conf.setClass(GiraphConstants.VERTEX_CLASS, DummyVertex.class, Vertex.class);
-    conf.setClass(GiraphConstants.VERTEX_ID_CLASS, Text.class, Writable.class);
-    conf.setClass(GiraphConstants.VERTEX_VALUE_CLASS, DoubleWritable.class, Writable.class);
+    GiraphConfiguration giraphConf = new GiraphConfiguration();
+    giraphConf.setVertexClass(DummyVertex.class);
+    conf = new ImmutableClassesGiraphConfiguration<Text, DoubleWritable,
+        DoubleWritable, BooleanWritable>(giraphConf);
     graphState = mock(GraphState.class);
     tac = mock(TaskAttemptContext.class);
     when(tac.getConfiguration()).thenReturn(conf);
@@ -133,31 +128,26 @@ public class TestTextDoubleDoubleAdjacencyListVertexInputFormat extends TextDoub
   }
 
   public static <I extends WritableComparable, V extends Writable,
-      E extends Writable, M extends Writable> void assertValidVertex(Configuration conf,
-      GraphState<I, V, E, M> graphState, Vertex<I, V, E, M> actual,
-      I expectedId, V expectedValue, Edge<I, E>... edges)
-      throws Exception {
-    Vertex<I, V, E, M> expected = BspUtils.createVertex(conf);
+      E extends WritableComparable, M extends Writable> void assertValidVertex(
+      ImmutableClassesGiraphConfiguration<I, V, E, M> conf,
+      GraphState<I, V, E, M> graphState,
+      Vertex<I, V, E, M> actual,
+      I expectedId,
+      V expectedValue,
+      Edge<I, E>... edges) throws Exception {
+    Vertex<I, V, E, M> expected = conf.createVertex();
     setGraphState(expected, graphState);
     expected.initialize(expectedId, expectedValue, Arrays.asList(edges));
     assertValid(expected, actual);
   }
 
-  public static
-  <I extends WritableComparable, V extends Writable, E extends Writable, M extends Writable> void
-  assertValid(Vertex<I, V, E, M> expected, Vertex<I, V, E, M> actual) {
+  public static <I extends WritableComparable, V extends Writable,
+      E extends WritableComparable, M extends Writable> void assertValid(
+      Vertex<I, V, E, M> expected, Vertex<I, V, E, M> actual) {
     assertEquals(expected.getId(), actual.getId());
     assertEquals(expected.getValue(), actual.getValue());
     assertEquals(expected.getTotalNumEdges(), actual.getTotalNumEdges());
-    List<Edge<I, E>> expectedEdges = Lists.newArrayList();
-    List<Edge<I, E>> actualEdges = Lists.newArrayList();
-    Iterables.addAll(actualEdges, actual.getEdges());
-    Iterables.addAll(expectedEdges, expected.getEdges());
-    Collections.sort(expectedEdges);
-    Collections.sort(actualEdges);
-    for(int i = 0; i < expectedEdges.size(); i++) {
-      assertEquals(expectedEdges.get(i), actualEdges.get(i));
-    }
+    assertTrue(EdgeIterables.equals(expected.getEdges(), actual.getEdges()));
   }
 
   @Test
@@ -172,7 +162,8 @@ public class TestTextDoubleDoubleAdjacencyListVertexInputFormat extends TextDoub
     Vertex<Text, DoubleWritable, DoubleWritable, BooleanWritable> vertex =
         vr.getCurrentVertex();
     setGraphState(vertex, graphState);
-    assertValidVertex(conf, graphState, vertex, new Text("Hi"), new DoubleWritable(0),
+    assertValidVertex(conf, graphState, vertex,
+        new Text("Hi"), new DoubleWritable(0),
         EdgeFactory.create(new Text("Ciao"), new DoubleWritable(1.123d)),
         EdgeFactory.create(new Text("Bomdia"), new DoubleWritable(2.234d)),
         EdgeFactory.create(new Text("Ola"), new DoubleWritable(3.345d)));
@@ -221,13 +212,13 @@ public class TestTextDoubleDoubleAdjacencyListVertexInputFormat extends TextDoub
     Vertex<Text, DoubleWritable, DoubleWritable, BooleanWritable> vertex =
         vr.getCurrentVertex();
     setGraphState(vertex, graphState);
-    assertValidVertex(conf, graphState, vertex, new Text("alpha"), new DoubleWritable(42d),
+    assertValidVertex(conf, graphState, vertex,
+        new Text("alpha"), new DoubleWritable(42d),
         EdgeFactory.create(new Text("beta"), new DoubleWritable(99d)));
     assertEquals(vertex.getNumEdges(), 1);
   }
 
-  public static class DummyVertex
-      extends EdgeListVertex<Text, DoubleWritable,
+  public static class DummyVertex extends Vertex<Text, DoubleWritable,
             DoubleWritable, BooleanWritable> {
     @Override
     public void compute(Iterable<BooleanWritable> messages) throws IOException {

http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/master/TestMasterObserver.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/master/TestMasterObserver.java b/giraph-core/src/test/java/org/apache/giraph/master/TestMasterObserver.java
index f67a6e0..ba43d8e 100644
--- a/giraph-core/src/test/java/org/apache/giraph/master/TestMasterObserver.java
+++ b/giraph-core/src/test/java/org/apache/giraph/master/TestMasterObserver.java
@@ -18,24 +18,26 @@
 
 package org.apache.giraph.master;
 
+import com.google.common.collect.Maps;
 import org.apache.giraph.conf.GiraphClasses;
 import org.apache.giraph.conf.GiraphConstants;
-import org.apache.giraph.vertex.IntNullNullNullVertex;
 import org.apache.giraph.io.formats.IntNullNullNullTextInputFormat;
 import org.apache.giraph.utils.InternalVertexRunner;
+import org.apache.giraph.edge.ByteArrayEdges;
+import org.apache.giraph.graph.Vertex;
+import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.NullWritable;
 import org.apache.hadoop.util.StringUtils;
 import org.junit.Test;
 
-import com.google.common.collect.Maps;
-
 import java.io.IOException;
 import java.util.Map;
 
 import static org.junit.Assert.assertEquals;
 
 public class TestMasterObserver {
-  public static class NoOpVertex extends IntNullNullNullVertex {
+  public static class NoOpVertex extends Vertex<IntWritable, NullWritable,
+      NullWritable, NullWritable> {
     private int count = 0;
 
     @Override
@@ -90,6 +92,7 @@ public class TestMasterObserver {
 
     GiraphClasses classes = new GiraphClasses();
     classes.setVertexClass(NoOpVertex.class);
+    classes.setVertexEdgesClass(ByteArrayEdges.class);
     classes.setVertexInputFormatClass(IntNullNullNullTextInputFormat.class);
     InternalVertexRunner.run(classes, params, graph);
 

http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/partition/TestGiraphTransferRegulator.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/partition/TestGiraphTransferRegulator.java b/giraph-core/src/test/java/org/apache/giraph/partition/TestGiraphTransferRegulator.java
index 2671708..bdcc49e 100644
--- a/giraph-core/src/test/java/org/apache/giraph/partition/TestGiraphTransferRegulator.java
+++ b/giraph-core/src/test/java/org/apache/giraph/partition/TestGiraphTransferRegulator.java
@@ -17,11 +17,12 @@
  */
 package org.apache.giraph.partition;
 
-import org.apache.giraph.graph.Edge;
-import org.apache.giraph.graph.EdgeFactory;
+import org.apache.giraph.edge.ArrayListEdges;
+import org.apache.giraph.edge.EdgeFactory;
+import org.apache.giraph.edge.VertexEdges;
 import org.apache.giraph.graph.GiraphTransferRegulator;
 import org.apache.giraph.job.GiraphJob;
-import org.apache.giraph.vertex.EdgeListVertex;
+import org.apache.giraph.graph.Vertex;
 import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.FloatWritable;
 import org.apache.hadoop.io.IntWritable;
@@ -29,10 +30,7 @@ import org.apache.hadoop.io.LongWritable;
 import org.junit.Before;
 import org.junit.Test;
 
-import com.google.common.collect.Lists;
-
 import java.io.IOException;
-import java.util.List;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -46,14 +44,13 @@ public class TestGiraphTransferRegulator {
   /** Job filled in by setup() */
   private GiraphJob job;
   /** Instantiated vertex filled in from setup() */
-  private IFDLEdgeListVertex vertex = new IFDLEdgeListVertex();
+  private TestVertex vertex = new TestVertex();
 
   /**
-   * Simple instantiable class that extends
-   * {@link org.apache.giraph.vertex.EdgeListVertex}.
+   * Dummy vertex.
    */
-  public static class IFDLEdgeListVertex extends
-      EdgeListVertex<IntWritable, FloatWritable, DoubleWritable, LongWritable> {
+  public static class TestVertex extends
+      Vertex<IntWritable, FloatWritable, DoubleWritable, LongWritable> {
     @Override
     public void compute(Iterable<LongWritable> messages) throws IOException { }
   }
@@ -65,7 +62,7 @@ public class TestGiraphTransferRegulator {
     } catch (IOException e) {
       throw new RuntimeException("setUp: Failed", e);
     }
-    job.getConfiguration().setVertexClass(IFDLEdgeListVertex.class);
+    job.getConfiguration().setVertexClass(TestVertex.class);
   }
 
   @Test
@@ -74,11 +71,13 @@ public class TestGiraphTransferRegulator {
         .setInt(GiraphTransferRegulator.MAX_VERTICES_PER_TRANSFER, 1);
     job.getConfiguration()
         .setInt(GiraphTransferRegulator.MAX_EDGES_PER_TRANSFER, 3);
-    List<Edge<IntWritable, DoubleWritable>> edges = Lists.newLinkedList();
+    VertexEdges<IntWritable, DoubleWritable> edges =
+        new ArrayListEdges<IntWritable, DoubleWritable>();
+    edges.initialize(3);
     edges.add(EdgeFactory.create(new IntWritable(2), new DoubleWritable(22)));
     edges.add(EdgeFactory.create(new IntWritable(3), new DoubleWritable(33)));
     edges.add(EdgeFactory.create(new IntWritable(4), new DoubleWritable(44)));
-    vertex.initialize(null, null, edges);
+    vertex.initialize(new IntWritable(1), new FloatWritable(1), edges);
     GiraphTransferRegulator gtr =
         new GiraphTransferRegulator(job.getConfiguration());
     PartitionOwner owner = mock(PartitionOwner.class);

http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/partition/TestPartitionStores.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/partition/TestPartitionStores.java b/giraph-core/src/test/java/org/apache/giraph/partition/TestPartitionStores.java
index b4cddf6..d403dd8 100644
--- a/giraph-core/src/test/java/org/apache/giraph/partition/TestPartitionStores.java
+++ b/giraph-core/src/test/java/org/apache/giraph/partition/TestPartitionStores.java
@@ -18,24 +18,20 @@
 
 package org.apache.giraph.partition;
 
+import com.google.common.collect.Iterables;
 import org.apache.giraph.conf.GiraphConfiguration;
 import org.apache.giraph.conf.GiraphConstants;
 import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
-import org.apache.giraph.vertex.IntIntNullIntVertex;
-import org.apache.giraph.vertex.Vertex;
 import org.apache.giraph.utils.UnsafeByteArrayInputStream;
 import org.apache.giraph.utils.UnsafeByteArrayOutputStream;
+import org.apache.giraph.graph.Vertex;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.NullWritable;
 import org.apache.hadoop.mapreduce.Mapper;
 import org.junit.Before;
 import org.junit.Test;
 
-import com.google.common.collect.Iterables;
-
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -46,19 +42,23 @@ import static org.mockito.Mockito.mock;
  * Test case for partition stores.
  */
 public class TestPartitionStores {
-  private ImmutableClassesGiraphConfiguration conf;
+  private ImmutableClassesGiraphConfiguration<IntWritable, IntWritable,
+      NullWritable, IntWritable> conf;
   private Mapper<?, ?, ?, ?>.Context context;
 
-  public static class MyVertex extends IntIntNullIntVertex {
+  public static class MyVertex extends Vertex<IntWritable, IntWritable,
+      NullWritable, IntWritable> {
     @Override
     public void compute(Iterable<IntWritable> messages) throws IOException {}
   }
 
   private Partition<IntWritable, IntWritable, NullWritable,
-        IntWritable> createPartition(ImmutableClassesGiraphConfiguration conf,
-                                   Integer id,
-                                   Vertex<IntWritable, IntWritable,
-                                       NullWritable, IntWritable>... vertices) {
+        IntWritable> createPartition(
+      ImmutableClassesGiraphConfiguration<IntWritable, IntWritable,
+          NullWritable, IntWritable> conf,
+      Integer id,
+      Vertex<IntWritable, IntWritable, NullWritable,
+          IntWritable>... vertices) {
     Partition<IntWritable, IntWritable, NullWritable, IntWritable> partition =
         conf.createPartition(id, context);
     for (Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v :
@@ -72,7 +72,8 @@ public class TestPartitionStores {
   public void setUp() {
     GiraphConfiguration configuration = new GiraphConfiguration();
     configuration.setVertexClass(MyVertex.class);
-    conf = new ImmutableClassesGiraphConfiguration(configuration);
+    conf = new ImmutableClassesGiraphConfiguration<IntWritable, IntWritable,
+        NullWritable, IntWritable>(configuration);
     context = mock(Mapper.Context.class);
   }
 
@@ -89,25 +90,25 @@ public class TestPartitionStores {
   public void testUnsafePartitionSerializationClass() throws IOException {
     conf.setPartitionClass(ByteArrayPartition.class);
     Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v1 =
-        new MyVertex();
+        conf.createVertex();
     v1.initialize(new IntWritable(1), new IntWritable(1));
     Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v2 =
-        new MyVertex();
+        conf.createVertex();
     v2.initialize(new IntWritable(2), new IntWritable(2));
     Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v3 =
-        new MyVertex();
+        conf.createVertex();
     v3.initialize(new IntWritable(3), new IntWritable(3));
     Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v4 =
-        new MyVertex();
+        conf.createVertex();
     v4.initialize(new IntWritable(4), new IntWritable(4));
     Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v5 =
-        new MyVertex();
+        conf.createVertex();
     v5.initialize(new IntWritable(5), new IntWritable(5));
     Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v6 =
-        new MyVertex();
+        conf.createVertex();
     v6.initialize(new IntWritable(6), new IntWritable(6));
     Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v7 =
-        new MyVertex();
+        conf.createVertex();
     v7.initialize(new IntWritable(7), new IntWritable(7));
 
     Partition<IntWritable, IntWritable, NullWritable,
@@ -158,27 +159,28 @@ public class TestPartitionStores {
   public void testReadWrite(
       PartitionStore<IntWritable, IntWritable,
           NullWritable, IntWritable> partitionStore,
-      ImmutableClassesGiraphConfiguration conf) {
+      ImmutableClassesGiraphConfiguration<IntWritable, IntWritable,
+          NullWritable, IntWritable> conf) {
     Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v1 =
-        new MyVertex();
+        conf.createVertex();
     v1.initialize(new IntWritable(1), new IntWritable(1));
     Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v2 =
-        new MyVertex();
+        conf.createVertex();
     v2.initialize(new IntWritable(2), new IntWritable(2));
     Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v3 =
-        new MyVertex();
+        conf.createVertex();
     v3.initialize(new IntWritable(3), new IntWritable(3));
     Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v4 =
-        new MyVertex();
+        conf.createVertex();
     v4.initialize(new IntWritable(4), new IntWritable(4));
     Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v5 =
-        new MyVertex();
+        conf.createVertex();
     v5.initialize(new IntWritable(5), new IntWritable(5));
     Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v6 =
-        new MyVertex();
+        conf.createVertex();
     v6.initialize(new IntWritable(7), new IntWritable(7));
     Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v7 =
-        new MyVertex();
+        conf.createVertex();
     v7.initialize(new IntWritable(7), new IntWritable(7));
 
     partitionStore.addPartition(createPartition(conf, 1, v1, v2));

http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/utils/ComparisonUtilsTest.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/utils/ComparisonUtilsTest.java b/giraph-core/src/test/java/org/apache/giraph/utils/ComparisonUtilsTest.java
deleted file mode 100644
index 789c9ee..0000000
--- a/giraph-core/src/test/java/org/apache/giraph/utils/ComparisonUtilsTest.java
+++ /dev/null
@@ -1,75 +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.utils;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-import com.google.common.collect.Lists;
-
-public class ComparisonUtilsTest {
-
-    @Test
-    public void testEquality() {
-        Iterable<String> one = Lists.newArrayList("one", "two", "three");
-        Iterable<String> two = Lists.newArrayList("one", "two", "three");
-
-        assertTrue(ComparisonUtils.equal(one, one));
-        assertTrue(ComparisonUtils.equal(one, two));
-        assertTrue(ComparisonUtils.equal(two, two));
-        assertTrue(ComparisonUtils.equal(two, one));
-    }
-
-    @Test
-    public void testEqualityEmpty() {
-        Iterable<String> one = Lists.newArrayList();
-        Iterable<String> two = Lists.newArrayList();
-
-        assertTrue(ComparisonUtils.equal(one, one));
-        assertTrue(ComparisonUtils.equal(one, two));
-        assertTrue(ComparisonUtils.equal(two, two));
-        assertTrue(ComparisonUtils.equal(two, one));
-    }
-
-    @Test
-    public void testInEquality() {
-        Iterable<String> one = Lists.newArrayList("one", "two", "three");
-        Iterable<String> two = Lists.newArrayList("two", "three", "four");
-        Iterable<String> three = Lists.newArrayList();
-
-        assertFalse(ComparisonUtils.equal(one, two));
-        assertFalse(ComparisonUtils.equal(one, three));
-        assertFalse(ComparisonUtils.equal(two, one));
-        assertFalse(ComparisonUtils.equal(two, three));
-        assertFalse(ComparisonUtils.equal(three, one));
-        assertFalse(ComparisonUtils.equal(three, two));
-    }
-
-    @Test
-    public void testInEqualityDifferentLengths() {
-        Iterable<String> one = Lists.newArrayList("one", "two", "three");
-        Iterable<String> two = Lists.newArrayList("one", "two", "three", "four");
-
-        assertFalse(ComparisonUtils.equal(one, two));
-        assertFalse(ComparisonUtils.equal(two, one));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/utils/MockUtils.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/utils/MockUtils.java b/giraph-core/src/test/java/org/apache/giraph/utils/MockUtils.java
index 04c7a3c..3a0e144 100644
--- a/giraph-core/src/test/java/org/apache/giraph/utils/MockUtils.java
+++ b/giraph-core/src/test/java/org/apache/giraph/utils/MockUtils.java
@@ -18,15 +18,18 @@
 
 package org.apache.giraph.utils;
 
-import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
 import org.apache.giraph.bsp.CentralizedServiceWorker;
 import org.apache.giraph.comm.ServerData;
 import org.apache.giraph.comm.WorkerClientRequestProcessor;
 import org.apache.giraph.comm.messages.ByteArrayMessagesPerVertexStore;
-import org.apache.giraph.vertex.Vertex;
+import org.apache.giraph.conf.GiraphConfiguration;
+import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
 import org.apache.giraph.graph.GraphState;
 import org.apache.giraph.partition.BasicPartitionOwner;
 import org.apache.giraph.partition.PartitionOwner;
+import org.apache.giraph.edge.ArrayListEdges;
+import org.apache.giraph.edge.ConfigurableVertexEdges;
+import org.apache.giraph.graph.Vertex;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.Writable;
@@ -131,8 +134,18 @@ public class MockUtils {
         Mockito.when(env.getGraphState().getWorkerClientRequestProcessor())
                 .thenReturn(env.getWorkerClientRequestProcessor());
 
+        GiraphConfiguration giraphConf = new GiraphConfiguration();
+        giraphConf.setVertexClass(vertex.getClass());
+        ImmutableClassesGiraphConfiguration<I, V, E, M> conf =
+            new ImmutableClassesGiraphConfiguration<I, V, E, M>(giraphConf);
+        vertex.setConf(conf);
+        ConfigurableVertexEdges<I, E> edges = new ArrayListEdges<I, E>();
+        edges.setConf(conf);
+        edges.initialize();
+
         ReflectionUtils.setField(vertex, "id", vertexId);
         ReflectionUtils.setField(vertex, "value", vertexValue);
+        ReflectionUtils.setField(vertex, "edges", edges);
         ReflectionUtils.setField(vertex, "graphState", env.getGraphState());
         ReflectionUtils.setField(vertex, "halt", isHalted);
 

http://git-wip-us.apache.org/repos/asf/giraph/blob/3f5009ae/giraph-core/src/test/java/org/apache/giraph/vertex/TestIntIntNullIntVertex.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/test/java/org/apache/giraph/vertex/TestIntIntNullIntVertex.java b/giraph-core/src/test/java/org/apache/giraph/vertex/TestIntIntNullIntVertex.java
deleted file mode 100644
index 37e8768..0000000
--- a/giraph-core/src/test/java/org/apache/giraph/vertex/TestIntIntNullIntVertex.java
+++ /dev/null
@@ -1,78 +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.vertex;
-
-import org.apache.giraph.graph.Edge;
-import org.apache.giraph.graph.EdgeFactory;
-import org.apache.hadoop.io.IntWritable;
-import org.apache.hadoop.io.NullWritable;
-import org.junit.Test;
-
-import com.google.common.collect.Lists;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInput;
-import java.io.DataInputStream;
-import java.io.DataOutput;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests {@link org.apache.giraph.vertex.IntIntNullIntVertex}.
- */
-public class TestIntIntNullIntVertex {
-  /**
-   * Simple instantiable class that extends {@link org.apache.giraph.vertex.IntIntNullIntVertex}.
-   */
-  private static class MyIntIntNullVertex extends IntIntNullIntVertex {
-    @Override
-    public void compute(Iterable<IntWritable> messages) throws IOException {
-    }
-  }
-
-  @Test
-  public void testSerialize() throws IOException {
-    IntIntNullIntVertex vertex = new MyIntIntNullVertex();
-
-    List<Edge<IntWritable, NullWritable>> edges = Lists.newLinkedList();
-    edges.add(EdgeFactory.create(new IntWritable(3)));
-    edges.add(EdgeFactory.create(new IntWritable(47)));
-
-    vertex.initialize(new IntWritable(23), new IntWritable(7), edges);
-    vertex.voteToHalt();
-
-    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-    DataOutput out = new DataOutputStream(outStream);
-    vertex.write(out);
-
-    IntIntNullIntVertex vertex1 = new MyIntIntNullVertex();
-
-    ByteArrayInputStream inStream = new ByteArrayInputStream(
-        outStream.toByteArray());
-    DataInput in = new DataInputStream(inStream);
-    vertex1.readFields(in);
-
-    assertEquals(2, vertex1.getNumEdges());
-    assertEquals(true, vertex1.isHalted());
-  }
-}


Mime
View raw message