directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r773948 - in /directory/apacheds/trunk: jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ xdbm-base/src/main/java/org/apache/directory/server/xdbm/
Date Tue, 12 May 2009 15:46:41 GMT
Author: elecharny
Date: Tue May 12 15:46:41 2009
New Revision: 773948

URL: http://svn.apache.org/viewvc?rev=773948&view=rev
Log:
Fixed the way index are updated when removing some element. The cursor was not stopping once
the element has been removed, leading to very slow removals.

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

Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java?rev=773948&r1=773947&r2=773948&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
(original)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
Tue May 12 15:46:41 2009
@@ -482,6 +482,13 @@
         while ( values.next() )
         {
             forward.remove( values.get().getValue(), id );
+
+            boolean removed = forward.remove( values.get().getValue(), id );
+            
+            if ( !removed )
+            {
+                break;
+            }
         }
 
         reverse.remove( id );

Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java?rev=773948&r1=773947&r2=773948&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
(original)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
Tue May 12 15:46:41 2009
@@ -631,11 +631,11 @@
      * java.lang.Object)
      */
     @SuppressWarnings("unchecked")
-    public void remove( K key, V value ) throws IOException
+    public boolean remove( K key, V value ) throws IOException
     {
         if ( key == null )
         {
-            return;
+            return false;
         }
 
         if ( ! allowsDuplicates )
@@ -643,17 +643,18 @@
             V oldValue = ( V ) bt.find( key );
         
             // Remove the value only if it is the same as value.
-            if ( oldValue != null && oldValue.equals( value ) )
+            if ( ( oldValue != null ) && oldValue.equals( value ) )
             {
                 bt.remove( key );
                 count--;
-                return;
+                return true;
             }
 
-            return;
+            return false;
         }
 
         DupsContainer<V> values = getDupsContainer( ( byte[] ) bt.find( key ) );
+        
         if ( values.isAvlTree() )
         {
             AvlTree<V> set = values.getAvlTree();
@@ -670,14 +671,15 @@
                     bt.insert( key, marshaller.serialize( set ), true );
                 }
                 count--;
-                return;
+                return true ;
             }
 
-            return;
+            return false;
         }
 
         // if the number of duplicates falls below the numDupLimit value
         BTree tree = getBTree( values.getBTreeRedirect() );
+        
         if ( removeDupFromBTree( tree, value ) )
         {
             /*
@@ -692,32 +694,34 @@
             }
             
             count--;
+            return true;
         }
         
+        return false;
     }
 
 
     /**
      * @see Table#remove(Object)
      */
-    public void remove( K key ) throws IOException
+    public boolean remove( K key ) throws IOException
     {
         if ( key == null )
         {
-            return;
+            return false;
         }
 
         Object returned = bt.remove( key );
 
         if ( null == returned )
         {
-            return;
+            return false;
         }
 
         if ( ! allowsDuplicates )
         {
             this.count--;
-            return;
+            return true;
         }
 
         byte[] serialized = ( byte[] ) returned;
@@ -726,13 +730,13 @@
         {
             BTree tree = getBTree( BTreeRedirectMarshaller.INSTANCE.deserialize( serialized
) );
             this.count -= tree.size();
-            return;
+            return true;
         }
         else
         {
             AvlTree<V> set = marshaller.deserialize( serialized );
             this.count -= set.getSize();
-            return;
+            return true;
         }
     }
 

Modified: directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Table.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Table.java?rev=773948&r1=773947&r2=773948&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Table.java
(original)
+++ directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Table.java
Tue May 12 15:46:41 2009
@@ -227,7 +227,7 @@
      * @throws Exception if there is a failure to read or write to
      * the underlying Db
      */
-    void remove( K key ) throws Exception;
+    boolean remove( K key ) throws Exception;
 
 
     /**
@@ -239,7 +239,7 @@
      * @throws Exception if there is a failure to read or write to
      * the underlying Db
      */
-    void remove( K key, V value ) throws Exception;
+    boolean remove( K key, V value ) throws Exception;
 
 
     /**



Mime
View raw message