Author: elecharny
Date: Sun Mar 17 22:35:18 2013
New Revision: 1457577

URL: http://svn.apache.org/r1457577
Log:
o Added the code that fetch an element from the disk, when it's not present in 
memory
o Propagated various exceptions up to the top
o The RecordManager was not stored into a BTree we read from disk, leading to 
NPEs

Modified:
    
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/AbstractPage.java
    
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Cursor.java
    
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/ElementHolder.java
    labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java
    labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Node.java
    labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Page.java
    
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/ReferenceHolder.java
    
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/store/RecordManager.java

Modified: 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/AbstractPage.java
URL: 
http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/AbstractPage.java?rev=1457577&r1=1457576&r2=1457577&view=diff
==============================================================================
--- 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/AbstractPage.java
 (original)
+++ 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/AbstractPage.java
 Sun Mar 17 22:35:18 2013
@@ -20,8 +20,11 @@
 package org.apache.mavibot.btree;
 
 
+import java.io.IOException;
 import java.lang.reflect.Array;
 
+import org.apache.mavibot.btree.exception.EndOfFileExceededException;
+
 
 /**
  * A MVCC abstract Page. It stores the field and the methods shared by the 
Node and Leaf
@@ -86,8 +89,10 @@ public abstract class AbstractPage<K, V>
      * @param parent The parent of the current page
      * @param The position of the current page reference in its parent
      * @return The position of the sibling, or -1 if we have'nt found any 
sibling
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    protected int selectSibling( Node<K, V> parent, int parentPos )
+    protected int selectSibling( Node<K, V> parent, int parentPos ) throws 
EndOfFileExceededException, IOException
     {
         if ( parentPos == 0 )
         {

Modified: 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Cursor.java
URL: 
http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Cursor.java?rev=1457577&r1=1457576&r2=1457577&view=diff
==============================================================================
--- 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Cursor.java 
(original)
+++ 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Cursor.java 
Sun Mar 17 22:35:18 2013
@@ -20,8 +20,11 @@
 package org.apache.mavibot.btree;
 
 
+import java.io.IOException;
 import java.util.LinkedList;
 
+import org.apache.mavibot.btree.exception.EndOfFileExceededException;
+
 
 /**
  * A Cursor is used to fetch elements in a BTree and is returned by the
@@ -67,8 +70,10 @@ import java.util.LinkedList;
      * Find the next key/value
      * 
      * @return A Tuple containing the found key and value
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    /* No qualifier */Tuple<K, V> next()
+    /* No qualifier */Tuple<K, V> next() throws EndOfFileExceededException, 
IOException
     {
         ParentPos<K, V> parentPos = stack.getFirst();
 
@@ -104,8 +109,10 @@ import java.util.LinkedList;
      * Find the leaf containing the following elements.
      * 
      * @return the new ParentPos instance, or null if we have no following leaf
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    private ParentPos<K, V> findNextParentPos()
+    private ParentPos<K, V> findNextParentPos() throws 
EndOfFileExceededException, IOException
     {
         while ( true )
         {
@@ -150,8 +157,10 @@ import java.util.LinkedList;
      * Find the leaf containing the previous elements.
      * 
      * @return the new ParentPos instance, or null if we have no previous leaf
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    private ParentPos<K, V> findPreviousParentPos()
+    private ParentPos<K, V> findPreviousParentPos() throws 
EndOfFileExceededException, IOException
     {
         while ( true )
         {
@@ -197,8 +206,10 @@ import java.util.LinkedList;
      * Find the previous key/value
      * 
      * @return A Tuple containing the found key and value
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    /* No qualifier */Tuple<K, V> prev()
+    /* No qualifier */Tuple<K, V> prev() throws EndOfFileExceededException, 
IOException
     {
         ParentPos<K, V> parentPos = stack.peek();
 
@@ -234,8 +245,10 @@ import java.util.LinkedList;
     /**
      * Tells if the cursor can return a next element
      * @return true if there are some more elements
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    /* No qualifier */boolean hasNext()
+    /* No qualifier */boolean hasNext() throws EndOfFileExceededException, 
IOException
     {
         ParentPos<K, V> parentPos = stack.peek();
 
@@ -265,8 +278,10 @@ import java.util.LinkedList;
     /**
      * Tells if the cursor can return a previous element
      * @return true if there are some more elements
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    /* No qualifier */boolean hasPrev()
+    /* No qualifier */boolean hasPrev() throws EndOfFileExceededException, 
IOException
     {
         ParentPos<K, V> parentPos = stack.peek();
 

Modified: 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/ElementHolder.java
URL: 
http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/ElementHolder.java?rev=1457577&r1=1457576&r2=1457577&view=diff
==============================================================================
--- 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/ElementHolder.java
 (original)
+++ 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/ElementHolder.java
 Sun Mar 17 22:35:18 2013
@@ -20,6 +20,11 @@
 package org.apache.mavibot.btree;
 
 
+import java.io.IOException;
+
+import org.apache.mavibot.btree.exception.EndOfFileExceededException;
+
+
 /**
  * A Value holder. As we may not store all the values in memory (except for an 
in-memory
  * BTree), we will use a SoftReference to keep a reference to a Value, and if 
it's null,
@@ -40,5 +45,5 @@ public interface ElementHolder<E, K, V>
      * 
      * @return The stored element
      */
-    E getValue( BTree<K, V> btree );
+    E getValue( BTree<K, V> btree ) throws EndOfFileExceededException, 
IOException;
 }

Modified: 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java
URL: 
http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java?rev=1457577&r1=1457576&r2=1457577&view=diff
==============================================================================
--- labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java 
(original)
+++ labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java 
Sun Mar 17 22:35:18 2013
@@ -24,6 +24,7 @@ import java.io.IOException;
 import java.lang.reflect.Array;
 import java.util.LinkedList;
 
+import org.apache.mavibot.btree.exception.EndOfFileExceededException;
 import org.apache.mavibot.btree.exception.KeyNotFoundException;
 
 
@@ -108,9 +109,12 @@ public class Leaf<K, V> extends Abstract
 
     /**
      * {@inheritDoc}
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
     @SuppressWarnings("unchecked")
     public DeleteResult<K, V> delete( long revision, K key, Page<K, V> parent, 
int parentPos )
+        throws EndOfFileExceededException, IOException
     {
         // Check that the leaf is not empty
         if ( nbElems == 0 )
@@ -200,8 +204,11 @@ public class Leaf<K, V> extends Abstract
      * @param isLeft Tells if the sibling is on the left or on the right
      * @param pos The position of the removed element
      * @return The new created leaf containing the sibling and the old page.
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
     private DeleteResult<K, V> mergeWithSibling( long revision, Leaf<K, V> 
sibling, boolean isLeft, int pos )
+        throws EndOfFileExceededException, IOException
     {
         // Create the new page. It will contain N - 1 elements (the maximum 
number)
         // as we merge two pages that contain N/2 elements minus the one we 
remove
@@ -256,8 +263,11 @@ public class Leaf<K, V> extends Abstract
      * @param sibling The left sibling
      * @param pos The position of the element to remove
      * @return The resulting pages
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
     private DeleteResult<K, V> borrowFromLeft( long revision, Leaf<K, V> 
sibling, int pos )
+        throws EndOfFileExceededException, IOException
     {
         // The sibling is on the left, borrow the rightmost element
         K siblingKey = sibling.keys[sibling.getNbElems() - 1];
@@ -300,8 +310,11 @@ public class Leaf<K, V> extends Abstract
      * @param sibling The right sibling
      * @param pos The position of the element to remove
      * @return The resulting pages
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
     private DeleteResult<K, V> borrowFromRight( long revision, Leaf<K, V> 
sibling, int pos )
+        throws EndOfFileExceededException, IOException
     {
         // The sibling is on the left, borrow the rightmost element
         K siblingKey = sibling.keys[0];
@@ -345,8 +358,10 @@ public class Leaf<K, V> extends Abstract
      * @param revision The revision of the modified page
      * @param pos The position into the page of the element to remove
      * @return The modified page with the <K,V> element added
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    private DeleteResult<K, V> removeElement( long revision, int pos )
+    private DeleteResult<K, V> removeElement( long revision, int pos ) throws 
EndOfFileExceededException, IOException
     {
         // First copy the current page, but remove one element in the copied 
page
         Leaf<K, V> newLeaf = new Leaf<K, V>( btree, revision, nbElems - 1 );
@@ -394,8 +409,10 @@ public class Leaf<K, V> extends Abstract
 
     /**
      * {@inheritDoc}
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    public V get( K key ) throws KeyNotFoundException
+    public V get( K key ) throws KeyNotFoundException, 
EndOfFileExceededException, IOException
     {
         int pos = findPos( key );
 
@@ -530,8 +547,11 @@ public class Leaf<K, V> extends Abstract
      * @param value the new value
      * @param pos The position of the key in the page
      * @return The copied page
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
     private InsertResult<K, V> replaceElement( long revision, K key, V value, 
int pos )
+        throws EndOfFileExceededException, IOException
     {
         Leaf<K, V> newLeaf = this;
 
@@ -693,8 +713,10 @@ public class Leaf<K, V> extends Abstract
 
     /**
      * {@inheritDoc}
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    public Tuple<K, V> findLeftMost()
+    public Tuple<K, V> findLeftMost() throws EndOfFileExceededException, 
IOException
     {
         return new Tuple<K, V>( keys[0], values[0].getValue( btree ) );
     }
@@ -702,8 +724,10 @@ public class Leaf<K, V> extends Abstract
 
     /**
      * {@inheritDoc}
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    public Tuple<K, V> findRightMost()
+    public Tuple<K, V> findRightMost() throws EndOfFileExceededException, 
IOException
     {
         return new Tuple<K, V>( keys[nbElems - 1], values[nbElems - 
1].getValue( btree ) );
     }

Modified: 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Node.java
URL: 
http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Node.java?rev=1457577&r1=1457576&r2=1457577&view=diff
==============================================================================
--- labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Node.java 
(original)
+++ labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Node.java 
Sun Mar 17 22:35:18 2013
@@ -24,6 +24,7 @@ import java.io.IOException;
 import java.lang.reflect.Array;
 import java.util.LinkedList;
 
+import org.apache.mavibot.btree.exception.EndOfFileExceededException;
 import org.apache.mavibot.btree.exception.KeyNotFoundException;
 
 
@@ -821,8 +822,11 @@ public class Node<K, V> extends Abstract
 
     /**
      * {@inheritDoc}
+     * @throws IOException 
+     * @throws KeyNotFoundException 
+     * @throws EndOfFileExceededException 
      */
-    public V get( K key ) throws KeyNotFoundException
+    public V get( K key ) throws IOException, KeyNotFoundException
     {
         int pos = findPos( key );
 
@@ -852,8 +856,10 @@ public class Node<K, V> extends Abstract
 
     /**
      * {@inheritDoc}
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    public Page<K, V> getReference( int pos )
+    public Page<K, V> getReference( int pos ) throws 
EndOfFileExceededException, IOException
     {
         if ( pos < nbElems + 1 )
         {
@@ -868,8 +874,11 @@ public class Node<K, V> extends Abstract
 
     /**
      * {@inheritDoc}
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
     public Cursor<K, V> browse( K key, Transaction<K, V> transaction, 
LinkedList<ParentPos<K, V>> stack )
+        throws EndOfFileExceededException, IOException
     {
         int pos = findPos( key );
 
@@ -887,8 +896,11 @@ public class Node<K, V> extends Abstract
 
     /**
      * {@inheritDoc}
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
     public Cursor<K, V> browse( Transaction<K, V> transaction, 
LinkedList<ParentPos<K, V>> stack )
+        throws EndOfFileExceededException, IOException
     {
         stack.push( new ParentPos<K, V>( this, 0 ) );
 
@@ -1115,8 +1127,10 @@ public class Node<K, V> extends Abstract
 
     /**
      * {@inheritDoc}
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    public K getLeftMostKey()
+    public K getLeftMostKey() throws EndOfFileExceededException, IOException
     {
         return children[0].getValue( btree ).getLeftMostKey();
     }
@@ -1124,8 +1138,10 @@ public class Node<K, V> extends Abstract
 
     /**
      * {@inheritDoc}
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    public Tuple<K, V> findLeftMost()
+    public Tuple<K, V> findLeftMost() throws EndOfFileExceededException, 
IOException
     {
         return children[0].getValue( btree ).findLeftMost();
     }
@@ -1133,14 +1149,18 @@ public class Node<K, V> extends Abstract
 
     /**
      * {@inheritDoc}
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    public Tuple<K, V> findRightMost()
+    public Tuple<K, V> findRightMost() throws EndOfFileExceededException, 
IOException
     {
         return children[nbElems].getValue( btree ).findRightMost();
     }
 
 
     /**
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      * @see Object#toString()
      */
     public String toString()
@@ -1151,32 +1171,39 @@ public class Node<K, V> extends Abstract
         sb.append( super.toString() );
         sb.append( "] -> {" );
 
-        if ( nbElems > 0 )
+        try
         {
-            // Start with the first child
-            if ( children[0] == null )
-            {
-                sb.append( "null" );
-            }
-            else
+            if ( nbElems > 0 )
             {
-                sb.append( 'r' ).append( children[0].getValue( btree 
).getRevision() );
-            }
-
-            for ( int i = 0; i < nbElems; i++ )
-            {
-                sb.append( "|<" ).append( keys[i] ).append( ">|" );
-
-                if ( children[i + 1] == null )
+                // Start with the first child
+                if ( children[0] == null )
                 {
                     sb.append( "null" );
                 }
                 else
                 {
-                    sb.append( 'r' ).append( children[i + 1].getValue( btree 
).getRevision() );
+                    sb.append( 'r' ).append( children[0].getValue( btree 
).getRevision() );
+                }
+
+                for ( int i = 0; i < nbElems; i++ )
+                {
+                    sb.append( "|<" ).append( keys[i] ).append( ">|" );
+
+                    if ( children[i + 1] == null )
+                    {
+                        sb.append( "null" );
+                    }
+                    else
+                    {
+                        sb.append( 'r' ).append( children[i + 1].getValue( 
btree ).getRevision() );
+                    }
                 }
             }
         }
+        catch ( IOException ioe )
+        {
+            // Do nothing
+        }
 
         sb.append( "}" );
 
@@ -1193,15 +1220,22 @@ public class Node<K, V> extends Abstract
 
         if ( nbElems > 0 )
         {
-            // Start with the first child
-            sb.append( children[0].getValue( btree ).dumpPage( tabs + "    " ) 
);
+            try
+            {
+                // Start with the first child
+                sb.append( children[0].getValue( btree ).dumpPage( tabs + "    
" ) );
 
-            for ( int i = 0; i < nbElems; i++ )
+                for ( int i = 0; i < nbElems; i++ )
+                {
+                    sb.append( tabs );
+                    sb.append( "<" );
+                    sb.append( keys[i] ).append( ">\n" );
+                    sb.append( children[i + 1].getValue( btree ).dumpPage( 
tabs + "    " ) );
+                }
+            }
+            catch ( IOException ioe )
             {
-                sb.append( tabs );
-                sb.append( "<" );
-                sb.append( keys[i] ).append( ">\n" );
-                sb.append( children[i + 1].getValue( btree ).dumpPage( tabs + 
"    " ) );
+                // Do nothing
             }
         }
 

Modified: 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Page.java
URL: 
http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Page.java?rev=1457577&r1=1457576&r2=1457577&view=diff
==============================================================================
--- labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Page.java 
(original)
+++ labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Page.java 
Sun Mar 17 22:35:18 2013
@@ -23,6 +23,7 @@ package org.apache.mavibot.btree;
 import java.io.IOException;
 import java.util.LinkedList;
 
+import org.apache.mavibot.btree.exception.EndOfFileExceededException;
 import org.apache.mavibot.btree.exception.KeyNotFoundException;
 
 
@@ -96,7 +97,7 @@ public interface Page<K, V>
      * @throws KeyNotFoundException If no entry with the given key can be found
      * @return The associated value, or null if there is none
      */
-    V get( K key ) throws KeyNotFoundException;
+    V get( K key ) throws KeyNotFoundException, IOException;
 
 
     /**
@@ -108,7 +109,8 @@ public interface Page<K, V>
      * @param stack The stack of parents we go through to get to this page
      * @return A Cursor to browse the next elements
      */
-    Cursor<K, V> browse( K key, Transaction<K, V> transaction, 
LinkedList<ParentPos<K, V>> stack );
+    Cursor<K, V> browse( K key, Transaction<K, V> transaction, 
LinkedList<ParentPos<K, V>> stack )
+        throws EndOfFileExceededException, IOException;
 
 
     /**
@@ -117,8 +119,11 @@ public interface Page<K, V>
      * @param transaction The started transaction for this operation
      * @param stack The stack of parents we go through to get to this page
      * @return A Cursor to browse the next elements
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    Cursor<K, V> browse( Transaction<K, V> transaction, 
LinkedList<ParentPos<K, V>> stack );
+    Cursor<K, V> browse( Transaction<K, V> transaction, 
LinkedList<ParentPos<K, V>> stack )
+        throws EndOfFileExceededException, IOException;
 
 
     /**
@@ -140,8 +145,10 @@ public interface Page<K, V>
      * down in the leftmost children to recursively find the leftmost key.
      * 
      * @return The leftmost key in the tree
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    K getLeftMostKey();
+    K getLeftMostKey() throws EndOfFileExceededException, IOException;
 
 
     /**
@@ -149,8 +156,10 @@ public interface Page<K, V>
      * down in the leftmost children to recursively find the leftmost element.
      * 
      * @return The leftmost element in the tree
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    Tuple<K, V> findLeftMost();
+    Tuple<K, V> findLeftMost() throws EndOfFileExceededException, IOException;
 
 
     /**
@@ -158,8 +167,10 @@ public interface Page<K, V>
      * down in the rightmost children to recursively find the rightmost 
element.
      * 
      * @return The rightmost element in the tree
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    Tuple<K, V> findRightMost();
+    Tuple<K, V> findRightMost() throws EndOfFileExceededException, IOException;
 
 
     /**

Modified: 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/ReferenceHolder.java
URL: 
http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/ReferenceHolder.java?rev=1457577&r1=1457576&r2=1457577&view=diff
==============================================================================
--- 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/ReferenceHolder.java
 (original)
+++ 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/ReferenceHolder.java
 Sun Mar 17 22:35:18 2013
@@ -20,8 +20,11 @@
 package org.apache.mavibot.btree;
 
 
+import java.io.IOException;
 import java.lang.ref.SoftReference;
 
+import org.apache.mavibot.btree.exception.EndOfFileExceededException;
+
 
 /**
  * A Value holder. As we may not store all the values in memory (except for an 
in-memory
@@ -62,29 +65,35 @@ public class ReferenceHolder<E, K, V> im
 
     /**
      * {@inheritDoc}
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
     @Override
-    public E getValue( BTree<K, V> btree )
+    public E getValue( BTree<K, V> btree ) throws EndOfFileExceededException, 
IOException
     {
         E element = reference.get();
 
-        if ( element != null )
+        if ( element == null )
         {
-            return element;
+            // We have to fetch the element from disk, using the offset now
+            element = fetchElement( btree );
         }
 
-        // We have to fetch the element from disk, using the offset now
-        return fetchElement( btree );
+        return element;
     }
 
 
     /**
      * Retrieve the value from the disk, using the BTree and offset
-     * @return
+     * @return The deserialized element (
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
      */
-    private E fetchElement( BTree<K, V> btree )
+    private E fetchElement( BTree<K, V> btree ) throws 
EndOfFileExceededException, IOException
     {
-        return null;
+        E element = ( E ) btree.getRecordManager().deserialize( btree, offset 
);
+
+        return element;
     }
 
 

Modified: 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/store/RecordManager.java
URL: 
http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/store/RecordManager.java?rev=1457577&r1=1457576&r2=1457577&view=diff
==============================================================================
--- 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/store/RecordManager.java
 (original)
+++ 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/store/RecordManager.java
 Sun Mar 17 22:35:18 2013
@@ -492,6 +492,7 @@ public class RecordManager
         PageIO[] rootPageIos = readPages( rootPageOffset, Long.MAX_VALUE );
 
         Page btreeRoot = readPage( btree, rootPageIos );
+        BTreeFactory.setRecordManager( btree, this );
 
         BTreeFactory.setRoot( btree, btreeRoot );
     }
@@ -508,6 +509,16 @@ public class RecordManager
     }
 
 
+    public Page deserialize( BTree btree, long offset ) throws 
EndOfFileExceededException, IOException
+    {
+        PageIO[] rootPageIos = readPages( offset, Long.MAX_VALUE );
+
+        Page page = readPage( btree, rootPageIos );
+
+        return page;
+    }
+
+
     private Page readPage( BTree btree, PageIO[] pageIos ) throws IOException
     {
         // Deserialize the rootPage now



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to