You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2012/08/22 12:02:41 UTC

svn commit: r1375965 - /directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java

Author: elecharny
Date: Wed Aug 22 10:02:40 2012
New Revision: 1375965

URL: http://svn.apache.org/viewvc?rev=1375965&view=rev
Log:
Simplified the drop when we don't have duplicates, not using a cursor.

Modified:
    directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java

Modified: directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java?rev=1375965&r1=1375964&r2=1375965&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java Wed Aug 22 10:02:40 2012
@@ -415,21 +415,30 @@ public class JdbmIndex<K, O> extends Abs
      */
     public void drop( Long entryId ) throws Exception
     {
-        // Build a cursor to iterate on all the keys referencing
-        // this entryId
-        Cursor<Tuple<Long, K>> values = reverse.cursor( entryId );
-
-        while ( values.next() )
-        {
-            // Remove the Key -> entryId from the index
-            forward.remove( values.get().getValue(), entryId );
-        }
-        
-        values.close();
-
-        // Remove the id -> key from the reverse index
         if ( withReverse )
         {
+            if ( isDupsEnabled() )
+            {
+                // Build a cursor to iterate on all the keys referencing
+                // this entryId
+                Cursor<Tuple<Long, K>> values = reverse.cursor( entryId );
+
+                while ( values.next() )
+                {
+                    // Remove the Key -> entryId from the index
+                    forward.remove( values.get().getValue(), entryId );
+                }
+
+                values.close();
+            }
+            else
+            {
+                K key = reverse.get( entryId );
+
+                forward.remove( key );
+            }
+
+            // Remove the id -> key from the reverse index
             reverse.remove( entryId );
         }
     }