directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1375954 - /directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlIndex.java
Date Wed, 22 Aug 2012 09:24:22 GMT
Author: elecharny
Date: Wed Aug 22 09:24:21 2012
New Revision: 1375954

URL: http://svn.apache.org/viewvc?rev=1375954&view=rev
Log:
Simplified the removal of an ID when we don't allow duplicates

Modified:
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlIndex.java

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlIndex.java?rev=1375954&r1=1375953&r2=1375954&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlIndex.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlIndex.java
Wed Aug 22 09:24:21 2012
@@ -123,7 +123,7 @@ public class AvlIndex<K, O> extends Abst
     public void add( K attrVal, Long id ) throws Exception
     {
         forward.put( attrVal, id );
-        
+
         if ( withReverse )
         {
             reverse.put( id, attrVal );
@@ -173,16 +173,25 @@ public class AvlIndex<K, O> extends Abst
     {
         if ( withReverse )
         {
-            Cursor<Tuple<Long, K>> cursor = reverse.cursor( id );
-    
-            while ( cursor.next() )
+            if ( isDupsEnabled() )
+            {
+                Cursor<Tuple<Long, K>> cursor = reverse.cursor( id );
+
+                while ( cursor.next() )
+                {
+                    Tuple<Long, K> tuple = cursor.get();
+                    forward.remove( tuple.getValue(), id );
+                }
+
+                cursor.close();
+
+            }
+            else
             {
-                Tuple<Long, K> tuple = cursor.get();
-                forward.remove( tuple.getValue(), id );
+                K key = reverse.get( id );
+                forward.remove( key );
             }
-            
-            cursor.close();
-    
+
             reverse.remove( id );
         }
     }
@@ -194,7 +203,7 @@ public class AvlIndex<K, O> extends Abst
     public void drop( K attrVal, Long id ) throws Exception
     {
         forward.remove( attrVal, id );
-        
+
         if ( withReverse )
         {
             reverse.remove( id, attrVal );



Mime
View raw message