directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1621483 - in /directory/mavibot/branches/free-page-mgmt/mavibot/src/main/java/org/apache/directory/mavibot/btree: AbstractValueHolder.java InMemoryValueHolder.java PersistedValueHolder.java
Date Sat, 30 Aug 2014 16:22:23 GMT
Author: kayyagari
Date: Sat Aug 30 16:22:23 2014
New Revision: 1621483

URL: http://svn.apache.org/r1621483
Log:
fixed the way sub-btree is built

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

Modified: directory/mavibot/branches/free-page-mgmt/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractValueHolder.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/free-page-mgmt/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractValueHolder.java?rev=1621483&r1=1621482&r2=1621483&view=diff
==============================================================================
--- directory/mavibot/branches/free-page-mgmt/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractValueHolder.java
(original)
+++ directory/mavibot/branches/free-page-mgmt/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractValueHolder.java
Sat Aug 30 16:22:23 2014
@@ -273,7 +273,18 @@ import org.apache.directory.mavibot.btre
      */
     protected abstract void createSubTree();
 
+    
+    /**
+     * Constructs the sub-BTree using bulkload instead of performing sequential inserts.
+     * 
+     * @param btree the sub-BTtree to be constructed
+     * @param dupKeyValues the array of values to be inserted as keys
+     * @return
+     * @throws Exception
+     */
+    protected abstract BTree buildSubBTree( BTree<V, V> btree, V[] dupKeyValues ) throws
Exception;
 
+    
     /**
      * Add the value in an array
      */
@@ -287,13 +298,8 @@ import org.apache.directory.mavibot.btre
 
             try
             {
-                for ( V val : valueArray )
-                {
-                    // Here, we should insert all the values in one shot then 
-                    // write the btree on disk only once.
-                    valueBtree.insert( val, null );
-                }
-
+                buildSubBTree( valueBtree, valueArray );
+                
                 // We can delete the array now
                 nbArrayElems = 0;
                 valueArray = null;
@@ -301,7 +307,7 @@ import org.apache.directory.mavibot.btre
                 // And inject the new value
                 valueBtree.insert( value, null );
             }
-            catch ( IOException e )
+            catch ( Exception e )
             {
                 // TODO Auto-generated catch block
                 e.printStackTrace();
@@ -318,6 +324,8 @@ import org.apache.directory.mavibot.btre
             }
             else
             {
+                //FIXME delete the sub-btree if the valueThresholdLow is reached
+                
                 // check that the value is not already present in the ValueHolder
                 int pos = findPos( value );
 

Modified: directory/mavibot/branches/free-page-mgmt/mavibot/src/main/java/org/apache/directory/mavibot/btree/InMemoryValueHolder.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/free-page-mgmt/mavibot/src/main/java/org/apache/directory/mavibot/btree/InMemoryValueHolder.java?rev=1621483&r1=1621482&r2=1621483&view=diff
==============================================================================
--- directory/mavibot/branches/free-page-mgmt/mavibot/src/main/java/org/apache/directory/mavibot/btree/InMemoryValueHolder.java
(original)
+++ directory/mavibot/branches/free-page-mgmt/mavibot/src/main/java/org/apache/directory/mavibot/btree/InMemoryValueHolder.java
Sat Aug 30 16:22:23 2014
@@ -134,6 +134,23 @@ import org.apache.directory.mavibot.btre
 
 
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected BTree buildSubBTree( BTree<V, V> btree, V[] dupKeyValues ) throws Exception
+    {
+        for ( V val : dupKeyValues )
+        {
+            // Here, we should insert all the values in one shot then 
+            // write the btree on disk only once.
+            valueBtree.insert( val, null );
+        }
+        
+        return valueBtree;
+    }
+
+
+    /**
      * Set the subBtree in the ValueHolder
      */
     /* No qualifier*/void setSubBtree( BTree<V, V> subBtree )

Modified: directory/mavibot/branches/free-page-mgmt/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedValueHolder.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/free-page-mgmt/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedValueHolder.java?rev=1621483&r1=1621482&r2=1621483&view=diff
==============================================================================
--- directory/mavibot/branches/free-page-mgmt/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedValueHolder.java
(original)
+++ directory/mavibot/branches/free-page-mgmt/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedValueHolder.java
Sat Aug 30 16:22:23 2014
@@ -708,19 +708,15 @@ import static org.apache.directory.mavib
 
 
     /**
-     * Constructs the sub-BTree using bulkload instead of performing sequential inserts.
-     * 
-     * @param btree the sub-BTtree to be constructed
-     * @param dupKeyValues the array of values to be inserted as keys
-     * @return
-     * @throws Exception
+     * {@inheritDoc}
      */
-    private BTree build( PersistedBTree<V, V> btree, V[] dupKeyValues ) throws Exception
+    protected BTree buildSubBTree( BTree<V, V> givenBTree, V[] dupKeyValues ) throws
Exception
     {
+        PersistedBTree<V, V> btree = ( PersistedBTree<V, V> ) givenBTree;
+        
         long newRevision = btree.getRevision() + 1;
         
         int numKeysInNode = btree.getPageSize();
-        
         RecordManager rm = btree.getRecordManager();
         
         List<Page<V, V>> lstLeaves = new ArrayList<Page<V, V>>();
@@ -787,7 +783,7 @@ import static org.apache.directory.mavib
         Page oldRoot = btree.getRootPage();
         
         long newRootPageOffset = ( ( AbstractPage ) rootPage ).getOffset();
-        System.out.println( "replacing old offset " + btree.getRootPageOffset() + " of the
BTree " + btree.getName() + " with " + newRootPageOffset );
+        //System.out.println( "replacing old offset " + btree.getRootPageOffset() + " of
the BTree " + btree.getName() + " with " + newRootPageOffset );
         
         BTreeHeader header = btree.getBtreeHeader();
         
@@ -799,7 +795,7 @@ import static org.apache.directory.mavib
         
         header.setBTreeHeaderOffset( newBtreeHeaderOffset );
         
-        rm.freePages( ( BTree ) btree, btree.getRevision(), ( List ) Arrays.asList( oldRoot
) );
+        rm.free( ( ( AbstractPage ) oldRoot ).getOffset() );
 
         return btree;
     }



Mime
View raw message