You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by el...@apache.org on 2013/02/03 16:08:01 UTC

svn commit: r1441926 - in /labs/mavibot/trunk/mavibot/src: main/java/org/apache/mavibot/btree/BTree.java test/java/org/apache/mavibot/btree/BTreeFlushTest.java test/java/org/apache/mavibot/btree/InMemoryBTreeTest.java

Author: elecharny
Date: Sun Feb  3 15:08:00 2013
New Revision: 1441926

URL: http://svn.apache.org/viewvc?rev=1441926&view=rev
Log:
o Allowing null value additions
o Fixed a /0 error

Modified:
    labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java
    labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/BTreeFlushTest.java
    labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/InMemoryBTreeTest.java

Modified: labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java
URL: http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java?rev=1441926&r1=1441925&r2=1441926&view=diff
==============================================================================
--- labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java (original)
+++ labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java Sun Feb  3 15:08:00 2013
@@ -889,11 +889,6 @@ public class BTree<K, V>
             throw new IllegalArgumentException( "Key must not be null" );
         }
 
-        if ( value == null )
-        {
-            throw new IllegalArgumentException( "Value must not be null" );
-        }
-
         // Commented atm, we will have to play around the idea of transactions later
         writeLock.lock();
 

Modified: labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/BTreeFlushTest.java
URL: http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/BTreeFlushTest.java?rev=1441926&r1=1441925&r2=1441926&view=diff
==============================================================================
--- labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/BTreeFlushTest.java (original)
+++ labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/BTreeFlushTest.java Sun Feb  3 15:08:00 2013
@@ -164,7 +164,7 @@ public class BTreeFlushTest
         long l2 = System.currentTimeMillis();
 
         System.out.println( "Delta : " + ( l2 - l1 ) + ", nbError = " + nbError
-            + ", Nb insertion per second : " + ( nbElems ) / ( ( l2 - l1 ) / 1000 ) );
+            + ", Nb insertion per second : " + ( ( nbElems ) / ( l2 - l1 ) ) * 1000 );
 
         // Now, flush the btree
 

Modified: labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/InMemoryBTreeTest.java
URL: http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/InMemoryBTreeTest.java?rev=1441926&r1=1441925&r2=1441926&view=diff
==============================================================================
--- labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/InMemoryBTreeTest.java (original)
+++ labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/InMemoryBTreeTest.java Sun Feb  3 15:08:00 2013
@@ -23,6 +23,7 @@ package org.apache.mavibot.btree;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -1664,6 +1665,35 @@ public class InMemoryBTreeTest
 
 
     /**
+     * Test the addition of elements with null values
+     */
+    @Test
+    public void testAdditionNullValues() throws IOException
+    {
+        BTree<Integer, String> btree = createMultiLevelBTreeLeavesHalfFull();
+
+        // Adding an element with a null value
+        btree.insert( 100, null );
+
+        assertTrue( btree.exist( 100 ) );
+
+        try
+        {
+            assertNull( btree.get( 100 ) );
+        }
+        catch ( KeyNotFoundException knfe )
+        {
+            fail();
+        }
+
+        Tuple<Integer, String> deleted = btree.delete( 100 );
+
+        assertNotNull( deleted );
+        assertNull( deleted.getValue() );
+    }
+
+
+    /**
      * Test the insertion of 5 million elements in a BTree
      * @throws Exception
      */



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org