directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r676922 - in /directory/apacheds/branches/bigbang/jdbm-store/src: main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursor.java test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursorTest.java
Date Tue, 15 Jul 2008 14:00:30 GMT
Author: kayyagari
Date: Tue Jul 15 07:00:28 2008
New Revision: 676922

URL: http://svn.apache.org/viewvc?rev=676922&view=rev
Log:
fixed an issue related to JDBM browser switch happening when calling browser.getPrevious()
after calling browser.getNext()
Added a test case to verify this

Modified:
    directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursor.java
    directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursorTest.java

Modified: directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursor.java?rev=676922&r1=676921&r2=676922&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursor.java
(original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursor.java
Tue Jul 15 07:00:28 2008
@@ -179,6 +179,15 @@
 
         if ( browser.getPrevious( jdbmTuple ) )
         {
+            if( returnedTuple.getKey() != null )
+            {
+                if( table.getKeyComparator().compare(
+                    ( K) jdbmTuple.getKey(), ( K) returnedTuple.getKey() ) == 0 )
+                {
+                    browser.getPrevious( jdbmTuple );
+                }
+            }
+
             //noinspection unchecked
             returnedTuple.setKey( ( K ) jdbmTuple.getKey() );
             //noinspection unchecked
@@ -202,6 +211,15 @@
 
         if ( browser.getNext( jdbmTuple ) )
         {
+            if( returnedTuple.getKey() != null )
+            {
+                if( table.getKeyComparator().compare(
+                    ( K) jdbmTuple.getKey(), ( K) returnedTuple.getKey() ) == 0 )
+                {
+                    browser.getNext( jdbmTuple );
+                }
+            }
+            
             //noinspection unchecked
             returnedTuple.setKey( ( K ) jdbmTuple.getKey() );
             //noinspection unchecked

Modified: directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursorTest.java?rev=676922&r1=676921&r2=676922&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursorTest.java
(original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursorTest.java
Tue Jul 15 07:00:28 2008
@@ -184,6 +184,68 @@
     
 
     @Test
+    public void testJdbmBrowserSwitch() throws Exception
+    {
+        for( int i=1; i < 10; i++ )
+        {
+            table.put( i, i );
+        }
+    
+        Cursor<Tuple<Integer,Integer>> cursor = table.cursor();
+        
+        // go to last and call next then previous twice then next
+        cursor.afterLast();
+        assertFalse( cursor.next() );
+        assertTrue( cursor.previous() );
+        assertEquals( 9, ( int ) cursor.get().getKey() );
+        
+        assertTrue( cursor.previous() );
+        assertEquals( 8, ( int ) cursor.get().getKey() );
+
+        assertTrue( cursor.next() );
+         assertEquals( 9, ( int ) cursor.get().getKey() );
+ 
+        
+        // go to last and call previous then next and again previous 
+        cursor.afterLast();
+        assertTrue( cursor.previous() );
+        assertEquals( 9, ( int ) cursor.get().getKey() );
+        
+        assertTrue( cursor.next() );
+        assertEquals( 9, ( int ) cursor.get().getKey() );
+        
+        assertTrue( cursor.previous() );
+        assertEquals( 8, ( int ) cursor.get().getKey() );
+        
+        
+        // go to first and call previous then next twice and again next
+        cursor.beforeFirst();
+        assertFalse( cursor.previous() );
+        assertTrue( cursor.next() );
+        assertEquals( 1, ( int ) cursor.get().getKey() );
+
+        assertTrue( cursor.next() );
+        assertEquals( 2, ( int ) cursor.get().getKey() );
+        
+        assertTrue( cursor.previous() );
+        assertEquals( 1, ( int ) cursor.get().getKey() );
+
+
+        // go to first and call next twice then previous
+        cursor.beforeFirst();
+        assertTrue( cursor.next() );
+        assertEquals( 1, ( int ) cursor.get().getKey() );
+
+        assertTrue( cursor.next() );
+        assertEquals( 2, ( int ) cursor.get().getKey() );
+        
+        assertTrue( cursor.previous() );
+        assertEquals( 1, ( int ) cursor.get().getKey() );
+
+    }
+    
+    
+    @Test
     public void testMiscellaneous() throws Exception
     {
     }



Mime
View raw message