Author: elecharny
Date: Wed Aug 15 05:31:10 2012
New Revision: 1373217
URL: http://svn.apache.org/viewvc?rev=1373217&view=rev
Log:
o Some class renaming
o Added support for the Journal
o Closing the btree when done with it, so that the inner threads are closed too
Added:
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/InMemoryBTreeTest.java
- copied, changed from r1372500,
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/BTreeTest.java
Removed:
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/BTreeTest.java
Modified:
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/BTreeConfigurationTest.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/LeafTest.java
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/MultiThreadedBtreeTest.java
Modified:
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/BTreeConfigurationTest.java
URL:
http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/BTreeConfigurationTest.java?rev=1373217&r1=1373216&r2=1373217&view=diff
==============================================================================
---
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/BTreeConfigurationTest.java
(original)
+++
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/BTreeConfigurationTest.java
Wed Aug 15 05:31:10 2012
@@ -196,7 +196,7 @@ public class BTreeConfigurationTest
assertNotNull( value );
}
- btree.close();
+ btreeCopy.close();
}
finally
{
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=1373217&r1=1373216&r2=1373217&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
Wed Aug 15 05:31:10 2012
@@ -26,9 +26,11 @@ import static org.junit.Assert.assertTru
import java.io.File;
import java.io.IOException;
+import java.util.Random;
import java.util.Set;
import org.apache.mavibot.btree.comparator.IntComparator;
+import org.apache.mavibot.btree.comparator.LongComparator;
import org.apache.mavibot.btree.serializer.DefaultSerializer;
import org.junit.Test;
@@ -163,8 +165,6 @@ public class BTreeFlushTest
BTree<Integer, String> btreeLoaded = new BTree<Integer, String>( file,
new IntComparator(), serializer );
btree.setPageSize( 8 );
- btreeLoaded.load( file );
-
Cursor<Integer, String> cursor1 = btree.browse();
Cursor<Integer, String> cursor2 = btree.browse();
@@ -184,4 +184,76 @@ public class BTreeFlushTest
btree.close();
btreeLoaded.close();
}
+
+
+ /**
+ * Test the insertion of 5 million elements in a BTree
+ * @throws Exception
+ */
+ @Test
+ public void testPageInsert5M() throws Exception
+ {
+ Random random = new Random( System.nanoTime() );
+
+ int nbError = 0;
+
+ long l1 = System.currentTimeMillis();
+ int n = 0;
+ long delta = l1;
+ int nbElems = 5000000;
+
+ BTree<Long, String> btree = new BTree<Long, String>( new
LongComparator(), new DefaultSerializer<Long, String>(
+ Long.class, String.class ) );
+ btree.setPageSize( 32 );
+
+ for ( int i = 0; i < nbElems; i++ )
+ {
+ Long key = ( long ) random.nextLong();
+ String value = Long.toString( key );
+
+ try
+ {
+ btree.insert( key, value );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ System.out.println( btree );
+ System.out.println( "Error while adding " + value );
+ nbError++;
+ return;
+ }
+
+ if ( i % 100000 == 0 )
+ {
+ if ( n > 0 )
+ {
+ long t0 = System.currentTimeMillis();
+ System.out.println( "Written " + i + " elements in : " + (
t0 - delta ) + "ms" );
+ delta = t0;
+ }
+
+ n++;
+ }
+ }
+
+ long l2 = System.currentTimeMillis();
+
+ System.out.println( "Delta : " + ( l2 - l1 ) + ", nbError = " + nbError
+ + ", Nb insertion per second : " + ( nbElems ) / ( ( l2 - l1 ) /
1000 ) );
+
+ // Now, flush the btree
+
+ File tempFile = File.createTempFile( "mavibot", "tmp" );
+ tempFile.deleteOnExit();
+
+ long t0 = System.currentTimeMillis();
+
+ btree.flush( tempFile );
+
+ long t1 = System.currentTimeMillis();
+
+ System.out.println( "Time to flush 5 million elements : " + ( t1 - t0
) );
+ btree.close();
+ }
}
Copied:
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/InMemoryBTreeTest.java
(from r1372500,
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/BTreeTest.java)
URL:
http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/InMemoryBTreeTest.java?p2=labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/InMemoryBTreeTest.java&p1=labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/BTreeTest.java&r1=1372500&r2=1373217&rev=1373217&view=diff
==============================================================================
---
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/BTreeTest.java
(original)
+++
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/InMemoryBTreeTest.java
Wed Aug 15 05:31:10 2012
@@ -27,7 +27,6 @@ import static org.junit.Assert.assertNul
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
@@ -37,17 +36,16 @@ import java.util.Set;
import org.apache.mavibot.btree.comparator.IntComparator;
import org.apache.mavibot.btree.comparator.LongComparator;
-import org.apache.mavibot.btree.serializer.DefaultSerializer;
import org.junit.Ignore;
import org.junit.Test;
/**
- * A unit test class for BTree
+ * A unit test class for in-memory BTree
*
* @author <a href="mailto:[email protected]">Mavibot labs Project</a>
*/
-public class BTreeTest
+public class InMemoryBTreeTest
{
// Some values to inject in a btree
private static int[] sortedValues = new int[]
@@ -159,7 +157,7 @@ public class BTreeTest
long l1 = System.currentTimeMillis();
int n = 0;
long delta = l1;
- int nbTrees = 100000;
+ int nbTrees = 1000;
int nbElems = 1000;
for ( int j = 0; j < nbTrees; j++ )
@@ -1618,78 +1616,6 @@ public class BTreeTest
* @throws Exception
*/
@Test
- public void testPageInsert5M() throws Exception
- {
- Random random = new Random( System.nanoTime() );
-
- int nbError = 0;
-
- long l1 = System.currentTimeMillis();
- int n = 0;
- long delta = l1;
- int nbElems = 5000000;
-
- BTree<Long, String> btree = new BTree<Long, String>( new
LongComparator(), new DefaultSerializer<Long, String>(
- Long.class, String.class ) );
- btree.setPageSize( 32 );
-
- for ( int i = 0; i < nbElems; i++ )
- {
- Long key = ( long ) random.nextLong();
- String value = Long.toString( key );
-
- try
- {
- btree.insert( key, value );
- }
- catch ( Exception e )
- {
- e.printStackTrace();
- System.out.println( btree );
- System.out.println( "Error while adding " + value );
- nbError++;
- return;
- }
-
- if ( i % 100000 == 0 )
- {
- if ( n > 0 )
- {
- long t0 = System.currentTimeMillis();
- System.out.println( "Written " + i + " elements in : " + (
t0 - delta ) + "ms" );
- delta = t0;
- }
-
- n++;
- }
- }
-
- long l2 = System.currentTimeMillis();
-
- System.out.println( "Delta : " + ( l2 - l1 ) + ", nbError = " + nbError
- + ", Nb insertion per second : " + ( nbElems ) / ( ( l2 - l1 ) /
1000 ) );
-
- // Now, flush the btree
-
- File tempFile = File.createTempFile( "mavibot", "tmp" );
- tempFile.deleteOnExit();
-
- long t0 = System.currentTimeMillis();
-
- btree.flush( tempFile );
-
- long t1 = System.currentTimeMillis();
-
- System.out.println( "Time to flush 5 million elements : " + ( t1 - t0
) );
- btree.close();
- }
-
-
- /**
- * Test the insertion of 5 million elements in a BTree
- * @throws Exception
- */
- @Test
public void testBrowse5M() throws Exception
{
Random random = new Random( System.nanoTime() );
Modified:
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/LeafTest.java
URL:
http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/LeafTest.java?rev=1373217&r1=1373216&r2=1373217&view=diff
==============================================================================
---
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/LeafTest.java
(original)
+++
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/LeafTest.java
Wed Aug 15 05:31:10 2012
@@ -54,7 +54,7 @@ public class LeafTest
@After
- public void shutdown()
+ public void shutdown() throws IOException
{
btree.close();
}
Modified:
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/MultiThreadedBtreeTest.java
URL:
http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/MultiThreadedBtreeTest.java?rev=1373217&r1=1373216&r2=1373217&view=diff
==============================================================================
---
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/MultiThreadedBtreeTest.java
(original)
+++
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/MultiThreadedBtreeTest.java
Wed Aug 15 05:31:10 2012
@@ -58,7 +58,7 @@ public class MultiThreadedBtreeTest
* Close the btree
*/
@AfterClass
- public static void shutdown()
+ public static void shutdown() throws IOException
{
btree.close();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]