directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r642807 - /directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
Date Sun, 30 Mar 2008 20:04:30 GMT
Author: kayyagari
Date: Sun Mar 30 13:04:27 2008
New Revision: 642807

URL: http://svn.apache.org/viewvc?rev=642807&view=rev
Log:
added code for updating sublevel index during a move operation

Modified:
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=642807&r1=642806&r2=642807&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
Sun Mar 30 13:04:27 2008
@@ -1838,7 +1838,9 @@
          */
         oneLevelIdx.drop( oldParentId, childId );
         oneLevelIdx.add( newParentId, childId );
-
+        
+        updateSubLevelIndex( childId, oldParentId, newParentId );
+        
         /*
          * Build the new user provided DN (updn) for the child using the child's
          * user provided RDN & the new parent's UPDN.  Basically add the child's
@@ -1854,6 +1856,68 @@
     }
 
 
+    /**
+     * 
+     * updates the SubLevel Index as part of a move operation.
+     *
+     * @param childId child id to be moved
+     * @param oldParentId old parent's id
+     * @param newParentId new parent's id
+     * @throws Exception
+     */
+    private void updateSubLevelIndex( Long childId, Long oldParentId, Long newParentId )
throws Exception
+    {
+        Long tempId = oldParentId;
+        List<Long> parentIds = new ArrayList<Long>();
+
+        // find all the parents of the oldParentId
+        while( tempId != 0 && tempId != 1 && tempId != null )
+        {
+          parentIds.add( tempId );
+          tempId = getParentId( tempId );
+        }
+
+        // find all the children of the childId
+        Cursor<IndexEntry<Long,E>> cursor = subLevelIdx.forwardCursor( childId
);
+        
+        List<Long> childIds = new ArrayList<Long>();
+        childIds.add( childId );
+        
+        while( cursor.next() )
+        {
+            childIds.add( cursor.get().getId() );
+        }
+        
+        // detach the childId and all its children from oldParentId and all it parents excluding
the root
+        for( Long pid : parentIds )
+        {
+            for( Long cid: childIds )
+            {
+                subLevelIdx.drop( pid, cid );
+            }
+        }
+        
+        parentIds.clear();
+        tempId = newParentId;
+
+        // find all the parents of the newParentId
+        while( tempId != 0 && tempId != 1 && tempId != null )
+        {
+          parentIds.add( tempId );
+          tempId = getParentId( tempId );
+        }
+        
+        // attach the childId and all its children to newParentId and all it parents excluding
the root
+        for( Long id : parentIds )
+        {
+            for( Long cid: childIds )
+            {
+                subLevelIdx.add( id, cid );
+            }
+        }
+    }
+    
+    
     /**
      * For all aliases including and under the moved base, this method removes
      * one and subtree alias index tuples for old ancestors above the moved base



Mime
View raw message