directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1375965 - /directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
Date Wed, 22 Aug 2012 10:02:41 GMT
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 );
         }
     }



Mime
View raw message