[GIRAPH-1041] Generate primitive type specific code

Summary:
- Use FreeMarker library to generate primitive type specific code.
Initially generating three sets of files:
{TYPE}Consumer, {TYPE}TypeOps and W{TYPE}ArrayList

Right now generation happens manually, and generated files are being committed.
In the future we can move those to a separate project, and have them generated
when maven is compiling and deploying.

Additionally to generation change, BasicArrayList is renamed to WArrayList and
directly extends fastutil implementation, to now serves two purposes:
- generic handling of efficient arrays through TypeOps
- extended fastutil class - to make it writtable, to add useful Java8 methods,
  or anything else we can think of. Since we are just extending it, and there is
  no efficiency penalty, we can always use WLongArrayList instead of 
LongArrayList.

There is additional WReusableLongArrayList, which when readFields is called,
doesn't size it to exact size, but reuses the old length.

Test Plan:
mvn clean install

There are no changes in logic in this diff. Will send a small separate diff
with some examples of what is now simpler.

Reviewers: sergey.edunov, dionysis.logothetis, spupyrev, maja.kabiljo

Differential Revision: https://reviews.facebook.net/D52515


Project: http://git-wip-us.apache.org/repos/asf/giraph/repo
Commit: http://git-wip-us.apache.org/repos/asf/giraph/commit/77ae12e0
Tree: http://git-wip-us.apache.org/repos/asf/giraph/tree/77ae12e0
Diff: http://git-wip-us.apache.org/repos/asf/giraph/diff/77ae12e0

Branch: refs/heads/trunk
Commit: 77ae12e00e6e0b4955949bc71e9b275bd6d70538
Parents: bac93fa
Author: Igor Kabiljo <[email protected]>
Authored: Tue Mar 15 14:41:35 2016 -0700
Committer: Igor Kabiljo <[email protected]>
Committed: Mon Apr 11 18:15:05 2016 -0700

----------------------------------------------------------------------
 .../reducers/array/BasicArrayReduce.java        |  42 +-
 .../reducers/array/HugeArrayUtils.java          |  16 +-
 .../CollectPrimitiveReduceOperation.java        |  20 +-
 .../CollectShardedPrimitiveReducerHandle.java   |  18 +-
 ...tShardedTuplesOfPrimitivesReducerHandle.java |  26 +-
 ...ollectTuplesOfPrimitivesReduceOperation.java |  20 +-
 .../apache/giraph/edge/IdAndNullArrayEdges.java |  14 +-
 .../giraph/edge/IdAndValueArrayEdges.java       |  30 +-
 .../function/primitive/BooleanPredicate.java    |  37 +
 .../function/primitive/BytePredicate.java       |  37 +
 .../function/primitive/DoublePredicate.java     |  37 +
 .../function/primitive/FloatPredicate.java      |  37 +
 .../giraph/function/primitive/IntPredicate.java |  37 +
 .../function/primitive/LongPredicate.java       |  37 +
 .../function/primitive/Obj2ShortFunction.java   |  39 +
 .../function/primitive/ShortConsumer.java       |  36 +
 .../function/primitive/ShortPredicate.java      |  37 +
 .../apache/giraph/types/ops/BooleanTypeOps.java |  25 +-
 .../apache/giraph/types/ops/ByteTypeOps.java    |  30 +-
 .../apache/giraph/types/ops/DoubleTypeOps.java  |  28 +-
 .../apache/giraph/types/ops/FloatTypeOps.java   |  27 +-
 .../org/apache/giraph/types/ops/IntTypeOps.java |  36 +-
 .../apache/giraph/types/ops/LongTypeOps.java    |  36 +-
 .../giraph/types/ops/PrimitiveTypeOps.java      |  24 +-
 .../types/ops/collections/BasicArrayList.java   | 813 -------------------
 .../ops/collections/WBooleanCollection.java     |  51 ++
 .../types/ops/collections/WByteCollection.java  |  51 ++
 .../types/ops/collections/WCollection.java      | 120 +++
 .../ops/collections/WDoubleCollection.java      |  51 ++
 .../types/ops/collections/WFloatCollection.java |  51 ++
 .../types/ops/collections/WIntCollection.java   |  51 ++
 .../types/ops/collections/WLongCollection.java  |  51 ++
 .../types/ops/collections/array/WArrayList.java |  73 ++
 .../array/WArrayListPrivateUtils.java           | 122 +++
 .../collections/array/WBooleanArrayList.java    | 305 +++++++
 .../ops/collections/array/WByteArrayList.java   | 305 +++++++
 .../ops/collections/array/WDoubleArrayList.java | 305 +++++++
 .../ops/collections/array/WFloatArrayList.java  | 305 +++++++
 .../ops/collections/array/WIntArrayList.java    | 305 +++++++
 .../ops/collections/array/WLongArrayList.java   | 305 +++++++
 .../ops/collections/array/package-info.java     |  22 +
 .../apache/giraph/writable/kryo/HadoopKryo.java |   9 +-
 .../generate/GeneratePrimitiveClasses.java      |  97 ++-
 .../apache/giraph/types/TestCollections.java    |   8 +-
 .../kryo/DirectWritableSerializerCopyTest.java  |  25 +-
 .../giraph/writable/kryo/KryoWritableTest.java  |  18 +-
 .../writable/kryo/KryoWritableWrapperTest.java  |  27 +-
 giraph-core/templates/TypePredicate.java        |  36 +
 giraph-core/templates/TypeTypeOps.java          | 147 ++++
 giraph-core/templates/WTypeArrayList.java       | 304 +++++++
 giraph-core/templates/WTypeCollection.java      |  50 ++
 51 files changed, 3681 insertions(+), 1052 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/array/BasicArrayReduce.java
----------------------------------------------------------------------
diff --git 
a/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/array/BasicArrayReduce.java
 
b/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/array/BasicArrayReduce.java
index 91ced16..352e693 100644
--- 
a/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/array/BasicArrayReduce.java
+++ 
b/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/array/BasicArrayReduce.java
@@ -35,7 +35,7 @@ import org.apache.giraph.master.MasterGlobalCommUsage;
 import org.apache.giraph.reducers.ReduceOperation;
 import org.apache.giraph.types.ops.PrimitiveTypeOps;
 import org.apache.giraph.types.ops.TypeOpsUtils;
-import org.apache.giraph.types.ops.collections.BasicArrayList;
+import org.apache.giraph.types.ops.collections.array.WArrayList;
 import org.apache.giraph.utils.WritableUtils;
 import org.apache.giraph.worker.WorkerBroadcastUsage;
 import org.apache.hadoop.io.Writable;
@@ -50,7 +50,7 @@ import org.apache.hadoop.io.Writable;
  * @param <R> Reduced value type
  */
 public class BasicArrayReduce<S, R extends Writable>
-    implements ReduceOperation<Pair<IntRef, S>, BasicArrayList<R>> {
+    implements ReduceOperation<Pair<IntRef, S>, WArrayList<R>> {
   private int fixedSize;
   private PrimitiveTypeOps<R> typeOps;
   private ReduceOperation<S, R> elementReduceOp;
@@ -182,7 +182,7 @@ public class BasicArrayReduce<S, R extends Writable>
       final int fixedSize, final PrimitiveTypeOps<R> typeOps,
       ReduceOperation<S, R> elementReduceOp,
       CreateReducerFunctionApi createFunction) {
-    final ReducerHandle<Pair<IntRef, S>, BasicArrayList<R>> reduceHandle =
+    final ReducerHandle<Pair<IntRef, S>, WArrayList<R>> reduceHandle =
         createFunction.createReducer(
             new BasicArrayReduce<>(fixedSize, typeOps, elementReduceOp));
     final IntRef curIndex = new IntRef(0);
@@ -193,11 +193,11 @@ public class BasicArrayReduce<S, R extends Writable>
     final ReducerHandle<S, R> elementReduceHandle = new ReducerHandle<S, R>() {
       @Override
       public R getReducedValue(MasterGlobalCommUsage master) {
-        BasicArrayList<R> result = reduceHandle.getReducedValue(master);
+        WArrayList<R> result = reduceHandle.getReducedValue(master);
         if (fixedSize == -1 && curIndex.value >= result.size()) {
           typeOps.set(reusableValue, initialValue);
         } else {
-          result.getInto(curIndex.value, reusableValue);
+          result.getIntoW(curIndex.value, reusableValue);
         }
         return reusableValue;
       }
@@ -238,7 +238,7 @@ public class BasicArrayReduce<S, R extends Writable>
 
       @Override
       public BroadcastArrayHandle<R> broadcastValue(BlockMasterApi master) {
-        final BroadcastHandle<BasicArrayList<R>> broadcastHandle =
+        final BroadcastHandle<WArrayList<R>> broadcastHandle =
             reduceHandle.broadcastValue(master);
         final IntRef curIndex = new IntRef(0);
         final R reusableValue = typeOps.create();
@@ -246,11 +246,11 @@ public class BasicArrayReduce<S, R extends Writable>
         elementBroadcastHandle = new BroadcastHandle<R>() {
           @Override
           public R getBroadcast(WorkerBroadcastUsage worker) {
-            BasicArrayList<R> result = broadcastHandle.getBroadcast(worker);
+            WArrayList<R> result = broadcastHandle.getBroadcast(worker);
             if (fixedSize == -1 && curIndex.value >= result.size()) {
               typeOps.set(reusableValue, initialValue);
             } else {
-              result.getInto(curIndex.value, reusableValue);
+              result.getIntoW(curIndex.value, reusableValue);
             }
             return reusableValue;
           }
@@ -288,9 +288,9 @@ public class BasicArrayReduce<S, R extends Writable>
   }
 
   @Override
-  public BasicArrayList<R> createInitialValue() {
+  public WArrayList<R> createInitialValue() {
     if (fixedSize != -1) {
-      BasicArrayList<R> list = typeOps.createArrayList(fixedSize);
+      WArrayList<R> list = typeOps.createArrayList(fixedSize);
       fill(list, fixedSize);
       return list;
     } else {
@@ -298,7 +298,7 @@ public class BasicArrayReduce<S, R extends Writable>
     }
   }
 
-  private void fill(BasicArrayList<R> list, int newSize) {
+  private void fill(WArrayList<R> list, int newSize) {
     if (fixedSize != -1 && newSize > fixedSize) {
       throw new IllegalArgumentException(newSize + " larger then " + 
fixedSize);
     }
@@ -307,30 +307,30 @@ public class BasicArrayReduce<S, R extends Writable>
       list.setCapacity(newSize);
     }
     while (list.size() < newSize) {
-      list.add(initialElement);
+      list.addW(initialElement);
     }
   }
 
   @Override
-  public BasicArrayList<R> reduce(
-      BasicArrayList<R> curValue, Pair<IntRef, S> valueToReduce) {
+  public WArrayList<R> reduce(
+      WArrayList<R> curValue, Pair<IntRef, S> valueToReduce) {
     int index = valueToReduce.getLeft().value;
     fill(curValue, index + 1);
-    curValue.getInto(index, reusable);
+    curValue.getIntoW(index, reusable);
     R result = elementReduceOp.reduce(reusable, valueToReduce.getRight());
-    curValue.set(index, result);
+    curValue.setW(index, result);
     return curValue;
   }
 
   @Override
-  public BasicArrayList<R> reduceMerge(
-      BasicArrayList<R> curValue, BasicArrayList<R> valueToReduce) {
+  public WArrayList<R> reduceMerge(
+      WArrayList<R> curValue, WArrayList<R> valueToReduce) {
     fill(curValue, valueToReduce.size());
     for (int i = 0; i < valueToReduce.size(); i++) {
-      valueToReduce.getInto(i, reusable2);
-      curValue.getInto(i, reusable);
+      valueToReduce.getIntoW(i, reusable2);
+      curValue.getIntoW(i, reusable);
       R result = elementReduceOp.reduceMerge(reusable, reusable2);
-      curValue.set(i, result);
+      curValue.setW(i, result);
     }
 
     return curValue;

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/array/HugeArrayUtils.java
----------------------------------------------------------------------
diff --git 
a/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/array/HugeArrayUtils.java
 
b/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/array/HugeArrayUtils.java
index 815cbfa..e74f37e 100644
--- 
a/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/array/HugeArrayUtils.java
+++ 
b/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/array/HugeArrayUtils.java
@@ -36,7 +36,7 @@ import 
org.apache.giraph.function.primitive.PrimitiveRefs.IntRef;
 import org.apache.giraph.reducers.ReduceOperation;
 import org.apache.giraph.types.ops.PrimitiveTypeOps;
 import org.apache.giraph.types.ops.TypeOpsUtils;
-import org.apache.giraph.types.ops.collections.BasicArrayList;
+import org.apache.giraph.types.ops.collections.array.WArrayList;
 import org.apache.giraph.utils.ArrayWritable;
 import org.apache.giraph.worker.WorkerBroadcastUsage;
 import org.apache.hadoop.io.Writable;
@@ -300,30 +300,30 @@ public class HugeArrayUtils {
   Int2ObjFunction<BroadcastHandle<V>> getPrimitiveBroadcastHandleSupplier(
       final Int2ObjFunction<V> valueSupplier, final PrimitiveTypeOps<V> 
typeOps,
       final BlockMasterApi master, final ObjectStriping striping) {
-    final ArrayOfHandles<BroadcastHandle<BasicArrayList<V>>> arrayOfBroadcasts 
=
+    final ArrayOfHandles<BroadcastHandle<WArrayList<V>>> arrayOfBroadcasts =
       new ArrayOfHandles<>(
         striping.getSplits(),
-        new Int2ObjFunction<BroadcastHandle<BasicArrayList<V>>>() {
+        new Int2ObjFunction<BroadcastHandle<WArrayList<V>>>() {
           @Override
-          public BroadcastHandle<BasicArrayList<V>> apply(int value) {
+          public BroadcastHandle<WArrayList<V>> apply(int value) {
             int size = striping.getSplitSize(value);
             int start = striping.getSplitStart(value);
-            BasicArrayList<V> array = typeOps.createArrayList(size);
+            WArrayList<V> array = typeOps.createArrayList(size);
             for (int i = 0; i < size; i++) {
-              array.add(valueSupplier.apply(start + i));
+              array.addW(valueSupplier.apply(start + i));
             }
             return master.broadcast(array);
           }
         });
 
     final IntRef insideIndex = new IntRef(-1);
-    final ObjectHolder<BroadcastHandle<BasicArrayList<V>>> handleHolder =
+    final ObjectHolder<BroadcastHandle<WArrayList<V>>> handleHolder =
             new ObjectHolder<>();
     final BroadcastHandle<V> reusableHandle = new BroadcastHandle<V>() {
       private final V reusable = typeOps.create();
       @Override
       public V getBroadcast(WorkerBroadcastUsage worker) {
-        handleHolder.get().getBroadcast(worker).getInto(
+        handleHolder.get().getBroadcast(worker).getIntoW(
             insideIndex.value, reusable);
         return reusable;
       }

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectPrimitiveReduceOperation.java
----------------------------------------------------------------------
diff --git 
a/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectPrimitiveReduceOperation.java
 
b/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectPrimitiveReduceOperation.java
index 13dd153..f6846f3 100644
--- 
a/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectPrimitiveReduceOperation.java
+++ 
b/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectPrimitiveReduceOperation.java
@@ -24,8 +24,8 @@ import java.io.IOException;
 import org.apache.giraph.reducers.impl.KryoWrappedReduceOperation;
 import org.apache.giraph.types.ops.PrimitiveTypeOps;
 import org.apache.giraph.types.ops.TypeOpsUtils;
-import org.apache.giraph.types.ops.collections.BasicArrayList;
 import org.apache.giraph.types.ops.collections.ResettableIterator;
+import org.apache.giraph.types.ops.collections.array.WArrayList;
 import org.apache.giraph.utils.WritableUtils;
 
 /**
@@ -34,7 +34,7 @@ import org.apache.giraph.utils.WritableUtils;
  * @param <S> Primitive Writable type, which has its type ops
  */
 public class CollectPrimitiveReduceOperation<S>
-    extends KryoWrappedReduceOperation<S, BasicArrayList<S>> {
+    extends KryoWrappedReduceOperation<S, WArrayList<S>> {
   /**
    * Type ops if available, or null
    */
@@ -49,25 +49,25 @@ public class CollectPrimitiveReduceOperation<S>
   }
 
   @Override
-  public BasicArrayList<S> createValue() {
+  public WArrayList<S> createValue() {
     return createList();
   }
 
   @Override
-  public void reduce(BasicArrayList<S> reduceInto, S value) {
-    reduceInto.add(value);
+  public void reduce(WArrayList<S> reduceInto, S value) {
+    reduceInto.addW(value);
   }
 
   @Override
-  public void reduceMerge(BasicArrayList<S> reduceInto,
-      BasicArrayList<S> toReduce) {
-    ResettableIterator<S> iterator = toReduce.fastIterator();
+  public void reduceMerge(final WArrayList<S> reduceInto,
+      WArrayList<S> toReduce) {
+    ResettableIterator<S> iterator = toReduce.fastIteratorW();
     while (iterator.hasNext()) {
-      reduceInto.add(iterator.next());
+      reduceInto.addW(iterator.next());
     }
   }
 
-  public BasicArrayList<S> createList() {
+  public WArrayList<S> createList() {
     return typeOps.createArrayList();
   }
 

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectShardedPrimitiveReducerHandle.java
----------------------------------------------------------------------
diff --git 
a/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectShardedPrimitiveReducerHandle.java
 
b/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectShardedPrimitiveReducerHandle.java
index b29b297..40a0d5d 100644
--- 
a/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectShardedPrimitiveReducerHandle.java
+++ 
b/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectShardedPrimitiveReducerHandle.java
@@ -24,7 +24,7 @@ import org.apache.giraph.master.MasterGlobalCommUsage;
 import org.apache.giraph.reducers.ReduceOperation;
 import org.apache.giraph.types.ops.PrimitiveTypeOps;
 import org.apache.giraph.types.ops.TypeOpsUtils;
-import org.apache.giraph.types.ops.collections.BasicArrayList;
+import org.apache.giraph.types.ops.collections.array.WArrayList;
 import org.apache.giraph.worker.WorkerBroadcastUsage;
 import org.apache.giraph.writable.kryo.KryoWritableWrapper;
 
@@ -35,7 +35,7 @@ import org.apache.giraph.writable.kryo.KryoWritableWrapper;
  * @param <S> Single value type
  */
 public class CollectShardedPrimitiveReducerHandle<S>
-    extends ShardedReducerHandle<S, BasicArrayList<S>> {
+    extends ShardedReducerHandle<S, WArrayList<S>> {
   /**
    * Type ops if available, or null
    */
@@ -48,13 +48,13 @@ public class CollectShardedPrimitiveReducerHandle<S>
   }
 
   @Override
-  public ReduceOperation<S, KryoWritableWrapper<BasicArrayList<S>>>
+  public ReduceOperation<S, KryoWritableWrapper<WArrayList<S>>>
   createReduceOperation() {
     return new CollectPrimitiveReduceOperation<>(typeOps);
   }
 
   @Override
-  public BasicArrayList<S> createReduceResult(MasterGlobalCommUsage master) {
+  public WArrayList<S> createReduceResult(MasterGlobalCommUsage master) {
     int size = 0;
     for (int i = 0; i < REDUCER_COUNT; i++) {
       size += reducers.get(i).getReducedValue(master).get().size();
@@ -62,13 +62,13 @@ public class CollectShardedPrimitiveReducerHandle<S>
     return createList(size);
   }
 
-  public BasicArrayList<S> createList(int size) {
+  public WArrayList<S> createList(int size) {
     return typeOps.createArrayList(size);
   }
 
   @Override
-  public BroadcastHandle<BasicArrayList<S>> createBroadcastHandle(
-      BroadcastArrayHandle<KryoWritableWrapper<BasicArrayList<S>>> broadcasts) 
{
+  public BroadcastHandle<WArrayList<S>> createBroadcastHandle(
+      BroadcastArrayHandle<KryoWritableWrapper<WArrayList<S>>> broadcasts) {
     return new CollectShardedPrimitiveBroadcastHandle(broadcasts);
   }
 
@@ -78,13 +78,13 @@ public class CollectShardedPrimitiveReducerHandle<S>
   public class CollectShardedPrimitiveBroadcastHandle
       extends ShardedBroadcastHandle {
     public CollectShardedPrimitiveBroadcastHandle(
-        BroadcastArrayHandle<KryoWritableWrapper<BasicArrayList<S>>>
+        BroadcastArrayHandle<KryoWritableWrapper<WArrayList<S>>>
             broadcasts) {
       super(broadcasts);
     }
 
     @Override
-    public BasicArrayList<S> createBroadcastResult(
+    public WArrayList<S> createBroadcastResult(
         WorkerBroadcastUsage worker) {
       int size = 0;
       for (int i = 0; i < REDUCER_COUNT; i++) {

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectShardedTuplesOfPrimitivesReducerHandle.java
----------------------------------------------------------------------
diff --git 
a/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectShardedTuplesOfPrimitivesReducerHandle.java
 
b/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectShardedTuplesOfPrimitivesReducerHandle.java
index 3222c17..fdf7aba 100644
--- 
a/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectShardedTuplesOfPrimitivesReducerHandle.java
+++ 
b/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectShardedTuplesOfPrimitivesReducerHandle.java
@@ -28,7 +28,7 @@ import org.apache.giraph.master.MasterGlobalCommUsage;
 import org.apache.giraph.reducers.ReduceOperation;
 import org.apache.giraph.types.ops.PrimitiveTypeOps;
 import org.apache.giraph.types.ops.TypeOpsUtils;
-import org.apache.giraph.types.ops.collections.BasicArrayList;
+import org.apache.giraph.types.ops.collections.array.WArrayList;
 import org.apache.giraph.worker.WorkerBroadcastUsage;
 import org.apache.giraph.writable.kryo.KryoWritableWrapper;
 
@@ -39,7 +39,7 @@ import org.apache.giraph.writable.kryo.KryoWritableWrapper;
  */
 @SuppressWarnings("unchecked")
 public class CollectShardedTuplesOfPrimitivesReducerHandle
-extends ShardedReducerHandle<List<Object>, List<BasicArrayList>> {
+extends ShardedReducerHandle<List<Object>, List<WArrayList>> {
   /**
    * Type ops if available, or null
    */
@@ -64,12 +64,12 @@ extends ShardedReducerHandle<List<Object>, 
List<BasicArrayList>> {
 
   @Override
   public ReduceOperation<List<Object>,
-      KryoWritableWrapper<List<BasicArrayList>>> createReduceOperation() {
+      KryoWritableWrapper<List<WArrayList>>> createReduceOperation() {
     return new CollectTuplesOfPrimitivesReduceOperation(typeOpsList);
   }
 
   @Override
-  public List<BasicArrayList> createReduceResult(
+  public List<WArrayList> createReduceResult(
       MasterGlobalCommUsage master) {
     int size = 0;
     for (int i = 0; i < REDUCER_COUNT; i++) {
@@ -78,8 +78,8 @@ extends ShardedReducerHandle<List<Object>, 
List<BasicArrayList>> {
     return createLists(size);
   }
 
-  public List<BasicArrayList> createLists(int size) {
-    List<BasicArrayList> ret = new ArrayList<>();
+  public List<WArrayList> createLists(int size) {
+    List<WArrayList> ret = new ArrayList<>();
     for (PrimitiveTypeOps typeOps : typeOpsList) {
       ret.add(typeOps.createArrayList(size));
     }
@@ -87,8 +87,8 @@ extends ShardedReducerHandle<List<Object>, 
List<BasicArrayList>> {
   }
 
   @Override
-  public BroadcastHandle<List<BasicArrayList>> createBroadcastHandle(
-      BroadcastArrayHandle<KryoWritableWrapper<List<BasicArrayList>>>
+  public BroadcastHandle<List<WArrayList>> createBroadcastHandle(
+      BroadcastArrayHandle<KryoWritableWrapper<List<WArrayList>>>
           broadcasts) {
     return new CollectShardedTuplesOfPrimitivesBroadcastHandle(broadcasts);
   }
@@ -99,13 +99,13 @@ extends ShardedReducerHandle<List<Object>, 
List<BasicArrayList>> {
   public class CollectShardedTuplesOfPrimitivesBroadcastHandle
       extends ShardedBroadcastHandle {
     public CollectShardedTuplesOfPrimitivesBroadcastHandle(
-        BroadcastArrayHandle<KryoWritableWrapper<List<BasicArrayList>>>
+        BroadcastArrayHandle<KryoWritableWrapper<List<WArrayList>>>
             broadcasts) {
       super(broadcasts);
     }
 
     @Override
-    public List<BasicArrayList> createBroadcastResult(
+    public List<WArrayList> createBroadcastResult(
         WorkerBroadcastUsage worker) {
       int size = 0;
       for (int i = 0; i < REDUCER_COUNT; i++) {
@@ -120,7 +120,7 @@ extends ShardedReducerHandle<List<Object>, 
List<BasicArrayList>> {
    */
   public static class CollectShardedTuplesOfPrimitivesReduceBroadcast {
     private CollectShardedTuplesOfPrimitivesReducerHandle reducerHandle;
-    private BroadcastHandle<List<BasicArrayList>> broadcastHandle;
+    private BroadcastHandle<List<WArrayList>> broadcastHandle;
 
     /** Set reducer handle to just registered handle */
     public void registeredReducer(CreateReducersApi reduceApi,
@@ -139,7 +139,7 @@ extends ShardedReducerHandle<List<Object>, 
List<BasicArrayList>> {
     }
 
     /** Get reduced value */
-    public List<BasicArrayList> getReducedValue(MasterGlobalCommUsage master) {
+    public List<WArrayList> getReducedValue(MasterGlobalCommUsage master) {
       return reducerHandle.getReducedValue(master);
     }
 
@@ -151,7 +151,7 @@ extends ShardedReducerHandle<List<Object>, 
List<BasicArrayList>> {
     }
 
     /** Get broadcasted value */
-    public List<BasicArrayList> getBroadcast(WorkerBroadcastUsage worker) {
+    public List<WArrayList> getBroadcast(WorkerBroadcastUsage worker) {
       return broadcastHandle.getBroadcast(worker);
     }
   }

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectTuplesOfPrimitivesReduceOperation.java
----------------------------------------------------------------------
diff --git 
a/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectTuplesOfPrimitivesReduceOperation.java
 
b/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectTuplesOfPrimitivesReduceOperation.java
index afaba7a..4e17bf0 100644
--- 
a/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectTuplesOfPrimitivesReduceOperation.java
+++ 
b/giraph-block-app/src/main/java/org/apache/giraph/block_app/reducers/collect/CollectTuplesOfPrimitivesReduceOperation.java
@@ -26,15 +26,15 @@ import java.util.List;
 import org.apache.giraph.reducers.impl.KryoWrappedReduceOperation;
 import org.apache.giraph.types.ops.PrimitiveTypeOps;
 import org.apache.giraph.types.ops.TypeOpsUtils;
-import org.apache.giraph.types.ops.collections.BasicArrayList;
 import org.apache.giraph.types.ops.collections.ResettableIterator;
+import org.apache.giraph.types.ops.collections.array.WArrayList;
 import org.apache.giraph.utils.WritableUtils;
 
 /**
  * Collect tuples of primitive values reduce operation
  */
 public class CollectTuplesOfPrimitivesReduceOperation
-    extends KryoWrappedReduceOperation<List<Object>, List<BasicArrayList>> {
+    extends KryoWrappedReduceOperation<List<Object>, List<WArrayList>> {
   /**
    * Type ops if available, or null
    */
@@ -50,8 +50,8 @@ public class CollectTuplesOfPrimitivesReduceOperation
   }
 
   @Override
-  public List<BasicArrayList> createValue() {
-    List<BasicArrayList> ret = new ArrayList<>(typeOpsList.size());
+  public List<WArrayList> createValue() {
+    List<WArrayList> ret = new ArrayList<>(typeOpsList.size());
     for (PrimitiveTypeOps typeOps : typeOpsList) {
       ret.add(typeOps.createArrayList());
     }
@@ -59,19 +59,19 @@ public class CollectTuplesOfPrimitivesReduceOperation
   }
 
   @Override
-  public void reduce(List<BasicArrayList> reduceInto, List<Object> value) {
+  public void reduce(List<WArrayList> reduceInto, List<Object> value) {
     for (int i = 0; i < reduceInto.size(); i++) {
-      reduceInto.get(i).add(value.get(i));
+      reduceInto.get(i).addW(value.get(i));
     }
   }
 
   @Override
-  public void reduceMerge(List<BasicArrayList> reduceInto,
-      List<BasicArrayList> toReduce) {
+  public void reduceMerge(final List<WArrayList> reduceInto,
+      List<WArrayList> toReduce) {
     for (int i = 0; i < reduceInto.size(); i++) {
-      ResettableIterator iterator = toReduce.get(i).fastIterator();
+      ResettableIterator iterator = toReduce.get(i).fastIteratorW();
       while (iterator.hasNext()) {
-        reduceInto.get(i).add(iterator.next());
+        reduceInto.get(i).addW(iterator.next());
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-core/src/main/java/org/apache/giraph/edge/IdAndNullArrayEdges.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/edge/IdAndNullArrayEdges.java 
b/giraph-core/src/main/java/org/apache/giraph/edge/IdAndNullArrayEdges.java
index 7de5d2a..0799c64 100644
--- a/giraph-core/src/main/java/org/apache/giraph/edge/IdAndNullArrayEdges.java
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/IdAndNullArrayEdges.java
@@ -26,7 +26,7 @@ import 
org.apache.giraph.conf.ImmutableClassesGiraphConfigurable;
 import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
 import org.apache.giraph.types.ops.PrimitiveIdTypeOps;
 import org.apache.giraph.types.ops.TypeOpsUtils;
-import org.apache.giraph.types.ops.collections.BasicArrayList;
+import org.apache.giraph.types.ops.collections.array.WArrayList;
 import org.apache.giraph.utils.EdgeIterables;
 import org.apache.hadoop.io.NullWritable;
 import org.apache.hadoop.io.Writable;
@@ -47,7 +47,7 @@ public class IdAndNullArrayEdges<I extends WritableComparable>
   ImmutableClassesGiraphConfigurable<I, Writable, NullWritable> {
 
   /** Array of target vertex ids. */
-  private BasicArrayList<I> neighbors;
+  private WArrayList<I> neighbors;
 
   @Override
   public
@@ -85,7 +85,7 @@ public class IdAndNullArrayEdges<I extends WritableComparable>
 
   @Override
   public void add(Edge<I, NullWritable> edge) {
-    neighbors.add(edge.getTargetVertexId());
+    neighbors.addW(edge.getTargetVertexId());
   }
 
   /**
@@ -108,9 +108,9 @@ public class IdAndNullArrayEdges<I extends 
WritableComparable>
     // the deleted edge with the rightmost element, thus achieving constant
     // time.
     I tmpValue = neighbors.getElementTypeOps().create();
-    neighbors.popInto(tmpValue);
+    neighbors.popIntoW(tmpValue);
     if (i != neighbors.size()) {
-      neighbors.set(i, tmpValue);
+      neighbors.setW(i, tmpValue);
     }
     // If needed after the removal, trim the array.
     trim();
@@ -122,7 +122,7 @@ public class IdAndNullArrayEdges<I extends 
WritableComparable>
     // we can remove all matching edges in linear time.
     I tmpValue = neighbors.getElementTypeOps().create();
     for (int i = neighbors.size() - 1; i >= 0; --i) {
-      neighbors.getInto(i, tmpValue);
+      neighbors.getIntoW(i, tmpValue);
       if (tmpValue.equals(targetVertexId)) {
         removeAt(i);
       }
@@ -158,7 +158,7 @@ public class IdAndNullArrayEdges<I extends 
WritableComparable>
 
       @Override
       public MutableEdge<I, NullWritable> next() {
-        neighbors.getInto(offset++, representativeEdge.getTargetVertexId());
+        neighbors.getIntoW(offset++, representativeEdge.getTargetVertexId());
         return representativeEdge;
       }
 

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-core/src/main/java/org/apache/giraph/edge/IdAndValueArrayEdges.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/edge/IdAndValueArrayEdges.java 
b/giraph-core/src/main/java/org/apache/giraph/edge/IdAndValueArrayEdges.java
index b99692f..c22dbc3 100644
--- a/giraph-core/src/main/java/org/apache/giraph/edge/IdAndValueArrayEdges.java
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/IdAndValueArrayEdges.java
@@ -27,7 +27,7 @@ import 
org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
 import org.apache.giraph.types.ops.PrimitiveIdTypeOps;
 import org.apache.giraph.types.ops.PrimitiveTypeOps;
 import org.apache.giraph.types.ops.TypeOpsUtils;
-import org.apache.giraph.types.ops.collections.BasicArrayList;
+import org.apache.giraph.types.ops.collections.array.WArrayList;
 import org.apache.giraph.utils.EdgeIterables;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.io.WritableComparable;
@@ -50,9 +50,9 @@ public class IdAndValueArrayEdges<I extends 
WritableComparable,
     ImmutableClassesGiraphConfigurable<I, Writable, E> {
 
   /** Array of target vertex ids. */
-  private BasicArrayList<I> neighborIds;
+  private WArrayList<I> neighborIds;
   /** Array of edge values. */
-  private BasicArrayList<E> neighborEdgeValues;
+  private WArrayList<E> neighborEdgeValues;
 
   @Override
   public ImmutableClassesGiraphConfiguration<I, Writable, E> getConf() {
@@ -89,8 +89,8 @@ public class IdAndValueArrayEdges<I extends 
WritableComparable,
 
   @Override
   public void add(Edge<I, E> edge) {
-    neighborIds.add(edge.getTargetVertexId());
-    neighborEdgeValues.add(edge.getValue());
+    neighborIds.addW(edge.getTargetVertexId());
+    neighborEdgeValues.addW(edge.getValue());
   }
 
   /**
@@ -116,11 +116,11 @@ public class IdAndValueArrayEdges<I extends 
WritableComparable,
     I tmpId = neighborIds.getElementTypeOps().create();
     E tmpValue = neighborEdgeValues.getElementTypeOps().create();
 
-    neighborIds.popInto(tmpId);
-    neighborEdgeValues.popInto(tmpValue);
+    neighborIds.popIntoW(tmpId);
+    neighborEdgeValues.popIntoW(tmpValue);
     if (i != neighborIds.size()) {
-      neighborIds.set(i, tmpId);
-      neighborEdgeValues.set(i, tmpValue);
+      neighborIds.setW(i, tmpId);
+      neighborEdgeValues.setW(i, tmpValue);
     }
     // If needed after the removal, trim the array.
     trim();
@@ -132,7 +132,7 @@ public class IdAndValueArrayEdges<I extends 
WritableComparable,
     // we can remove all matching edges in linear time.
     I tmpId = neighborIds.getElementTypeOps().create();
     for (int i = neighborIds.size() - 1; i >= 0; --i) {
-      neighborIds.getInto(i, tmpId);
+      neighborIds.getIntoW(i, tmpId);
       if (tmpId.equals(targetVertexId)) {
         removeAt(i);
       }
@@ -162,8 +162,8 @@ public class IdAndValueArrayEdges<I extends 
WritableComparable,
 
       @Override
       public Edge<I, E> next() {
-        neighborIds.getInto(index, representativeEdge.getTargetVertexId());
-        neighborEdgeValues.getInto(index, representativeEdge.getValue());
+        neighborIds.getIntoW(index, representativeEdge.getTargetVertexId());
+        neighborEdgeValues.getIntoW(index, representativeEdge.getValue());
         index++;
         return representativeEdge;
       }
@@ -189,8 +189,8 @@ public class IdAndValueArrayEdges<I extends 
WritableComparable,
      */
     public void setIndex(int index) {
       // Update the id and value objects from the superclass.
-      neighborIds.getInto(index, getTargetVertexId());
-      neighborEdgeValues.getInto(index, getValue());
+      neighborIds.getIntoW(index, getTargetVertexId());
+      neighborEdgeValues.getIntoW(index, getValue());
       // Update the index.
       this.index = index;
     }
@@ -200,7 +200,7 @@ public class IdAndValueArrayEdges<I extends 
WritableComparable,
       // Update the value object from the superclass.
       neighborEdgeValues.getElementTypeOps().set(getValue(), value);
       // Update the value stored in the backing array.
-      neighborEdgeValues.set(index, value);
+      neighborEdgeValues.setW(index, value);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-core/src/main/java/org/apache/giraph/function/primitive/BooleanPredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/BooleanPredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/BooleanPredicate.java
new file mode 100644
index 0000000..13f28a9
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/BooleanPredicate.java
@@ -0,0 +1,37 @@
+/*
+ * 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.function.primitive;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (boolean) -> boolean
+ */
+public interface BooleanPredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input input
+   * @return result
+   */
+  boolean apply(boolean input);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-core/src/main/java/org/apache/giraph/function/primitive/BytePredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/BytePredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/BytePredicate.java
new file mode 100644
index 0000000..d21fa30
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/BytePredicate.java
@@ -0,0 +1,37 @@
+/*
+ * 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.function.primitive;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (byte) -> boolean
+ */
+public interface BytePredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input input
+   * @return result
+   */
+  boolean apply(byte input);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-core/src/main/java/org/apache/giraph/function/primitive/DoublePredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/DoublePredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/DoublePredicate.java
new file mode 100644
index 0000000..60803a8
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/DoublePredicate.java
@@ -0,0 +1,37 @@
+/*
+ * 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.function.primitive;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (double) -> boolean
+ */
+public interface DoublePredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input input
+   * @return result
+   */
+  boolean apply(double input);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-core/src/main/java/org/apache/giraph/function/primitive/FloatPredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/FloatPredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/FloatPredicate.java
new file mode 100644
index 0000000..45c12f9
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/FloatPredicate.java
@@ -0,0 +1,37 @@
+/*
+ * 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.function.primitive;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (float) -> boolean
+ */
+public interface FloatPredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input input
+   * @return result
+   */
+  boolean apply(float input);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-core/src/main/java/org/apache/giraph/function/primitive/IntPredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/IntPredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/IntPredicate.java
new file mode 100644
index 0000000..a475d6e
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/IntPredicate.java
@@ -0,0 +1,37 @@
+/*
+ * 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.function.primitive;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (int) -> boolean
+ */
+public interface IntPredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input input
+   * @return result
+   */
+  boolean apply(int input);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-core/src/main/java/org/apache/giraph/function/primitive/LongPredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/LongPredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/LongPredicate.java
new file mode 100644
index 0000000..4724d63
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/LongPredicate.java
@@ -0,0 +1,37 @@
+/*
+ * 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.function.primitive;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (long) -> boolean
+ */
+public interface LongPredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input input
+   * @return result
+   */
+  boolean apply(long input);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-core/src/main/java/org/apache/giraph/function/primitive/Obj2ShortFunction.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/Obj2ShortFunction.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/Obj2ShortFunction.java
new file mode 100644
index 0000000..8208239
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/Obj2ShortFunction.java
@@ -0,0 +1,39 @@
+/*
+ * 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.function.primitive;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (T) -> short
+ *
+ * @param <T> Argument type
+ */
+public interface Obj2ShortFunction<T> extends Serializable {
+  /**
+   * Returns the result of applying this function to given {@code input}.
+   *
+   * @param input input
+   * @return result
+   */
+  short apply(T input);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-core/src/main/java/org/apache/giraph/function/primitive/ShortConsumer.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/ShortConsumer.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/ShortConsumer.java
new file mode 100644
index 0000000..125902c
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/ShortConsumer.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.function.primitive;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (short) -> void
+ */
+public interface ShortConsumer extends Serializable {
+  /**
+   * Applies this function to {@code input}
+   *
+   * @param input input
+   */
+  void apply(short input);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-core/src/main/java/org/apache/giraph/function/primitive/ShortPredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/ShortPredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/ShortPredicate.java
new file mode 100644
index 0000000..1181f9f
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/ShortPredicate.java
@@ -0,0 +1,37 @@
+/*
+ * 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.function.primitive;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (short) -> boolean
+ */
+public interface ShortPredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input input
+   * @return result
+   */
+  boolean apply(short input);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-core/src/main/java/org/apache/giraph/types/ops/BooleanTypeOps.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/types/ops/BooleanTypeOps.java 
b/giraph-core/src/main/java/org/apache/giraph/types/ops/BooleanTypeOps.java
index 980668f..31da03d 100644
--- a/giraph-core/src/main/java/org/apache/giraph/types/ops/BooleanTypeOps.java
+++ b/giraph-core/src/main/java/org/apache/giraph/types/ops/BooleanTypeOps.java
@@ -17,14 +17,20 @@
  */
 package org.apache.giraph.types.ops;
 
-import 
org.apache.giraph.types.ops.collections.BasicArrayList.BasicBooleanArrayList;
+import org.apache.giraph.types.ops.collections.array.WBooleanArrayList;
 import org.apache.hadoop.io.BooleanWritable;
 
+import java.io.DataInput;
+import java.io.IOException;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
 
 /** TypeOps implementation for working with BooleanWritable type */
-public enum BooleanTypeOps implements PrimitiveTypeOps<BooleanWritable> {
+public enum BooleanTypeOps implements
+    PrimitiveTypeOps<BooleanWritable> {
   /** Singleton instance */
-  INSTANCE();
+  INSTANCE;
 
   @Override
   public Class<BooleanWritable> getTypeClass() {
@@ -47,12 +53,17 @@ public enum BooleanTypeOps implements 
PrimitiveTypeOps<BooleanWritable> {
   }
 
   @Override
-  public BasicBooleanArrayList createArrayList() {
-    return new BasicBooleanArrayList();
+  public WBooleanArrayList createArrayList() {
+    return new WBooleanArrayList();
+  }
+
+  @Override
+  public WBooleanArrayList createArrayList(int capacity) {
+    return new WBooleanArrayList(capacity);
   }
 
   @Override
-  public BasicBooleanArrayList createArrayList(int capacity) {
-    return new BasicBooleanArrayList(capacity);
+  public WBooleanArrayList readNewArrayList(DataInput in) throws IOException {
+    return WBooleanArrayList.readNew(in);
   }
 }

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-core/src/main/java/org/apache/giraph/types/ops/ByteTypeOps.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/types/ops/ByteTypeOps.java 
b/giraph-core/src/main/java/org/apache/giraph/types/ops/ByteTypeOps.java
index 08f2c0f..6499c2b 100644
--- a/giraph-core/src/main/java/org/apache/giraph/types/ops/ByteTypeOps.java
+++ b/giraph-core/src/main/java/org/apache/giraph/types/ops/ByteTypeOps.java
@@ -17,15 +17,20 @@
  */
 package org.apache.giraph.types.ops;
 
-import 
org.apache.giraph.types.ops.collections.BasicArrayList.BasicByteArrayList;
+import org.apache.giraph.types.ops.collections.array.WByteArrayList;
 import org.apache.hadoop.io.ByteWritable;
 
+import java.io.DataInput;
+import java.io.IOException;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
 /** TypeOps implementation for working with ByteWritable type */
-public enum ByteTypeOps
-    implements PrimitiveTypeOps<ByteWritable>,
-    NumericTypeOps<ByteWritable> {
+public enum ByteTypeOps implements
+    PrimitiveTypeOps<ByteWritable>, NumericTypeOps<ByteWritable> {
   /** Singleton instance */
-  INSTANCE();
+  INSTANCE;
 
   @Override
   public Class<ByteWritable> getTypeClass() {
@@ -48,13 +53,18 @@ public enum ByteTypeOps
   }
 
   @Override
-  public BasicByteArrayList createArrayList() {
-    return new BasicByteArrayList();
+  public WByteArrayList createArrayList() {
+    return new WByteArrayList();
+  }
+
+  @Override
+  public WByteArrayList createArrayList(int capacity) {
+    return new WByteArrayList(capacity);
   }
 
   @Override
-  public BasicByteArrayList createArrayList(int capacity) {
-    return new BasicByteArrayList(capacity);
+  public WByteArrayList readNewArrayList(DataInput in) throws IOException {
+    return WByteArrayList.readNew(in);
   }
 
   @Override
@@ -89,6 +99,6 @@ public enum ByteTypeOps
 
   @Override
   public void negate(ByteWritable value) {
-    value.set((byte) -value.get());
+    value.set((byte) (-value.get()));
   }
 }

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-core/src/main/java/org/apache/giraph/types/ops/DoubleTypeOps.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/types/ops/DoubleTypeOps.java 
b/giraph-core/src/main/java/org/apache/giraph/types/ops/DoubleTypeOps.java
index 42e18c4..f549208 100644
--- a/giraph-core/src/main/java/org/apache/giraph/types/ops/DoubleTypeOps.java
+++ b/giraph-core/src/main/java/org/apache/giraph/types/ops/DoubleTypeOps.java
@@ -17,15 +17,20 @@
  */
 package org.apache.giraph.types.ops;
 
-import 
org.apache.giraph.types.ops.collections.BasicArrayList.BasicDoubleArrayList;
+import org.apache.giraph.types.ops.collections.array.WDoubleArrayList;
 import org.apache.hadoop.io.DoubleWritable;
 
+import java.io.DataInput;
+import java.io.IOException;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
 /** TypeOps implementation for working with DoubleWritable type */
-public enum DoubleTypeOps
-    implements PrimitiveTypeOps<DoubleWritable>,
-    NumericTypeOps<DoubleWritable> {
+public enum DoubleTypeOps implements
+    PrimitiveTypeOps<DoubleWritable>, NumericTypeOps<DoubleWritable> {
   /** Singleton instance */
-  INSTANCE();
+  INSTANCE;
 
   @Override
   public Class<DoubleWritable> getTypeClass() {
@@ -48,13 +53,18 @@ public enum DoubleTypeOps
   }
 
   @Override
-  public BasicDoubleArrayList createArrayList() {
-    return new BasicDoubleArrayList();
+  public WDoubleArrayList createArrayList() {
+    return new WDoubleArrayList();
+  }
+
+  @Override
+  public WDoubleArrayList createArrayList(int capacity) {
+    return new WDoubleArrayList(capacity);
   }
 
   @Override
-  public BasicDoubleArrayList createArrayList(int capacity) {
-    return new BasicDoubleArrayList(capacity);
+  public WDoubleArrayList readNewArrayList(DataInput in) throws IOException {
+    return WDoubleArrayList.readNew(in);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-core/src/main/java/org/apache/giraph/types/ops/FloatTypeOps.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/types/ops/FloatTypeOps.java 
b/giraph-core/src/main/java/org/apache/giraph/types/ops/FloatTypeOps.java
index 586e39a..cf970c0 100644
--- a/giraph-core/src/main/java/org/apache/giraph/types/ops/FloatTypeOps.java
+++ b/giraph-core/src/main/java/org/apache/giraph/types/ops/FloatTypeOps.java
@@ -17,14 +17,20 @@
  */
 package org.apache.giraph.types.ops;
 
-import 
org.apache.giraph.types.ops.collections.BasicArrayList.BasicFloatArrayList;
+import org.apache.giraph.types.ops.collections.array.WFloatArrayList;
 import org.apache.hadoop.io.FloatWritable;
 
+import java.io.DataInput;
+import java.io.IOException;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
 /** TypeOps implementation for working with FloatWritable type */
-public enum FloatTypeOps
-    implements PrimitiveTypeOps<FloatWritable>, NumericTypeOps<FloatWritable> {
+public enum FloatTypeOps implements
+    PrimitiveTypeOps<FloatWritable>, NumericTypeOps<FloatWritable> {
   /** Singleton instance */
-  INSTANCE();
+  INSTANCE;
 
   @Override
   public Class<FloatWritable> getTypeClass() {
@@ -47,13 +53,18 @@ public enum FloatTypeOps
   }
 
   @Override
-  public BasicFloatArrayList createArrayList() {
-    return new BasicFloatArrayList();
+  public WFloatArrayList createArrayList() {
+    return new WFloatArrayList();
+  }
+
+  @Override
+  public WFloatArrayList createArrayList(int capacity) {
+    return new WFloatArrayList(capacity);
   }
 
   @Override
-  public BasicFloatArrayList createArrayList(int capacity) {
-    return new BasicFloatArrayList(capacity);
+  public WFloatArrayList readNewArrayList(DataInput in) throws IOException {
+    return WFloatArrayList.readNew(in);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-core/src/main/java/org/apache/giraph/types/ops/IntTypeOps.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/types/ops/IntTypeOps.java 
b/giraph-core/src/main/java/org/apache/giraph/types/ops/IntTypeOps.java
index 5ab9631..943637c 100644
--- a/giraph-core/src/main/java/org/apache/giraph/types/ops/IntTypeOps.java
+++ b/giraph-core/src/main/java/org/apache/giraph/types/ops/IntTypeOps.java
@@ -17,18 +17,21 @@
  */
 package org.apache.giraph.types.ops;
 
-import org.apache.giraph.types.ops.collections.Basic2ObjectMap;
 import 
org.apache.giraph.types.ops.collections.Basic2ObjectMap.BasicInt2ObjectOpenHashMap;
-import org.apache.giraph.types.ops.collections.BasicArrayList;
-import 
org.apache.giraph.types.ops.collections.BasicArrayList.BasicIntArrayList;
-import org.apache.giraph.types.ops.collections.BasicSet;
 import org.apache.giraph.types.ops.collections.BasicSet.BasicIntOpenHashSet;
+import org.apache.giraph.types.ops.collections.array.WIntArrayList;
 import org.apache.giraph.types.ops.collections.WritableWriter;
 import org.apache.hadoop.io.IntWritable;
 
+import java.io.DataInput;
+import java.io.IOException;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
 /** TypeOps implementation for working with IntWritable type */
-public enum IntTypeOps
-    implements PrimitiveIdTypeOps<IntWritable>, NumericTypeOps<IntWritable> {
+public enum IntTypeOps implements
+    PrimitiveIdTypeOps<IntWritable>, NumericTypeOps<IntWritable> {
   /** Singleton instance */
   INSTANCE;
 
@@ -53,33 +56,38 @@ public enum IntTypeOps
   }
 
   @Override
-  public BasicArrayList<IntWritable> createArrayList() {
-    return new BasicIntArrayList();
+  public WIntArrayList createArrayList() {
+    return new WIntArrayList();
+  }
+
+  @Override
+  public WIntArrayList createArrayList(int capacity) {
+    return new WIntArrayList(capacity);
   }
 
   @Override
-  public BasicArrayList<IntWritable> createArrayList(int capacity) {
-    return new BasicIntArrayList(capacity);
+  public WIntArrayList readNewArrayList(DataInput in) throws IOException {
+    return WIntArrayList.readNew(in);
   }
 
   @Override
-  public BasicSet<IntWritable> createOpenHashSet() {
+  public BasicIntOpenHashSet createOpenHashSet() {
     return new BasicIntOpenHashSet();
   }
 
   @Override
-  public BasicSet<IntWritable> createOpenHashSet(long capacity) {
+  public BasicIntOpenHashSet createOpenHashSet(long capacity) {
     return new BasicIntOpenHashSet(capacity);
   }
 
   @Override
-  public <V> Basic2ObjectMap<IntWritable, V> create2ObjectOpenHashMap(
+  public <V> BasicInt2ObjectOpenHashMap<V> create2ObjectOpenHashMap(
       WritableWriter<V> valueWriter) {
     return new BasicInt2ObjectOpenHashMap<>(valueWriter);
   }
 
   @Override
-  public <V> Basic2ObjectMap<IntWritable, V> create2ObjectOpenHashMap(
+  public <V> BasicInt2ObjectOpenHashMap<V> create2ObjectOpenHashMap(
       int capacity, WritableWriter<V> valueWriter) {
     return new BasicInt2ObjectOpenHashMap<>(capacity, valueWriter);
   }

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-core/src/main/java/org/apache/giraph/types/ops/LongTypeOps.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/types/ops/LongTypeOps.java 
b/giraph-core/src/main/java/org/apache/giraph/types/ops/LongTypeOps.java
index b588aed..2e3c8e7 100644
--- a/giraph-core/src/main/java/org/apache/giraph/types/ops/LongTypeOps.java
+++ b/giraph-core/src/main/java/org/apache/giraph/types/ops/LongTypeOps.java
@@ -17,18 +17,21 @@
  */
 package org.apache.giraph.types.ops;
 
-import org.apache.giraph.types.ops.collections.Basic2ObjectMap;
 import 
org.apache.giraph.types.ops.collections.Basic2ObjectMap.BasicLong2ObjectOpenHashMap;
-import org.apache.giraph.types.ops.collections.BasicArrayList;
-import 
org.apache.giraph.types.ops.collections.BasicArrayList.BasicLongArrayList;
-import org.apache.giraph.types.ops.collections.BasicSet;
 import org.apache.giraph.types.ops.collections.BasicSet.BasicLongOpenHashSet;
+import org.apache.giraph.types.ops.collections.array.WLongArrayList;
 import org.apache.giraph.types.ops.collections.WritableWriter;
 import org.apache.hadoop.io.LongWritable;
 
+import java.io.DataInput;
+import java.io.IOException;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
 /** TypeOps implementation for working with LongWritable type */
-public enum LongTypeOps
-    implements PrimitiveIdTypeOps<LongWritable>, NumericTypeOps<LongWritable> {
+public enum LongTypeOps implements
+    PrimitiveIdTypeOps<LongWritable>, NumericTypeOps<LongWritable> {
   /** Singleton instance */
   INSTANCE;
 
@@ -53,33 +56,38 @@ public enum LongTypeOps
   }
 
   @Override
-  public BasicArrayList<LongWritable> createArrayList() {
-    return new BasicLongArrayList();
+  public WLongArrayList createArrayList() {
+    return new WLongArrayList();
+  }
+
+  @Override
+  public WLongArrayList createArrayList(int capacity) {
+    return new WLongArrayList(capacity);
   }
 
   @Override
-  public BasicArrayList<LongWritable> createArrayList(int capacity) {
-    return new BasicLongArrayList(capacity);
+  public WLongArrayList readNewArrayList(DataInput in) throws IOException {
+    return WLongArrayList.readNew(in);
   }
 
   @Override
-  public BasicSet<LongWritable> createOpenHashSet() {
+  public BasicLongOpenHashSet createOpenHashSet() {
     return new BasicLongOpenHashSet();
   }
 
   @Override
-  public BasicSet<LongWritable> createOpenHashSet(long capacity) {
+  public BasicLongOpenHashSet createOpenHashSet(long capacity) {
     return new BasicLongOpenHashSet(capacity);
   }
 
   @Override
-  public <V> Basic2ObjectMap<LongWritable, V> create2ObjectOpenHashMap(
+  public <V> BasicLong2ObjectOpenHashMap<V> create2ObjectOpenHashMap(
       WritableWriter<V> valueWriter) {
     return new BasicLong2ObjectOpenHashMap<>(valueWriter);
   }
 
   @Override
-  public <V> Basic2ObjectMap<LongWritable, V> create2ObjectOpenHashMap(
+  public <V> BasicLong2ObjectOpenHashMap<V> create2ObjectOpenHashMap(
       int capacity, WritableWriter<V> valueWriter) {
     return new BasicLong2ObjectOpenHashMap<>(capacity, valueWriter);
   }

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-core/src/main/java/org/apache/giraph/types/ops/PrimitiveTypeOps.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/types/ops/PrimitiveTypeOps.java 
b/giraph-core/src/main/java/org/apache/giraph/types/ops/PrimitiveTypeOps.java
index 0c7c852..dea1a63 100644
--- 
a/giraph-core/src/main/java/org/apache/giraph/types/ops/PrimitiveTypeOps.java
+++ 
b/giraph-core/src/main/java/org/apache/giraph/types/ops/PrimitiveTypeOps.java
@@ -17,7 +17,10 @@
  */
 package org.apache.giraph.types.ops;
 
-import org.apache.giraph.types.ops.collections.BasicArrayList;
+import java.io.DataInput;
+import java.io.IOException;
+
+import org.apache.giraph.types.ops.collections.array.WArrayList;
 
 
 /**
@@ -34,15 +37,22 @@ import 
org.apache.giraph.types.ops.collections.BasicArrayList;
 public interface PrimitiveTypeOps<T> extends TypeOps<T> {
   // primitive collections
   /**
-   * Create BasicArrayList of type T.
-   * @return BasicArrayList
+   * Create WArrayList of type T.
+   * @return WArrayList
    */
-  BasicArrayList<T> createArrayList();
+  WArrayList<T> createArrayList();
 
   /**
-   * Create BasicArrayList of type T, given capacity.
+   * Create WArrayList of type T, given capacity.
    * @param capacity Capacity
-   * @return BasicArrayList
+   * @return WArrayList
+   */
+  WArrayList<T> createArrayList(int capacity);
+
+  /**
+   * Create WArrayList of type T by reading it from given input.
+   * @param in Input
+   * @return WArrayList
    */
-  BasicArrayList<T> createArrayList(int capacity);
+  WArrayList<T> readNewArrayList(DataInput in) throws IOException;
 }

http://git-wip-us.apache.org/repos/asf/giraph/blob/77ae12e0/giraph-core/src/main/java/org/apache/giraph/types/ops/collections/BasicArrayList.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/types/ops/collections/BasicArrayList.java
 
b/giraph-core/src/main/java/org/apache/giraph/types/ops/collections/BasicArrayList.java
deleted file mode 100644
index 434cc23..0000000
--- 
a/giraph-core/src/main/java/org/apache/giraph/types/ops/collections/BasicArrayList.java
+++ /dev/null
@@ -1,813 +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.types.ops.collections;
-
-import it.unimi.dsi.fastutil.booleans.BooleanArrayList;
-import it.unimi.dsi.fastutil.bytes.ByteArrayList;
-import it.unimi.dsi.fastutil.doubles.DoubleArrayList;
-import it.unimi.dsi.fastutil.floats.FloatArrayList;
-import it.unimi.dsi.fastutil.ints.IntArrayList;
-import it.unimi.dsi.fastutil.longs.LongArrayList;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.NoSuchElementException;
-
-import org.apache.giraph.types.ops.BooleanTypeOps;
-import org.apache.giraph.types.ops.ByteTypeOps;
-import org.apache.giraph.types.ops.DoubleTypeOps;
-import org.apache.giraph.types.ops.FloatTypeOps;
-import org.apache.giraph.types.ops.IntTypeOps;
-import org.apache.giraph.types.ops.LongTypeOps;
-import org.apache.giraph.types.ops.PrimitiveTypeOps;
-import org.apache.hadoop.io.BooleanWritable;
-import org.apache.hadoop.io.ByteWritable;
-import org.apache.hadoop.io.DoubleWritable;
-import org.apache.hadoop.io.FloatWritable;
-import org.apache.hadoop.io.IntWritable;
-import org.apache.hadoop.io.LongWritable;
-import org.apache.hadoop.io.Writable;
-
-/**
- * BasicArrayList with only basic set of operations.
- *
- * @param <T> Element type
- */
-public abstract class BasicArrayList<T> implements Writable {
-  /** Removes all of the elements from this list. */
-  public abstract void clear();
-  /**
-   * Number of elements in this list
-   * @return size
-   */
-  public abstract int size();
-  /**
-   * Sets the size of this list.
-   *
-   * <P>
-   * If the specified size is smaller than the current size,
-   * the last elements are discarded.
-   * Otherwise, they are filled with 0/<code>null</code>/<code>false</code>.
-   *
-   * @param newSize the new size.
-   */
-  public abstract void size(int newSize);
-  /**
-   * Capacity of currently allocated memory
-   * @return capacity
-   */
-  public abstract int capacity();
-  /**
-   * Forces allocated memory to hold exactly N values
-   * @param n new capacity
-   */
-  public abstract void setCapacity(int n);
-  /**
-   * Add value to the end of the array
-   * @param value Value
-   */
-  public abstract void add(T value);
-  /**
-   * Pop value from the end of the array, storing it into 'to' argument
-   * @param to Object to store value into
-   */
-  public abstract void popInto(T to);
-  /**
-   * Get element at given index in the array, storing it into 'to' argument
-   * @param index Index
-   * @param to Object to store value into
-   */
-  public abstract void getInto(int index, T to);
-  /**
-   * Set element at given index in the array
-   * @param index Index
-   * @param value Value
-   */
-  public abstract void set(int index, T value);
-
-  /**
-   * Sets given range of elements to a specified value.
-   *
-   * @param from From index (inclusive)
-   * @param to To index (exclusive)
-   * @param value Value
-   */
-  public abstract void fill(int from, int to, T value);
-
-  /**
-   * Returns underlying primitive collection:
-   * it.unimi.dsi.fastutil.{T}s.{T}ArrayList.
-   *
-   * Allows for direct access where primitive type is fixed.
-   *
-   * @return underlying primitive collection
-   */
-  public abstract Object unwrap();
-
-  /**
-   * TypeOps for type of elements this object holds
-   * @return TypeOps
-   */
-  public abstract PrimitiveTypeOps<T> getElementTypeOps();
-
-  /**
-   * Fast iterator over BasicArrayList object, which doesn't allocate new
-   * element for each returned element, and can be iterated multiple times
-   * using reset().
-   *
-   * Object returned by next() is only valid until next() is called again,
-   * because it is reused.
-   *
-   * @return RessettableIterator
-   */
-  public ResettableIterator<T> fastIterator() {
-    return new ResettableIterator<T>() {
-      private final T value = getElementTypeOps().create();
-      private int pos;
-
-      @Override
-      public boolean hasNext() {
-        return pos < size();
-      }
-
-      @Override
-      public T next() {
-        if (!hasNext()) {
-          throw new NoSuchElementException();
-        }
-        getInto(pos, value);
-        pos++;
-        return value;
-      }
-
-      @Override
-      public void reset() {
-        pos = 0;
-      }
-
-      @Override
-      public void remove() {
-        throw new UnsupportedOperationException();
-      }
-    };
-  }
-
-  /** BooleanWritable implementation of BasicArrayList */
-  public static final class BasicBooleanArrayList
-      extends BasicArrayList<BooleanWritable> {
-    /** List */
-    private final BooleanArrayList list;
-
-    /** Constructor */
-    public BasicBooleanArrayList() {
-      list = new BooleanArrayList();
-    }
-
-    /**
-     * Constructor
-     * @param capacity Capacity
-     */
-    public BasicBooleanArrayList(int capacity) {
-      list = new BooleanArrayList(capacity);
-    }
-
-    @Override
-    public PrimitiveTypeOps<BooleanWritable> getElementTypeOps() {
-      return BooleanTypeOps.INSTANCE;
-    }
-
-    @Override
-    public void clear() {
-      list.clear();
-    }
-
-    @Override
-    public int size() {
-      return list.size();
-    }
-
-    @Override
-    public void size(int newSize) {
-      list.size(newSize);
-    }
-
-    @Override
-    public int capacity() {
-      return list.elements().length;
-    }
-
-    @Override
-    public void setCapacity(int n) {
-      if (n >= list.elements().length) {
-        list.ensureCapacity(n);
-      } else {
-        list.trim(n);
-      }
-    }
-
-    @Override
-    public void add(BooleanWritable value) {
-      list.add(value.get());
-    }
-
-    @Override
-    public void getInto(int index, BooleanWritable to) {
-      to.set(list.getBoolean(index));
-    }
-
-    @Override
-    public void popInto(BooleanWritable to) {
-      to.set(list.popBoolean());
-    }
-
-    @Override
-    public void set(int index, BooleanWritable value) {
-      list.set(index, value.get());
-    }
-
-    @Override
-    public void fill(int from, int to, BooleanWritable value) {
-      if (to > list.size()) {
-        throw new ArrayIndexOutOfBoundsException(
-            "End index (" + to + ") is greater than array length (" +
-                list.size() + ")");
-      }
-      Arrays.fill(list.elements(), from, to, value.get());
-    }
-
-    @Override
-    public BooleanArrayList unwrap() {
-      return list;
-    }
-
-    @Override
-    public void write(DataOutput out) throws IOException {
-      out.writeInt(list.size());
-      for (int i = 0; i < list.size(); i++) {
-        out.writeBoolean(list.getBoolean(i));
-      }
-    }
-
-    @Override
-    public void readFields(DataInput in) throws IOException {
-      int size = in.readInt();
-      list.clear();
-      list.ensureCapacity(size);
-      for (int i = 0; i < size; ++i) {
-        list.add(in.readBoolean());
-      }
-    }
-  }
-
-  /** ByteWritable implementation of BasicArrayList */
-  public static final class BasicByteArrayList
-      extends BasicArrayList<ByteWritable> {
-    /** List */
-    private final ByteArrayList list;
-
-    /** Constructor */
-    public BasicByteArrayList() {
-      list = new ByteArrayList();
-    }
-
-    /**
-     * Constructor
-     * @param capacity Capacity
-     */
-    public BasicByteArrayList(int capacity) {
-      list = new ByteArrayList(capacity);
-    }
-
-    @Override
-    public PrimitiveTypeOps<ByteWritable> getElementTypeOps() {
-      return ByteTypeOps.INSTANCE;
-    }
-
-    @Override
-    public void clear() {
-      list.clear();
-    }
-
-    @Override
-    public int size() {
-      return list.size();
-    }
-
-    @Override
-    public void size(int newSize) {
-      list.size(newSize);
-    }
-
-    @Override
-    public int capacity() {
-      return list.elements().length;
-    }
-
-    @Override
-    public void setCapacity(int n) {
-      if (n >= list.elements().length) {
-        list.ensureCapacity(n);
-      } else {
-        list.trim(n);
-      }
-    }
-
-    @Override
-    public void add(ByteWritable value) {
-      list.add(value.get());
-    }
-
-    @Override
-    public void getInto(int index, ByteWritable to) {
-      to.set(list.getByte(index));
-    }
-
-    @Override
-    public void popInto(ByteWritable to) {
-      to.set(list.popByte());
-    }
-
-    @Override
-    public void set(int index, ByteWritable value) {
-      list.set(index, value.get());
-    }
-
-    @Override
-    public void fill(int from, int to, ByteWritable value) {
-      if (to > list.size()) {
-        throw new ArrayIndexOutOfBoundsException(
-            "End index (" + to + ") is greater than array length (" +
-                list.size() + ")");
-      }
-      Arrays.fill(list.elements(), from, to, value.get());
-    }
-
-    @Override
-    public ByteArrayList unwrap() {
-      return list;
-    }
-
-    @Override
-    public void write(DataOutput out) throws IOException {
-      out.writeInt(list.size());
-      for (int i = 0; i < list.size(); i++) {
-        out.writeByte(list.getByte(i));
-      }
-    }
-
-    @Override
-    public void readFields(DataInput in) throws IOException {
-      int size = in.readInt();
-      list.clear();
-      list.ensureCapacity(size);
-      for (int i = 0; i < size; ++i) {
-        list.add(in.readByte());
-      }
-    }
-  }
-
-  /** IntWritable implementation of BasicArrayList */
-  public static final class BasicIntArrayList
-      extends BasicArrayList<IntWritable> {
-    /** List */
-    private final IntArrayList list;
-
-    /** Constructor */
-    public BasicIntArrayList() {
-      list = new IntArrayList();
-    }
-
-    /**
-     * Constructor
-     * @param capacity Capacity
-     */
-    public BasicIntArrayList(int capacity) {
-      list = new IntArrayList(capacity);
-    }
-
-    @Override
-    public PrimitiveTypeOps<IntWritable> getElementTypeOps() {
-      return IntTypeOps.INSTANCE;
-    }
-
-    @Override
-    public void clear() {
-      list.clear();
-    }
-
-    @Override
-    public int size() {
-      return list.size();
-    }
-
-    @Override
-    public void size(int newSize) {
-      list.size(newSize);
-    }
-
-    @Override
-    public int capacity() {
-      return list.elements().length;
-    }
-
-    @Override
-    public void setCapacity(int n) {
-      if (n >= list.elements().length) {
-        list.ensureCapacity(n);
-      } else {
-        list.trim(n);
-      }
-    }
-
-    @Override
-    public void add(IntWritable value) {
-      list.add(value.get());
-    }
-
-    @Override
-    public void getInto(int index, IntWritable to) {
-      to.set(list.getInt(index));
-    }
-
-    @Override
-    public void popInto(IntWritable to) {
-      to.set(list.popInt());
-    }
-
-    @Override
-    public void set(int index, IntWritable value) {
-      list.set(index, value.get());
-    }
-
-    @Override
-    public void fill(int from, int to, IntWritable value) {
-      if (to > list.size()) {
-        throw new ArrayIndexOutOfBoundsException(
-            "End index (" + to + ") is greater than array length (" +
-                list.size() + ")");
-      }
-      Arrays.fill(list.elements(), from, to, value.get());
-    }
-
-    @Override
-    public IntArrayList unwrap() {
-      return list;
-    }
-
-    @Override
-    public void write(DataOutput out) throws IOException {
-      out.writeInt(list.size());
-      for (int i = 0; i < list.size(); i++) {
-        out.writeInt(list.getInt(i));
-      }
-    }
-
-    @Override
-    public void readFields(DataInput in) throws IOException {
-      int size = in.readInt();
-      list.clear();
-      list.ensureCapacity(size);
-      for (int i = 0; i < size; ++i) {
-        list.add(in.readInt());
-      }
-    }
-  }
-
-  /** LongWritable implementation of BasicArrayList */
-  public static final class BasicLongArrayList
-      extends BasicArrayList<LongWritable> {
-    /** List */
-    private final LongArrayList list;
-
-    /** Constructor */
-    public BasicLongArrayList() {
-      list = new LongArrayList();
-    }
-
-    /**
-     * Constructor
-     * @param capacity Capacity
-     */
-    public BasicLongArrayList(int capacity) {
-      list = new LongArrayList(capacity);
-    }
-
-    @Override
-    public PrimitiveTypeOps<LongWritable> getElementTypeOps() {
-      return LongTypeOps.INSTANCE;
-    }
-
-    @Override
-    public void clear() {
-      list.clear();
-    }
-
-    @Override
-    public int size() {
-      return list.size();
-    }
-
-    @Override
-    public void size(int newSize) {
-      list.size(newSize);
-    }
-
-    @Override
-    public int capacity() {
-      return list.elements().length;
-    }
-
-    @Override
-    public void setCapacity(int n) {
-      if (n >= list.elements().length) {
-        list.ensureCapacity(n);
-      } else {
-        list.trim(n);
-      }
-    }
-
-    @Override
-    public void add(LongWritable value) {
-      list.add(value.get());
-    }
-
-    @Override
-    public void getInto(int index, LongWritable to) {
-      to.set(list.getLong(index));
-    }
-
-    @Override
-    public void popInto(LongWritable to) {
-      to.set(list.popLong());
-    }
-
-    @Override
-    public void set(int index, LongWritable value) {
-      list.set(index, value.get());
-    }
-
-    @Override
-    public void fill(int from, int to, LongWritable value) {
-      if (to > list.size()) {
-        throw new ArrayIndexOutOfBoundsException(
-            "End index (" + to + ") is greater than array length (" +
-                list.size() + ")");
-      }
-      Arrays.fill(list.elements(), from, to, value.get());
-    }
-
-    @Override
-    public LongArrayList unwrap() {
-      return list;
-    }
-
-    @Override
-    public void write(DataOutput out) throws IOException {
-      out.writeInt(list.size());
-      for (int i = 0; i < list.size(); i++) {
-        out.writeLong(list.getLong(i));
-      }
-    }
-
-    @Override
-    public void readFields(DataInput in) throws IOException {
-      int size = in.readInt();
-      list.clear();
-      list.ensureCapacity(size);
-      for (int i = 0; i < size; ++i) {
-        list.add(in.readLong());
-      }
-    }
-  }
-
-  /** FloatWritable implementation of BasicArrayList */
-  public static final class BasicFloatArrayList
-      extends BasicArrayList<FloatWritable> {
-    /** List */
-    private final FloatArrayList list;
-
-    /** Constructor */
-    public BasicFloatArrayList() {
-      list = new FloatArrayList();
-    }
-
-    /**
-     * Constructor
-     * @param capacity Capacity
-     */
-    public BasicFloatArrayList(int capacity) {
-      list = new FloatArrayList(capacity);
-    }
-
-    @Override
-    public PrimitiveTypeOps<FloatWritable> getElementTypeOps() {
-      return FloatTypeOps.INSTANCE;
-    }
-
-    @Override
-    public void clear() {
-      list.clear();
-    }
-
-    @Override
-    public int size() {
-      return list.size();
-    }
-
-    @Override
-    public void size(int newSize) {
-      list.size(newSize);
-    }
-
-    @Override
-    public int capacity() {
-      return list.elements().length;
-    }
-
-    @Override
-    public void setCapacity(int n) {
-      if (n >= list.elements().length) {
-        list.ensureCapacity(n);
-      } else {
-        list.trim(n);
-      }
-    }
-
-    @Override
-    public void add(FloatWritable value) {
-      list.add(value.get());
-    }
-
-    @Override
-    public void getInto(int index, FloatWritable to) {
-      to.set(list.getFloat(index));
-    }
-
-    @Override
-    public void popInto(FloatWritable to) {
-      to.set(list.popFloat());
-    }
-
-    @Override
-    public void set(int index, FloatWritable value) {
-      list.set(index, value.get());
-    }
-
-    @Override
-    public void fill(int from, int to, FloatWritable value) {
-      if (to > list.size()) {
-        throw new ArrayIndexOutOfBoundsException(
-            "End index (" + to + ") is greater than array length (" +
-                list.size() + ")");
-      }
-      Arrays.fill(list.elements(), from, to, value.get());
-    }
-
-    @Override
-    public FloatArrayList unwrap() {
-      return list;
-    }
-
-    @Override
-    public void write(DataOutput out) throws IOException {
-      out.writeInt(list.size());
-      for (int i = 0; i < list.size(); i++) {
-        out.writeFloat(list.getFloat(i));
-      }
-    }
-
-    @Override
-    public void readFields(DataInput in) throws IOException {
-      int size = in.readInt();
-      list.clear();
-      list.ensureCapacity(size);
-      for (int i = 0; i < size; ++i) {
-        list.add(in.readFloat());
-      }
-    }
-  }
-
-  /** DoubleWritable implementation of BasicArrayList */
-  public static final class BasicDoubleArrayList
-      extends BasicArrayList<DoubleWritable> {
-    /** List */
-    private final DoubleArrayList list;
-
-    /** Constructor */
-    public BasicDoubleArrayList() {
-      list = new DoubleArrayList();
-    }
-
-    /**
-     * Constructor
-     * @param capacity Capacity
-     */
-    public BasicDoubleArrayList(int capacity) {
-      list = new DoubleArrayList(capacity);
-    }
-
-    @Override
-    public PrimitiveTypeOps<DoubleWritable> getElementTypeOps() {
-      return DoubleTypeOps.INSTANCE;
-    }
-
-    @Override
-    public void clear() {
-      list.clear();
-    }
-
-    @Override
-    public int size() {
-      return list.size();
-    }
-
-    @Override
-    public void size(int newSize) {
-      list.size(newSize);
-    }
-
-    @Override
-    public int capacity() {
-      return list.elements().length;
-    }
-
-    @Override
-    public void setCapacity(int n) {
-      if (n >= list.elements().length) {
-        list.ensureCapacity(n);
-      } else {
-        list.trim(n);
-      }
-    }
-
-    @Override
-    public void add(DoubleWritable value) {
-      list.add(value.get());
-    }
-
-    @Override
-    public void getInto(int index, DoubleWritable to) {
-      to.set(list.getDouble(index));
-    }
-
-    @Override
-    public void popInto(DoubleWritable to) {
-      to.set(list.popDouble());
-    }
-
-    @Override
-    public void set(int index, DoubleWritable value) {
-      list.set(index, value.get());
-    }
-
-    @Override
-    public void fill(int from, int to, DoubleWritable value) {
-      if (to > list.size()) {
-        throw new ArrayIndexOutOfBoundsException(
-            "End index (" + to + ") is greater than array length (" +
-                list.size() + ")");
-      }
-      Arrays.fill(list.elements(), from, to, value.get());
-    }
-
-    @Override
-    public DoubleArrayList unwrap() {
-      return list;
-    }
-
-    @Override
-    public void write(DataOutput out) throws IOException {
-      out.writeInt(list.size());
-      for (int i = 0; i < list.size(); i++) {
-        out.writeDouble(list.getDouble(i));
-      }
-    }
-
-    @Override
-    public void readFields(DataInput in) throws IOException {
-      int size = in.readInt();
-      list.clear();
-      list.ensureCapacity(size);
-      for (int i = 0; i < size; ++i) {
-        list.add(in.readDouble());
-      }
-    }
-  }
-}

Reply via email to