hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1447240 - in /hama/branches/hama-732/graph: pom.xml src/main/java/org/apache/hama/graph/OffHeapVerticesInfo.java src/test/java/org/apache/hama/graph/OffHeapVerticesInfoTest.java
Date Mon, 18 Feb 2013 13:14:17 GMT
Author: tommaso
Date: Mon Feb 18 13:14:16 2013
New Revision: 1447240

URL: http://svn.apache.org/r1447240
Log:
HAMA-732 - fixed strict offheap test and added protostuff serializer

Modified:
    hama/branches/hama-732/graph/pom.xml
    hama/branches/hama-732/graph/src/main/java/org/apache/hama/graph/OffHeapVerticesInfo.java
    hama/branches/hama-732/graph/src/test/java/org/apache/hama/graph/OffHeapVerticesInfoTest.java

Modified: hama/branches/hama-732/graph/pom.xml
URL: http://svn.apache.org/viewvc/hama/branches/hama-732/graph/pom.xml?rev=1447240&r1=1447239&r2=1447240&view=diff
==============================================================================
--- hama/branches/hama-732/graph/pom.xml (original)
+++ hama/branches/hama-732/graph/pom.xml Mon Feb 18 13:14:16 2013
@@ -48,6 +48,11 @@
       <artifactId>directmemory-cache</artifactId>
       <version>0.2-SNAPSHOT</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.directmemory</groupId>
+      <artifactId>directmemory-protostuff</artifactId>
+      <version>0.2-SNAPSHOT</version>
+    </dependency>
   </dependencies>
   <build>
     <finalName>hama-graph-${project.version}</finalName>

Modified: hama/branches/hama-732/graph/src/main/java/org/apache/hama/graph/OffHeapVerticesInfo.java
URL: http://svn.apache.org/viewvc/hama/branches/hama-732/graph/src/main/java/org/apache/hama/graph/OffHeapVerticesInfo.java?rev=1447240&r1=1447239&r2=1447240&view=diff
==============================================================================
--- hama/branches/hama-732/graph/src/main/java/org/apache/hama/graph/OffHeapVerticesInfo.java
(original)
+++ hama/branches/hama-732/graph/src/main/java/org/apache/hama/graph/OffHeapVerticesInfo.java
Mon Feb 18 13:14:16 2013
@@ -21,6 +21,7 @@ import java.util.Iterator;
 
 import org.apache.directmemory.DirectMemory;
 import org.apache.directmemory.cache.CacheService;
+import org.apache.directmemory.serialization.protostuff.ProtoStuffWithLinkedBufferSerializer;
 import org.apache.directmemory.utils.CacheValuesIterable;
 import org.apache.hadoop.io.Writable;
 
@@ -36,9 +37,9 @@ public class OffHeapVerticesInfo<V exten
 
     public OffHeapVerticesInfo(boolean strict) {
         this.strict = strict;
-        this.vertices = new DirectMemory<V, Vertex<V, E, M>>().setNumberOfBuffers(1).
-                setSize(1000).setInitialCapacity(10000).setConcurrencyLevel(100).
-                setDisposalTime(100000).newCacheService();
+        this.vertices = new DirectMemory<V, Vertex<V, E, M>>().setNumberOfBuffers(10).
+                setSize(1000000).setInitialCapacity(10).setConcurrencyLevel(1).
+                setDisposalTime(100).setSerializer(new ProtoStuffWithLinkedBufferSerializer()).newCacheService();
     }
 
     public OffHeapVerticesInfo() {

Modified: hama/branches/hama-732/graph/src/test/java/org/apache/hama/graph/OffHeapVerticesInfoTest.java
URL: http://svn.apache.org/viewvc/hama/branches/hama-732/graph/src/test/java/org/apache/hama/graph/OffHeapVerticesInfoTest.java?rev=1447240&r1=1447239&r2=1447240&view=diff
==============================================================================
--- hama/branches/hama-732/graph/src/test/java/org/apache/hama/graph/OffHeapVerticesInfoTest.java
(original)
+++ hama/branches/hama-732/graph/src/test/java/org/apache/hama/graph/OffHeapVerticesInfoTest.java
Mon Feb 18 13:14:16 2013
@@ -27,6 +27,7 @@ import org.apache.hadoop.io.DoubleWritab
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 /**
@@ -46,6 +47,7 @@ public class OffHeapVerticesInfoTest {
         OffHeapVerticesInfo<DoubleWritable, DoubleWritable, DoubleWritable> verticesInfo
=
                 new OffHeapVerticesInfo<DoubleWritable, DoubleWritable, DoubleWritable>();
         Vertex<DoubleWritable, DoubleWritable, DoubleWritable> vertex = creteDoubleVertex(1d);
+        assertNotNull(vertex.getVertexID());
         verticesInfo.addVertex(vertex);
         assertTrue("added vertex could not be found in the cache", verticesInfo.iterator().hasNext());
     }
@@ -54,7 +56,7 @@ public class OffHeapVerticesInfoTest {
     public void testAdditionWithNonStrictCache() throws Exception {
         OffHeapVerticesInfo<DoubleWritable, DoubleWritable, DoubleWritable> verticesInfo
=
                 new OffHeapVerticesInfo<DoubleWritable, DoubleWritable, DoubleWritable>(false);
-        Vertex<DoubleWritable, DoubleWritable, DoubleWritable> vertex = creteDoubleVertex(1d);
+        Vertex<DoubleWritable, DoubleWritable, DoubleWritable> vertex = creteDoubleVertex(2d);
         verticesInfo.addVertex(vertex);
         assertTrue("added vertex could not be found in the cache", verticesInfo.iterator().hasNext());
     }
@@ -62,6 +64,12 @@ public class OffHeapVerticesInfoTest {
 
     private Vertex<DoubleWritable, DoubleWritable, DoubleWritable> creteDoubleVertex(final
Double id) {
         return new Vertex<DoubleWritable, DoubleWritable, DoubleWritable>() {
+
+            @Override
+            public DoubleWritable getVertexID() {
+                return new DoubleWritable(id);
+            }
+
             @Override
             public DoubleWritable createVertexIDObject() {
                 return new DoubleWritable(id);



Mime
View raw message