Index: graph/src/test/java/org/apache/hama/graph/TestSubmitGraphJob.java =================================================================== --- graph/src/test/java/org/apache/hama/graph/TestSubmitGraphJob.java (revision 1442854) +++ graph/src/test/java/org/apache/hama/graph/TestSubmitGraphJob.java (working copy) @@ -115,7 +115,7 @@ reader.close(); } LOG.info("Sum is: " + sum); - assertTrue(sum > 0.9d && sum <= 1.1d); + assertTrue("unexpected sum " +sum, sum > 0.9d && sum <= 1.1d); } Index: graph/src/main/java/org/apache/hama/graph/GraphJobRunner.java =================================================================== --- graph/src/main/java/org/apache/hama/graph/GraphJobRunner.java (revision 1442854) +++ graph/src/main/java/org/apache/hama/graph/GraphJobRunner.java (working copy) @@ -71,7 +71,7 @@ private Combiner combiner; private Partitioner partitioner; - private VerticesInfo vertices; + private OffHeapVerticesInfo vertices; private boolean updated = true; private int globalUpdateCounts = 0; @@ -261,7 +261,7 @@ aggregationRunner = new AggregationRunner(); aggregationRunner.setupAggregators(peer); - vertices = new VerticesInfo(); + vertices = new OffHeapVerticesInfo(); } /** Index: graph/src/main/java/org/apache/hama/graph/OffHeapVerticesInfo.java =================================================================== --- graph/src/main/java/org/apache/hama/graph/OffHeapVerticesInfo.java (revision 0) +++ graph/src/main/java/org/apache/hama/graph/OffHeapVerticesInfo.java (revision 0) @@ -0,0 +1,57 @@ +/** + * 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.hama.graph; + +import java.util.Iterator; + +import org.apache.directmemory.DirectMemory; +import org.apache.directmemory.cache.CacheService; +import org.apache.directmemory.utils.CacheValuesIterable; +import org.apache.hadoop.io.Writable; + +/** + * An off heap version of a {@link Vertex} storage. + */ +public class OffHeapVerticesInfo + implements Iterable> { + + private final CacheService> vertices; + + public OffHeapVerticesInfo() { + this.vertices = new DirectMemory>().setNumberOfBuffers(10). + setSize(1000).setInitialCapacity(10000).setConcurrencyLevel(1).newCacheService(); + } + + public void addVertex(Vertex vertex) { + vertices.put(vertex.getVertexID(), vertex); + } + + public void clear() { + vertices.clear(); + } + + public int size() { + return (int) this.vertices.entries(); + } + + @Override + public Iterator> iterator() { + return new CacheValuesIterable>(vertices).iterator(); + } + +} Property changes on: graph/src/main/java/org/apache/hama/graph/OffHeapVerticesInfo.java ___________________________________________________________________ Added: svn:eol-style + native Index: graph/pom.xml =================================================================== --- graph/pom.xml (revision 1442854) +++ graph/pom.xml (working copy) @@ -43,6 +43,11 @@ test-jar test + + org.apache.directmemory + directmemory-cache + 0.2-SNAPSHOT + hama-graph-${project.version}