directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1625361 - /directory/mavibot/branches/free-page-mgmt/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java
Date Tue, 16 Sep 2014 19:33:59 GMT
Author: kayyagari
Date: Tue Sep 16 19:33:59 2014
New Revision: 1625361

URL: http://svn.apache.org/r1625361
Log:
fixed some edge cases

Modified:
    directory/mavibot/branches/free-page-mgmt/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java

Modified: directory/mavibot/branches/free-page-mgmt/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/free-page-mgmt/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java?rev=1625361&r1=1625360&r2=1625361&view=diff
==============================================================================
--- directory/mavibot/branches/free-page-mgmt/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java
(original)
+++ directory/mavibot/branches/free-page-mgmt/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java
Tue Sep 16 19:33:59 2014
@@ -3950,7 +3950,7 @@ public class RecordManager extends Abstr
                 {
                     if( page instanceof PersistedNode )
                     {
-                        page = ( AbstractPage ) page.children[-(pos+1)].getValue();
+                        page = ( AbstractPage ) page.children[-(pos+1) + 1].getValue();
                         pos = page.findPos( key );
                         stack.push( new ParentPos( page, pos ) );
                     }
@@ -4017,6 +4017,14 @@ public class RecordManager extends Abstr
                         pageHolder = ( PersistedPageHolder ) writePage( tree, newLeaf, revision
);
                         leftKey = newLeaf.keys[0];
                     }
+                    else
+                    {
+                        if ( page.offset == root.offset )
+                        {
+                            PersistedLeaf newLeaf = ( PersistedLeaf ) BTreeFactory.createLeaf(
tree, revision, nbElems );
+                            pageHolder = ( PersistedPageHolder ) writePage( tree, newLeaf,
revision );
+                        }
+                    }
                     
                     if( tree.isAllowDuplicates() )
                     {
@@ -4044,7 +4052,7 @@ public class RecordManager extends Abstr
                         actPos = -( actPos + 1 );
                     }
                     
-                    int nbElems = node.nbElems - actPos - 1;
+                    int nbElems = node.nbElems;
                     int copyStartPos = actPos;
                     
                     // no child to point to
@@ -4053,6 +4061,19 @@ public class RecordManager extends Abstr
                         nbElems--;
                         copyStartPos = actPos + 1;
                     }
+                    else if ( pp.pos < 0 )
+                    {
+                        nbElems = node.nbElems - actPos - 1;
+                        copyStartPos = actPos + 1;
+                    }
+                    
+                    if ( ( pageHolder != null ) && ( nbElems == 0 ) )
+                    {
+                        if( node.children.length == 2 )
+                        {
+                            nbElems = 1;
+                        }
+                    }
                     
                     if( nbElems != 0 )
                     {
@@ -4069,10 +4090,22 @@ public class RecordManager extends Abstr
                         
                         pageHolder = ( PersistedPageHolder ) writePage( tree, newNode, revision
);
                         leftKey = newNode.keys[0];
+                        
+                        free( page.offset );
                     }
                     else
                     {
                         free( page.offset );
+                        
+                        if ( page.offset == root.offset )
+                        {
+                            pageHolder = new PersistedPageHolder( tree, page.children[actPos
+ 1].getValue() );
+                        }
+                        else
+                        {
+                            PersistedNode newNode = ( PersistedNode ) BTreeFactory.createNode(
tree, revision, 1 );
+                            //newNode.keys[0].key = leftKey;
+                        }
                     }
                 }
             }
@@ -4099,6 +4132,9 @@ public class RecordManager extends Abstr
     }
     
 
+    /**
+     * counts the number of keys present upto and including the given key
+     */
     /** no qualifier */ long countKeysUpto( Object key, BTree tree )
     {
         // count number of keys to be removed



Mime
View raw message