directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1142155 - in /directory/apacheds/branches/apacheds-no-reverse-index: jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ xdbm-partition/src/main/java/org/apache/directory/server/xdbm/
Date Sat, 02 Jul 2011 05:25:26 GMT
Author: elecharny
Date: Sat Jul  2 05:25:26 2011
New Revision: 1142155

URL: http://svn.apache.org/viewvc?rev=1142155&view=rev
Log:
o Slightly fixed the testRenameEscaped() test
o Reworked the rename() operation in AbstractStore

Modified:
    directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java

Modified: directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=1142155&r1=1142154&r2=1142155&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
(original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
Sat Jul  2 05:25:26 2011
@@ -745,7 +745,7 @@ public class JdbmStoreTest
         Long id = store.getEntryId( dn2 );
         assertNotNull( id );
         Entry entry2 = store.lookup( id );
-        assertEquals( "ja+es", entry2.get( "sn" ).getString() );
+        assertEquals( "Ja\\+es", entry2.get( "sn" ).getString() );
     }
 
 

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java?rev=1142155&r1=1142154&r2=1142155&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
(original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
Sat Jul  2 05:25:26 2011
@@ -1272,7 +1272,7 @@ public abstract class AbstractStore<E, I
             entry = lookup( id );
         }
 
-        Dn updn = entry.getDn();
+        Dn entryDn = entry.getDn();
 
         newRdn.apply( schemaManager );
 
@@ -1284,15 +1284,12 @@ public abstract class AbstractStore<E, I
          * Also we make sure that the presence index shows the existence of the
          * new Rdn attribute within this entry.
          */
-
         for ( Ava newAtav : newRdn )
         {
             String newNormType = newAtav.getNormType();
             Object newNormValue = newAtav.getNormValue().getValue();
 
-            AttributeType newRdnAttrType = schemaManager.lookupAttributeTypeRegistry( newNormType
);
-
-            entry.add( newRdnAttrType, newAtav.getNormValue() );
+            entry.add( newAtav.getAttributeType(), newAtav.getUpValue() );
 
             if ( hasUserIndexOn( newNormType ) )
             {
@@ -1326,7 +1323,7 @@ public abstract class AbstractStore<E, I
 
         if ( deleteOldRdn )
         {
-            Rdn oldRdn = updn.getRdn();
+            Rdn oldRdn = entryDn.getRdn();
 
             for ( Ava oldAtav : oldRdn )
             {
@@ -1347,9 +1344,10 @@ public abstract class AbstractStore<E, I
                 {
                     String oldNormType = oldAtav.getNormType();
                     String oldNormValue = oldAtav.getNormValue().getString();
-                    AttributeType oldRdnAttrType = schemaManager.lookupAttributeTypeRegistry(
oldNormType );
-                    entry.remove( oldRdnAttrType, oldNormValue );
+                    AttributeType oldRdnAttrType = oldAtav.getAttributeType();
+                    entry.remove( oldRdnAttrType, oldAtav.getNormValue() );
 
+                    // Remove the RDN value from the user index, if any
                     if ( hasUserIndexOn( oldNormType ) )
                     {
                         Index<?, E, ID> index = getUserIndex( oldNormType );
@@ -1359,7 +1357,7 @@ public abstract class AbstractStore<E, I
                          * If there is no value for id in this index due to our
                          * drop above we remove the oldRdnAttr from the presence idx
                          */
-                        if ( null == index.reverseLookup( id ) )
+                        if ( presenceIdx.forward( oldNormValue, id ) )
                         {
                             presenceIdx.drop( oldNormType, id );
                         }
@@ -1375,11 +1373,22 @@ public abstract class AbstractStore<E, I
          * We only need to update the Rdn index.
          * No need to calculate the new Dn.
          */
+        List<ID> parentIds = getParentIds( entryDn );
+        ID rootId = getRootId();
+        ID parentId = rootId;
+        
+        if ( parentIds.size() > 2 )
+        {
+            parentId = parentIds.get( parentIds.size() - 1 );
+        }
+
+        // Drop the RDN
+        ParentIdAndRdn<ID> key = new ParentIdAndRdn<ID>( parentId, entryDn.getRdn()
);
+
+        rdnIdx.drop( key, id );
 
-        ID parentId = getParentId( id );
-        rdnIdx.drop( id );
-        ParentIdAndRdn<ID> key = new ParentIdAndRdn<ID>( parentId, newRdn );
-        rdnIdx.add( key, id );
+        ParentIdAndRdn<ID> newKey = new ParentIdAndRdn<ID>( parentId, newRdn
);
+        rdnIdx.add( newKey, id );
 
         master.put( id, entry );
 



Mime
View raw message