Repository: giraph
Updated Branches:
  refs/heads/trunk 4a133f576 -> 28dac9e5a


GIRAPH-910: removing unnecessary boxing in some places in giraph-core (pavanka)


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

Branch: refs/heads/trunk
Commit: 28dac9e5a790199dffe944bad2d518435474b396
Parents: 4a133f5
Author: Pavan Kumar <[email protected]>
Authored: Sun Jun 8 11:33:38 2014 -0700
Committer: Pavan Kumar <[email protected]>
Committed: Sun Jun 8 11:33:38 2014 -0700

----------------------------------------------------------------------
 CHANGELOG                                       |  2 ++
 .../giraph/aggregators/DoubleMaxAggregator.java |  2 +-
 .../giraph/aggregators/FloatMaxAggregator.java  |  2 +-
 .../matrix/dense/DoubleDenseVector.java         | 15 ++++++------
 .../matrix/dense/FloatDenseVector.java          | 13 +++++-----
 .../matrix/dense/IntDenseVector.java            | 13 +++++-----
 .../matrix/dense/LongDenseVector.java           | 13 +++++-----
 .../apache/giraph/edge/IntNullArrayEdges.java   | 20 ++++++++--------
 .../giraph/edge/LongDoubleArrayEdges.java       | 25 ++++++++++----------
 .../giraph/edge/LongDoubleHashMapEdges.java     | 22 +++++++++--------
 .../apache/giraph/edge/LongNullArrayEdges.java  | 17 ++++++-------
 11 files changed, 77 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/giraph/blob/28dac9e5/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index 37b94e2..de277ea 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
 Giraph Change Log
 
 Release 1.1.0 - unreleased
+  GIRAPH-910: removing unnecessary boxing in some places in giraph-core 
(pavanka)  
+
   GIRAPH-908: support for partitioned input in giraph (pavanka)
 
   GIRAPH-907: refactor giraph code to support multiple implementations of 
vertexId data (pavanka)  

http://git-wip-us.apache.org/repos/asf/giraph/blob/28dac9e5/giraph-core/src/main/java/org/apache/giraph/aggregators/DoubleMaxAggregator.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/aggregators/DoubleMaxAggregator.java
 
b/giraph-core/src/main/java/org/apache/giraph/aggregators/DoubleMaxAggregator.java
index d925f9f..e91738b 100644
--- 
a/giraph-core/src/main/java/org/apache/giraph/aggregators/DoubleMaxAggregator.java
+++ 
b/giraph-core/src/main/java/org/apache/giraph/aggregators/DoubleMaxAggregator.java
@@ -32,6 +32,6 @@ public class DoubleMaxAggregator extends 
BasicAggregator<DoubleWritable> {
 
   @Override
   public DoubleWritable createInitialValue() {
-    return new DoubleWritable(Double.MIN_VALUE);
+    return new DoubleWritable(Double.NEGATIVE_INFINITY);
   }
 }

http://git-wip-us.apache.org/repos/asf/giraph/blob/28dac9e5/giraph-core/src/main/java/org/apache/giraph/aggregators/FloatMaxAggregator.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/aggregators/FloatMaxAggregator.java
 
b/giraph-core/src/main/java/org/apache/giraph/aggregators/FloatMaxAggregator.java
index 6ee1111..d047d8d 100644
--- 
a/giraph-core/src/main/java/org/apache/giraph/aggregators/FloatMaxAggregator.java
+++ 
b/giraph-core/src/main/java/org/apache/giraph/aggregators/FloatMaxAggregator.java
@@ -32,6 +32,6 @@ public class FloatMaxAggregator extends 
BasicAggregator<FloatWritable> {
 
   @Override
   public FloatWritable createInitialValue() {
-    return new FloatWritable(Float.MIN_VALUE);
+    return new FloatWritable(Float.NEGATIVE_INFINITY);
   }
 }

http://git-wip-us.apache.org/repos/asf/giraph/blob/28dac9e5/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/DoubleDenseVector.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/DoubleDenseVector.java
 
b/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/DoubleDenseVector.java
index 88b8a9b..09778ba 100644
--- 
a/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/DoubleDenseVector.java
+++ 
b/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/DoubleDenseVector.java
@@ -18,11 +18,12 @@
 
 package org.apache.giraph.aggregators.matrix.dense;
 
+import it.unimi.dsi.fastutil.doubles.DoubleArrayList;
+
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 
-import it.unimi.dsi.fastutil.doubles.DoubleArrayList;
 import org.apache.hadoop.io.Writable;
 
 /**
@@ -33,7 +34,7 @@ import org.apache.hadoop.io.Writable;
  */
 public class DoubleDenseVector implements Writable {
   /** The entries of the vector. */
-  private DoubleArrayList entries = new DoubleArrayList();
+  private final DoubleArrayList entries = new DoubleArrayList();
   /** If true, this vector is singleton */
   private boolean isSingleton = false;
   /** The index of the singleton */
@@ -94,7 +95,7 @@ public class DoubleDenseVector implements Writable {
     if (i >= entries.size()) {
       return 0.0;
     }
-    return entries.get(i);
+    return entries.getDouble(i);
   }
 
   /**
@@ -119,12 +120,12 @@ public class DoubleDenseVector implements Writable {
     }
     if (other.isSingleton) {
       ensureCapacity(other.singletonIndex + 1);
-      entries.set(other.singletonIndex, entries.get(other.singletonIndex) +
-          other.singletonValue);
+      entries.set(other.singletonIndex,
+          entries.getDouble(other.singletonIndex) + other.singletonValue);
     } else {
       ensureCapacity(other.entries.size());
       for (int i = 0; i < other.entries.size(); ++i) {
-        entries.set(i, entries.get(i) + other.entries.get(i));
+        entries.set(i, entries.getDouble(i) + other.entries.getDouble(i));
       }
     }
   }
@@ -149,7 +150,7 @@ public class DoubleDenseVector implements Writable {
     } else {
       out.writeInt(entries.size());
       for (int i = 0; i < entries.size(); ++i) {
-        out.writeDouble(entries.get(i));
+        out.writeDouble(entries.getDouble(i));
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/giraph/blob/28dac9e5/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/FloatDenseVector.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/FloatDenseVector.java
 
b/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/FloatDenseVector.java
index 140bd1e..37f0b24 100644
--- 
a/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/FloatDenseVector.java
+++ 
b/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/FloatDenseVector.java
@@ -18,11 +18,12 @@
 
 package org.apache.giraph.aggregators.matrix.dense;
 
+import it.unimi.dsi.fastutil.floats.FloatArrayList;
+
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 
-import it.unimi.dsi.fastutil.floats.FloatArrayList;
 import org.apache.hadoop.io.Writable;
 
 /**
@@ -31,7 +32,7 @@ import org.apache.hadoop.io.Writable;
  */
 public class FloatDenseVector implements Writable {
   /** The entries of the vector. */
-  private FloatArrayList entries = new FloatArrayList();
+  private final FloatArrayList entries = new FloatArrayList();
   /** If true, this vector is singleton */
   private boolean isSingleton = false;
   /** The index of the singleton */
@@ -92,7 +93,7 @@ public class FloatDenseVector implements Writable {
     if (i >= entries.size()) {
       return 0.0f;
     }
-    return entries.get(i);
+    return entries.getFloat(i);
   }
 
   /**
@@ -117,12 +118,12 @@ public class FloatDenseVector implements Writable {
     }
     if (other.isSingleton) {
       ensureCapacity(other.singletonIndex + 1);
-      entries.set(other.singletonIndex, entries.get(other.singletonIndex) +
+      entries.set(other.singletonIndex, entries.getFloat(other.singletonIndex) 
+
           other.singletonValue);
     } else {
       ensureCapacity(other.entries.size());
       for (int i = 0; i < other.entries.size(); ++i) {
-        entries.set(i, entries.get(i) + other.entries.get(i));
+        entries.set(i, entries.getFloat(i) + other.entries.getFloat(i));
       }
     }
   }
@@ -147,7 +148,7 @@ public class FloatDenseVector implements Writable {
     } else {
       out.writeInt(entries.size());
       for (int i = 0; i < entries.size(); ++i) {
-        out.writeFloat(entries.get(i));
+        out.writeFloat(entries.getFloat(i));
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/giraph/blob/28dac9e5/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/IntDenseVector.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/IntDenseVector.java
 
b/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/IntDenseVector.java
index 9e74f9e..0d289cd 100644
--- 
a/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/IntDenseVector.java
+++ 
b/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/IntDenseVector.java
@@ -18,11 +18,12 @@
 
 package org.apache.giraph.aggregators.matrix.dense;
 
+import it.unimi.dsi.fastutil.ints.IntArrayList;
+
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 
-import it.unimi.dsi.fastutil.ints.IntArrayList;
 import org.apache.hadoop.io.Writable;
 
 /**
@@ -31,7 +32,7 @@ import org.apache.hadoop.io.Writable;
  */
 public class IntDenseVector implements Writable {
   /** The entries of the vector. */
-  private IntArrayList entries = new IntArrayList();
+  private final IntArrayList entries = new IntArrayList();
   /** If true, this vector is singleton */
   private boolean isSingleton = false;
   /** The index of the singleton */
@@ -92,7 +93,7 @@ public class IntDenseVector implements Writable {
     if (i >= entries.size()) {
       return 0;
     }
-    return entries.get(i);
+    return entries.getInt(i);
   }
 
   /**
@@ -117,12 +118,12 @@ public class IntDenseVector implements Writable {
     }
     if (other.isSingleton) {
       ensureCapacity(other.singletonIndex + 1);
-      entries.set(other.singletonIndex, entries.get(other.singletonIndex) +
+      entries.set(other.singletonIndex, entries.getInt(other.singletonIndex) +
           other.singletonValue);
     } else {
       ensureCapacity(other.entries.size());
       for (int i = 0; i < other.entries.size(); ++i) {
-        entries.set(i, entries.get(i) + other.entries.get(i));
+        entries.set(i, entries.getInt(i) + other.entries.getInt(i));
       }
     }
   }
@@ -147,7 +148,7 @@ public class IntDenseVector implements Writable {
     } else {
       out.writeInt(entries.size());
       for (int i = 0; i < entries.size(); ++i) {
-        out.writeInt(entries.get(i));
+        out.writeInt(entries.getInt(i));
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/giraph/blob/28dac9e5/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/LongDenseVector.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/LongDenseVector.java
 
b/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/LongDenseVector.java
index 4cedc1f..4555074 100644
--- 
a/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/LongDenseVector.java
+++ 
b/giraph-core/src/main/java/org/apache/giraph/aggregators/matrix/dense/LongDenseVector.java
@@ -18,11 +18,12 @@
 
 package org.apache.giraph.aggregators.matrix.dense;
 
+import it.unimi.dsi.fastutil.longs.LongArrayList;
+
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 
-import it.unimi.dsi.fastutil.longs.LongArrayList;
 import org.apache.hadoop.io.Writable;
 
 /**
@@ -31,7 +32,7 @@ import org.apache.hadoop.io.Writable;
  */
 public class LongDenseVector implements Writable {
   /** The entries of the vector. */
-  private LongArrayList entries = new LongArrayList();
+  private final LongArrayList entries = new LongArrayList();
   /** If true, this vector is singleton */
   private boolean isSingleton = false;
   /** The index of the singleton */
@@ -92,7 +93,7 @@ public class LongDenseVector implements Writable {
     if (i >= entries.size()) {
       return 0L;
     }
-    return entries.get(i);
+    return entries.getLong(i);
   }
 
   /**
@@ -117,12 +118,12 @@ public class LongDenseVector implements Writable {
     }
     if (other.isSingleton) {
       ensureCapacity(other.singletonIndex + 1);
-      entries.set(other.singletonIndex, entries.get(other.singletonIndex) +
+      entries.set(other.singletonIndex, entries.getLong(other.singletonIndex) +
           other.singletonValue);
     } else {
       ensureCapacity(other.entries.size());
       for (int i = 0; i < other.entries.size(); ++i) {
-        entries.set(i, entries.get(i) + other.entries.get(i));
+        entries.set(i, entries.getLong(i) + other.entries.getLong(i));
       }
     }
   }
@@ -147,7 +148,7 @@ public class LongDenseVector implements Writable {
     } else {
       out.writeInt(entries.size());
       for (int i = 0; i < entries.size(); ++i) {
-        out.writeLong(entries.get(i));
+        out.writeLong(entries.getLong(i));
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/giraph/blob/28dac9e5/giraph-core/src/main/java/org/apache/giraph/edge/IntNullArrayEdges.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/edge/IntNullArrayEdges.java 
b/giraph-core/src/main/java/org/apache/giraph/edge/IntNullArrayEdges.java
index 31cc611..9280325 100644
--- a/giraph-core/src/main/java/org/apache/giraph/edge/IntNullArrayEdges.java
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/IntNullArrayEdges.java
@@ -18,13 +18,6 @@
 
 package org.apache.giraph.edge;
 
-import org.apache.giraph.utils.EdgeIterables;
-import org.apache.giraph.utils.Trimmable;
-import org.apache.hadoop.io.IntWritable;
-import org.apache.hadoop.io.NullWritable;
-
-import com.google.common.collect.UnmodifiableIterator;
-
 import it.unimi.dsi.fastutil.ints.IntArrayList;
 import it.unimi.dsi.fastutil.ints.IntIterator;
 
@@ -33,6 +26,13 @@ import java.io.DataOutput;
 import java.io.IOException;
 import java.util.Iterator;
 
+import org.apache.giraph.utils.EdgeIterables;
+import org.apache.giraph.utils.Trimmable;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.NullWritable;
+
+import com.google.common.collect.UnmodifiableIterator;
+
 /**
  * Implementation of {@link OutEdges} with int ids and null edge
  * values, backed by dynamic primitive array.
@@ -91,7 +91,7 @@ public class IntNullArrayEdges
     // Thanks to the constant-time implementation of removeAt(int),
     // we can remove all matching edges in linear time.
     for (int i = neighbors.size() - 1; i >= 0; --i) {
-      if (neighbors.get(i) == targetVertexId.get()) {
+      if (neighbors.getInt(i) == targetVertexId.get()) {
         removeAt(i);
       }
     }
@@ -102,9 +102,9 @@ public class IntNullArrayEdges
     // Returns an iterator that reuses objects.
     return new UnmodifiableIterator<Edge<IntWritable, NullWritable>>() {
       /** Wrapped neighbors iterator. */
-      private IntIterator neighborsIt = neighbors.iterator();
+      private final IntIterator neighborsIt = neighbors.iterator();
       /** Representative edge object. */
-      private Edge<IntWritable, NullWritable> representativeEdge =
+      private final Edge<IntWritable, NullWritable> representativeEdge =
           EdgeFactory.create(new IntWritable(), NullWritable.get());
 
       @Override

http://git-wip-us.apache.org/repos/asf/giraph/blob/28dac9e5/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleArrayEdges.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleArrayEdges.java 
b/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleArrayEdges.java
index 8bd1cef..bb8ddea 100644
--- a/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleArrayEdges.java
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleArrayEdges.java
@@ -18,21 +18,22 @@
 
 package org.apache.giraph.edge;
 
-import com.google.common.collect.UnmodifiableIterator;
 import it.unimi.dsi.fastutil.doubles.DoubleArrayList;
 import it.unimi.dsi.fastutil.doubles.DoubleIterator;
 import it.unimi.dsi.fastutil.longs.LongArrayList;
 import it.unimi.dsi.fastutil.longs.LongIterator;
 
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Iterator;
+
 import org.apache.giraph.utils.EdgeIterables;
 import org.apache.giraph.utils.Trimmable;
 import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.LongWritable;
 
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.Iterator;
+import com.google.common.collect.UnmodifiableIterator;
 
 /**
  * Implementation of {@link OutEdges} with long ids and double edge
@@ -108,7 +109,7 @@ public class LongDoubleArrayEdges
     // Thanks to the constant-time implementation of removeAt(int),
     // we can remove all matching edges in linear time.
     for (int i = neighbors.size() - 1; i >= 0; --i) {
-      if (neighbors.get(i) == targetVertexId.get()) {
+      if (neighbors.getLong(i) == targetVertexId.get()) {
         removeAt(i);
       }
     }
@@ -124,11 +125,11 @@ public class LongDoubleArrayEdges
     // Returns an iterator that reuses objects.
     return new UnmodifiableIterator<Edge<LongWritable, DoubleWritable>>() {
       /** Wrapped neighbors iterator. */
-      private LongIterator neighborsIt = neighbors.iterator();
+      private final LongIterator neighborsIt = neighbors.iterator();
       /** Wrapped edge values iterator. */
-      private DoubleIterator edgeValuesIt = edgeValues.iterator();
+      private final DoubleIterator edgeValuesIt = edgeValues.iterator();
       /** Representative edge object. */
-      private Edge<LongWritable, DoubleWritable> representativeEdge =
+      private final Edge<LongWritable, DoubleWritable> representativeEdge =
           EdgeFactory.create(new LongWritable(), new DoubleWritable());
 
       @Override
@@ -163,8 +164,8 @@ public class LongDoubleArrayEdges
      */
     public void setIndex(int index) {
       // Update the id and value objects from the superclass.
-      getTargetVertexId().set(neighbors.get(index));
-      getValue().set(edgeValues.get(index));
+      getTargetVertexId().set(neighbors.getLong(index));
+      getValue().set(edgeValues.getDouble(index));
       // Update the index.
       this.index = index;
     }
@@ -185,7 +186,7 @@ public class LongDoubleArrayEdges
       /** Current position in the array. */
       private int offset = 0;
       /** Representative edge object. */
-      private LongDoubleArrayMutableEdge representativeEdge =
+      private final LongDoubleArrayMutableEdge representativeEdge =
           new LongDoubleArrayMutableEdge();
 
       @Override

http://git-wip-us.apache.org/repos/asf/giraph/blob/28dac9e5/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleHashMapEdges.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleHashMapEdges.java 
b/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleHashMapEdges.java
index 6bfbd20..4c68646 100644
--- 
a/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleHashMapEdges.java
+++ 
b/giraph-core/src/main/java/org/apache/giraph/edge/LongDoubleHashMapEdges.java
@@ -18,20 +18,21 @@
 
 package org.apache.giraph.edge;
 
-import com.google.common.collect.UnmodifiableIterator;
 import it.unimi.dsi.fastutil.longs.Long2DoubleMap;
 import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap;
 import it.unimi.dsi.fastutil.objects.ObjectIterator;
 
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Iterator;
+
 import org.apache.giraph.utils.EdgeIterables;
 import org.apache.giraph.utils.Trimmable;
 import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.LongWritable;
 
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.Iterator;
+import com.google.common.collect.UnmodifiableIterator;
 
 /**
  * {@link OutEdges} implementation with long ids and double edge values,
@@ -105,10 +106,11 @@ public class LongDoubleHashMapEdges
     // Returns an iterator that reuses objects.
     return new UnmodifiableIterator<Edge<LongWritable, DoubleWritable>>() {
       /** Wrapped map iterator. */
-      private ObjectIterator<Long2DoubleMap.Entry> mapIterator =
+      private final ObjectIterator<Long2DoubleMap.Entry> mapIterator =
           edgeMap.long2DoubleEntrySet().fastIterator();
       /** Representative edge object. */
-      private ReusableEdge<LongWritable, DoubleWritable> representativeEdge =
+      private final ReusableEdge<LongWritable, DoubleWritable>
+      representativeEdge =
           EdgeFactory.createReusable(new LongWritable(), new DoubleWritable());
 
       @Override
@@ -150,7 +152,7 @@ public class LongDoubleHashMapEdges
     public void setEntry(Long2DoubleMap.Entry entry) {
       // Update the id and value objects from the superclass.
       getTargetVertexId().set(entry.getLongKey());
-      getValue().set(entry.getValue());
+      getValue().set(entry.getDoubleValue());
       // Update the entry.
       this.entry = entry;
     }
@@ -172,10 +174,10 @@ public class LongDoubleHashMapEdges
        * Note: we cannot use the fast iterator in this case,
        * because we need to call setValue() on an entry.
        */
-      private ObjectIterator<Long2DoubleMap.Entry> mapIterator =
+      private final ObjectIterator<Long2DoubleMap.Entry> mapIterator =
           edgeMap.long2DoubleEntrySet().iterator();
       /** Representative edge object. */
-      private LongDoubleHashMapMutableEdge representativeEdge =
+      private final LongDoubleHashMapMutableEdge representativeEdge =
           new LongDoubleHashMapMutableEdge();
 
       @Override

http://git-wip-us.apache.org/repos/asf/giraph/blob/28dac9e5/giraph-core/src/main/java/org/apache/giraph/edge/LongNullArrayEdges.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/edge/LongNullArrayEdges.java 
b/giraph-core/src/main/java/org/apache/giraph/edge/LongNullArrayEdges.java
index 06815ef..c504042 100644
--- a/giraph-core/src/main/java/org/apache/giraph/edge/LongNullArrayEdges.java
+++ b/giraph-core/src/main/java/org/apache/giraph/edge/LongNullArrayEdges.java
@@ -21,16 +21,16 @@ package org.apache.giraph.edge;
 import it.unimi.dsi.fastutil.longs.LongArrayList;
 import it.unimi.dsi.fastutil.longs.LongIterator;
 
-import org.apache.giraph.utils.EdgeIterables;
-import org.apache.giraph.utils.Trimmable;
-import org.apache.hadoop.io.LongWritable;
-import org.apache.hadoop.io.NullWritable;
-
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 import java.util.Iterator;
 
+import org.apache.giraph.utils.EdgeIterables;
+import org.apache.giraph.utils.Trimmable;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.NullWritable;
+
 /**
  * Implementation of {@link OutEdges} with long ids and null edge
  * values, backed by a dynamic primitive array.
@@ -97,7 +97,7 @@ public class LongNullArrayEdges
     // Thanks to the constant-time implementation of removeAt(int),
     // we can remove all matching edges in linear time.
     for (int i = neighbors.size() - 1; i >= 0; --i) {
-      if (neighbors.get(i) == targetVertexId.get()) {
+      if (neighbors.getLong(i) == targetVertexId.get()) {
         removeAt(i);
       }
     }
@@ -122,16 +122,17 @@ public class LongNullArrayEdges
       /** Current position in the array. */
       private int offset = 0;
       /** Representative edge object. */
-      private MutableEdge<LongWritable, NullWritable> representativeEdge =
+      private final MutableEdge<LongWritable, NullWritable> representativeEdge 
=
           EdgeFactory.createReusable(new LongWritable());
 
+      @Override
       public boolean hasNext() {
         return offset < neighbors.size();
       }
 
       @Override
       public MutableEdge<LongWritable, NullWritable> next() {
-        representativeEdge.getTargetVertexId().set(neighbors.get(offset++));
+        
representativeEdge.getTargetVertexId().set(neighbors.getLong(offset++));
         return representativeEdge;
       }
 

Reply via email to