directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r637355 - in /directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src: main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/
Date Sat, 15 Mar 2008 05:05:50 GMT
Author: akarasulu
Date: Fri Mar 14 22:05:48 2008
New Revision: 637355

URL: http://svn.apache.org/viewvc?rev=637355&view=rev
Log:
more tests and some cleanup of last and first methods on dups cursor

Modified:
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDupsCursor.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDupsCursorTest.java

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDupsCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDupsCursor.java?rev=637355&r1=637354&r2=637355&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDupsCursor.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDupsCursor.java
Fri Mar 14 22:05:48 2008
@@ -142,29 +142,35 @@
         if ( containerCursor.first() )
         {
             containerTuple.setBoth( containerCursor.get() );
+            DupsContainer<V> values = containerTuple.getValue();
 
             if ( containerTuple.getValue().isAvlTree() )
             {
-                dupsCursor = new AvlTreeCursor<V>( containerTuple.getValue().getAvlTree()
);
+                dupsCursor = new AvlTreeCursor<V>( values.getAvlTree() );
             }
             else
             {
-                BTree bt = table.getBTree( containerTuple.getValue().getBTreeRedirect() );
+                BTree bt = table.getBTree( values.getBTreeRedirect() );
                 dupsCursor = new KeyCursor<V>( bt, table.getValueComparator() );
             }
 
-            if ( ! dupsCursor.next() )
+            // *** meant to be an assignment = instead of == ***
+            if ( valueAvailable = dupsCursor.first() )
+            {
+                returnedTuple.setKey( containerTuple.getKey() );
+                returnedTuple.setValue( dupsCursor.get() );
+            }
+            else
             {
                 clearValue();
-                return false;
+                dupsCursor = null;
             }
 
-            returnedTuple.setKey( containerTuple.getKey() );
-            returnedTuple.setValue( dupsCursor.get() );
-            return valueAvailable = true;
+            return valueAvailable;
         }
 
         clearValue();
+        dupsCursor = null;
         return false;
     }
 
@@ -172,9 +178,41 @@
     public boolean last() throws Exception
     {
         clearValue();
+        if ( containerCursor.last() )
+        {
+            containerTuple.setBoth( containerCursor.get() );
+            DupsContainer<V> values = containerTuple.getValue();
+
+            if ( values.isAvlTree() )
+            {
+                AvlTree<V> set = values.getAvlTree();
+                dupsCursor = new AvlTreeCursor<V>( set );
+            }
+            else if ( values.isBTreeRedirect() )
+            {
+                BTree tree = table.getBTree( values.getBTreeRedirect() );
+                dupsCursor = new KeyCursor<V>( tree, table.getValueComparator() );
+            }
+
+            // *** meant to be an assignment = instead of == ***
+            if ( valueAvailable = dupsCursor.last() )
+            {
+                returnedTuple.setKey( containerTuple.getKey() );
+                returnedTuple.setValue( dupsCursor.get() );
+            }
+            else
+            {
+                clearValue();
+                dupsCursor = null;
+            }
+            return valueAvailable;
+        }
+
+        clearValue();
         dupsCursor = null;
-        return valueAvailable = containerCursor.last();
+        return false;
     }
+
 
 
     private void clearValue()

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDupsCursorTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDupsCursorTest.java?rev=637355&r1=637354&r2=637355&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDupsCursorTest.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDupsCursorTest.java
Fri Mar 14 22:05:48 2008
@@ -236,9 +236,9 @@
             ii++;
         }
 
-        cursor.beforeFirst();
+        cursor.first();
         ii = 0;
-        while ( cursor.next() )
+        do
         {
             Tuple<Integer,Integer> tuple = cursor.get();
             if ( ii > 12 && ii < 17 )
@@ -253,6 +253,7 @@
             }
             ii++;
         }
+        while ( cursor.next() );
 
         // now go backwards
         ii = SIZE*2-2;
@@ -273,9 +274,9 @@
         }
 
         // now advance to last and go backwards again
-        cursor.afterLast();
+        cursor.last();
         ii = SIZE*2-2;
-        while ( cursor.previous() )
+        do
         {
             Tuple<Integer,Integer> tuple = cursor.get();
             if ( ii > 12 && ii < 17 )
@@ -290,6 +291,7 @@
             }
             ii--;
         }
+        while ( cursor.previous() );
 
         // advance to first then last and go backwards again
         cursor.beforeFirst();
@@ -354,15 +356,16 @@
         }
 
         // now advance to last and go backwards again
-        cursor.afterLast();
+        cursor.last();
         ii = SIZE*3-2;
-        while ( cursor.previous() )
+        do
         {
             Tuple<Integer,Integer> tuple = cursor.get();
             assertEquals( ii, ( int ) tuple.getKey() );
             assertEquals( ii, ( int ) tuple.getValue() );
             ii--;
         }
+        while ( cursor.previous() );
 
         // advance to first then last and go backwards again
         cursor.beforeFirst();



Mime
View raw message