Author: kayyagari
Date: Sun Mar 31 18:25:43 2013
New Revision: 1463028
URL: http://svn.apache.org/r1463028
Log:
o set the page to null if the key is not found for browsing
o added a test
Modified:
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/test/java/org/apache/mavibot/btree/InMemoryBTreeTest.java
Modified:
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java
URL:
http://svn.apache.org/viewvc/labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java?rev=1463028&r1=1463027&r2=1463028&view=diff
==============================================================================
---
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java
(original)
+++
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java
Sun Mar 31 18:25:43 2013
@@ -587,7 +587,7 @@ public class Leaf<K, V> extends Abstract
else
{
// Not found : return a null cursor
- stack.push( new ParentPos<K, V>( this, -1 ) );
+ stack.push( new ParentPos<K, V>( null, -1 ) );
return new Cursor<K, V>( btree, transaction, stack );
}
Modified:
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/test/java/org/apache/mavibot/btree/InMemoryBTreeTest.java
URL:
http://svn.apache.org/viewvc/labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/test/java/org/apache/mavibot/btree/InMemoryBTreeTest.java?rev=1463028&r1=1463027&r2=1463028&view=diff
==============================================================================
---
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/test/java/org/apache/mavibot/btree/InMemoryBTreeTest.java
(original)
+++
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/test/java/org/apache/mavibot/btree/InMemoryBTreeTest.java
Sun Mar 31 18:25:43 2013
@@ -1004,6 +1004,33 @@ public class InMemoryBTreeTest
}
+ /**
+ * Test the browse method with a non existing key
+ * @throws Exception
+ */
+ @Test
+ public void testBrowseNonExistingKey() throws Exception
+ {
+ // Create a BTree with pages containing 8 elements
+ BTree<Integer, String> btree = new BTree<Integer, String>( "test", new
IntSerializer(), new StringSerializer() );
+ btree.setPageSize( 8 );
+ for( int i=0; i < 11; i++ )
+ {
+ btree.insert( i, String.valueOf( i ) );
+ }
+
+ for( int i=0; i < 11; i++ )
+ {
+ assertNotNull( btree.get( i ) );
+ }
+
+ assertFalse( btree.hasKey( 11 ) );
+
+ Cursor<Integer, String> cursor = btree.browse( 11 );
+ assertFalse( cursor.hasNext() );
+ }
+
+
private Page<Integer, String> createLeaf( BTree<Integer, String> btree,
long revision,
Tuple<Integer, String>... tuples )
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]