Updated Branches: refs/heads/trunk 3d4f31343 -> 487ec36fb
GIRAPH-682: LongNullHashSetEdges performance issue Project: http://git-wip-us.apache.org/repos/asf/giraph/repo Commit: http://git-wip-us.apache.org/repos/asf/giraph/commit/487ec36f Tree: http://git-wip-us.apache.org/repos/asf/giraph/tree/487ec36f Diff: http://git-wip-us.apache.org/repos/asf/giraph/diff/487ec36f Branch: refs/heads/trunk Commit: 487ec36fb2e124646a238c9aa294ad63510e6ab3 Parents: 3d4f313 Author: Maja Kabiljo <[email protected]> Authored: Fri Jun 7 10:20:25 2013 -0700 Committer: Maja Kabiljo <[email protected]> Committed: Fri Jun 7 10:20:25 2013 -0700 ---------------------------------------------------------------------- .../apache/giraph/edge/LongNullHashSetEdges.java | 20 ++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/giraph/blob/487ec36f/giraph-core/src/main/java/org/apache/giraph/edge/LongNullHashSetEdges.java ---------------------------------------------------------------------- diff --git a/giraph-core/src/main/java/org/apache/giraph/edge/LongNullHashSetEdges.java b/giraph-core/src/main/java/org/apache/giraph/edge/LongNullHashSetEdges.java index 139fc7a..a21de91 100644 --- a/giraph-core/src/main/java/org/apache/giraph/edge/LongNullHashSetEdges.java +++ b/giraph-core/src/main/java/org/apache/giraph/edge/LongNullHashSetEdges.java @@ -40,7 +40,8 @@ import java.util.Iterator; */ public class LongNullHashSetEdges implements ReuseObjectsOutEdges<LongWritable, NullWritable>, - MutableOutEdges<LongWritable, NullWritable> { + MutableOutEdges<LongWritable, NullWritable>, + StrictRandomAccessOutEdges<LongWritable, NullWritable> { /** Hash set of target vertex ids. */ private LongOpenHashSet neighbors; @@ -125,4 +126,21 @@ public class LongNullHashSetEdges neighbors.add(in.readLong()); } } + + @Override + public NullWritable getEdgeValue(LongWritable targetVertexId) { + if (neighbors.contains(targetVertexId.get())) { + return NullWritable.get(); + } else { + return null; + } + } + + @Override + public void setEdgeValue(LongWritable targetVertexId, + NullWritable edgeValue) { + // No operation. + // Only set value for an existing edge. + // If the edge exist, the Null value is already there. + } }
