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 2013/06/18 23:47:32 UTC

svn commit: r1494328 - /directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java

Author: elecharny
Date: Tue Jun 18 21:47:32 2013
New Revision: 1494328

URL: http://svn.apache.org/r1494328
Log:
Fixed the index updated when doing a modify with a replace when we have indexed attributes (cf DIRSERVER-1854)

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

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java?rev=1494328&r1=1494327&r2=1494328&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java Tue Jun 18 21:47:32 2013
@@ -1340,23 +1340,27 @@ public abstract class AbstractBTreeParti
         {
             Index<?, Entry, String> index = getUserIndex( attributeType );
 
-            // if the id exists in the index drop all existing attribute
-            // value index entries and add new ones
-            if ( index.reverse( id ) )
+            // Drop all the previous values
+            Attribute oldAttribute = entry.get( mods.getAttributeType() );
+
+            if ( oldAttribute != null )
             {
-                ( ( Index<?, Entry, String> ) index ).drop( id );
+                for ( Value<?> value : oldAttribute )
+                {
+                    ( ( Index<Object, Entry, String> ) index ).drop( value.getNormValue(), id );
+                }
             }
 
+            // And add the new ones
             for ( Value<?> value : mods )
             {
                 ( ( Index<Object, Entry, String> ) index ).add( value.getNormValue(), id );
             }
 
             /*
-             * If no attribute values exist for this entryId in the index then
-             * we remove the presence index entry for the removed attribute.
+             * If we have no new value, we have to drop the AT fro the presence index
              */
-            if ( null == index.reverseLookup( id ) )
+            if ( mods.size() == 0 )
             {
                 presenceIdx.drop( modsOid, id );
             }