You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by el...@apache.org on 2013/04/03 10:48:01 UTC

svn commit: r1463882 - /labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/store/RecordManager.java

Author: elecharny
Date: Wed Apr  3 08:48:01 2013
New Revision: 1463882

URL: http://svn.apache.org/r1463882
Log:
Added a Revision BTree (used to manage old revisions we want to keep)

Modified:
    labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/store/RecordManager.java

Modified: labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/store/RecordManager.java
URL: http://svn.apache.org/viewvc/labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/store/RecordManager.java?rev=1463882&r1=1463881&r2=1463882&view=diff
==============================================================================
--- labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/store/RecordManager.java (original)
+++ labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/store/RecordManager.java Wed Apr  3 08:48:01 2013
@@ -90,6 +90,9 @@ public class RecordManager
      **/
     private BTree<Integer, long[]> copiedPageBTree;
 
+    /** A BTree used to store all the vlid revisions for all the stroed BTrees */
+    private BTree<RevisionName, long[]> revisionBTree;
+
     /** A constant for an offset on a non existing page */
     private static final long NO_PAGE = -1L;
 
@@ -235,7 +238,8 @@ public class RecordManager
 
 
     /**
-     * We will create a brand new RecordManager file, containing nothing, but the header and
+     * We will create a brand new RecordManager file, containing nothing, but the header, 
+     * a BTree to manage the old revisions we want to keep and
      * a BTree used to manage pages associated with old versions.
      * <br/>
      * The Header contains the following informations :
@@ -253,6 +257,8 @@ public class RecordManager
      * 
      * We then store the BTree managing the pages that have been copied when we have added
      * or deleted an element in the BTree. They are associated with a version.
+     * 
+     * Last, we add the bTree that keep a track on each revision we can have access to.
      */
     private void initRecordManager() throws IOException
     {
@@ -265,13 +271,18 @@ public class RecordManager
         // Set the offset of the end of the file
         endOfFileOffset = fileChannel.size();
 
-        // Now, initialize the Discarded Page BTree, which is a in-memory BTree
+        // Now, initialize the Copied Page BTree
         copiedPageBTree = new BTree<Integer, long[]>( "copiedPageBTree", new IntSerializer(), new LongArraySerializer() );
 
-        // Inject this BTree into the RecordManager
+        // and initialize the Revision BTree
+        revisionBTree = new BTree<RevisionName, long[]>( "revisionBTree", new RevisionNameSerializer(),
+            new LongArraySerializer() );
+
+        // Inject these BTrees into the RecordManager
         try
         {
             manage( copiedPageBTree );
+            manage( revisionBTree );
         }
         catch ( BTreeAlreadyManagedException btame )
         {
@@ -327,8 +338,17 @@ public class RecordManager
             loadBTree( pageIos, copiedPageBTree );
             long nextBtreeOffset = copiedPageBTree.getNextBTreeOffset();
 
+            // And the Revision BTree
+            pageIos = readPages( nextBtreeOffset, Long.MAX_VALUE );
+
+            revisionBTree = BTreeFactory.createBTree();
+            revisionBTree.setBtreeOffset( nextBtreeOffset );
+
+            loadBTree( pageIos, revisionBTree );
+            nextBtreeOffset = revisionBTree.getNextBTreeOffset();
+
             // Then process the next ones
-            for ( int i = 1; i < nbBtree; i++ )
+            for ( int i = 2; i < nbBtree; i++ )
             {
                 // Create the BTree
                 BTree<?, ?> btree = BTreeFactory.createBTree();
@@ -1832,18 +1852,18 @@ public class RecordManager
 
 
     /**
-     * Get the number of managed trees. We don't count the CopiedPage BTree.
+     * Get the number of managed trees. We don't count the CopiedPage BTree. and the Revsion BTree
      * 
      * @return The number of managed BTrees
      */
     public int getNbManagedTrees()
     {
-        return nbBtree - 1;
+        return nbBtree - 2;
     }
 
 
     /**
-     * Get the managed trees. We don't return the CopiedPage BTree.
+     * Get the managed trees. We don't return the CopiedPage BTree nor the Revision BTree.
      * 
      * @return The managed BTrees
      */



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org