Author: elecharny
Date: Sun Mar 17 12:26:31 2013
New Revision: 1457435

URL: http://svn.apache.org/r1457435
Log:
o Made the getOffset() method public to be able to use it from the RM
o Fixed the usage of nbElems for Node : it's a negative value, we have to make 
it >0 to create the arrays
o Correctly write the Nodes

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/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=1457435&r1=1457434&r2=1457435&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 12:26:31 2013
@@ -289,7 +289,7 @@ public abstract class AbstractPage<K, V>
     /**
      * @return the offset
      */
-    /* No qualifier */long getOffset()
+    public long getOffset()
     {
         return offset;
     }

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=1457435&r1=1457434&r2=1457435&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 12:26:31 2013
@@ -32,6 +32,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.mavibot.btree.AbstractPage;
 import org.apache.mavibot.btree.BTree;
 import org.apache.mavibot.btree.BTreeFactory;
 import org.apache.mavibot.btree.ElementHolder;
@@ -552,7 +553,7 @@ public class RecordManager
         else
         {
             // It's a node
-            page = BTreeFactory.createNode( btree, revision, nbElems );
+            page = BTreeFactory.createNode( btree, revision, -nbElems );
         }
 
         return page;
@@ -966,12 +967,14 @@ public class RecordManager
 
             // The number of elements
             // Make it a negative value if it's a Node
+            int pageNbElems = nbElems;
+
             if ( page instanceof Node )
             {
-                nbElems = -nbElems;
+                pageNbElems = -nbElems;
             }
 
-            buffer = IntSerializer.serialize( nbElems );
+            buffer = IntSerializer.serialize( pageNbElems );
             serializedData.add( buffer );
             serializedSize += buffer.length;
 
@@ -982,7 +985,9 @@ public class RecordManager
                 if ( page instanceof Node )
                 {
                     Page child = ( ( Node ) page ).getReference( pos );
-                    //serializedData.add( 
btree.getValueSerializer().serialize( child..get );
+                    buffer = LongSerializer.serialize( ( ( AbstractPage ) 
child ).getOffset() );
+                    serializedData.add( buffer );
+                    dataSize += buffer.length;
                 }
                 else
                 {
@@ -1001,7 +1006,10 @@ public class RecordManager
             // Nodes have one more value to serialize
             if ( page instanceof Node )
             {
-                // TODO
+                Page child = ( ( Node ) page ).getReference( nbElems );
+                buffer = LongSerializer.serialize( ( ( AbstractPage ) child 
).getOffset() );
+                serializedData.add( buffer );
+                dataSize += buffer.length;
             }
 
             // Store the data size



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

Reply via email to