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/03/14 14:19:13 UTC

svn commit: r1456417 - in /labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/store: BTreeHeader.java BtreeHeader.java

Author: elecharny
Date: Thu Mar 14 13:19:13 2013
New Revision: 1456417

URL: http://svn.apache.org/r1456417
Log:
o Renamed the BtreeHeader to BTreeHeader
o Added some more data into this class

Added:
    labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/store/BTreeHeader.java
      - copied, changed from r1453805, labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/store/BtreeHeader.java
Removed:
    labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/store/BtreeHeader.java

Copied: labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/store/BTreeHeader.java (from r1453805, labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/store/BtreeHeader.java)
URL: http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/store/BTreeHeader.java?p2=labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/store/BTreeHeader.java&p1=labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/store/BtreeHeader.java&r1=1453805&r2=1456417&rev=1456417&view=diff
==============================================================================
--- labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/store/BtreeHeader.java (original)
+++ labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/store/BTreeHeader.java Thu Mar 14 13:19:13 2013
@@ -21,37 +21,65 @@ package org.apache.mavibot.btree.store;
 
 
 /**
- * 
+ * Store in memory the information associated with a BTree. <br>
+ * A BTree Header on disk contains the following elements :
+ * <pre>
+ * +--------------------+-------------+
+ * | revision           | 8 bytes     |
+ * +--------------------+-------------+
+ * | nbElems            | 8 bytes     |
+ * +--------------------+-------------+
+ * | rootPageOffset     | 8 bytes     |
+ * +--------------------+-------------+
+ * | nextBtreeHeader    | 8 bytes     |
+ * +--------------------+-------------+
+ * | pageSize           | 4 bytes     |
+ * +--------------------+-------------+
+ * | name               | 4 bytes + N |
+ * +--------------------+-------------+
+ * | keySerializeFQCN   | 4 bytes + N |
+ * +--------------------+-------------+
+ * | valueSerializeFQCN | 4 bytes + N |
+ * +--------------------+-------------+
+ * </pre>
+ * Each BtreeHeader will be written starting on a new page.
  * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
  */
-public class BtreeHeader
+public class BTreeHeader
 {
-    /** The BTree name */
-    private String name;
+    /** The current revision */
+    private long revision;
 
-    /** The current version */
-    private long version;
+    /** The number of elements in this BTree */
+    private long nbElems;
 
-    /** The existing versions */
-    private long[] versions;
+    /** The offset of the BTree RootPage */
+    private long rootPageOffset;
 
-    /** The position in the file */
-    private long offset;
+    /** The offset of the next BTree */
+    private long nextBtreeOffset;
+
+    /** The number of elements in a page for this BTree */
+    private long pageSize;
+
+    /** The BTree name */
+    private String name;
 
     /** The FQCN of the Key serializer */
     private String keySerializerFQCN;
 
-    /** The FQCN of the Key comparator */
-    private String keyComparatorFQCN;
-
     /** The FQCN of the Value serializer */
     private String valueSerializerFQCN;
 
-    /** The FQCN of the Value serializer */
-    private String valueComparatorFQCN;
+    // Those are data which aren't serialized : they are in memory only */
+    /** The position in the file */
+    private long offset;
+
+    /** The existing versions */
+    private long[] versions;
 
 
-    public BtreeHeader( String name )
+    public BTreeHeader( String name )
     {
         this.name = name;
     }
@@ -76,24 +104,6 @@ public class BtreeHeader
 
 
     /**
-     * @return the version
-     */
-    public long getVersion()
-    {
-        return version;
-    }
-
-
-    /**
-     * @param version the version to set
-     */
-    public void setVersion( long version )
-    {
-        this.version = version;
-    }
-
-
-    /**
      * @return the versions
      */
     public long[] getVersions()
@@ -130,6 +140,132 @@ public class BtreeHeader
 
 
     /**
+     * @return the rootPageOffset
+     */
+    public long getRootPageOffset()
+    {
+        return rootPageOffset;
+    }
+
+
+    /**
+     * @param rootPageOffset the rootPageOffset to set
+     */
+    public void setRootPageOffset( long rootPageOffset )
+    {
+        this.rootPageOffset = rootPageOffset;
+    }
+
+
+    /**
+     * @return the revision
+     */
+    public long getRevision()
+    {
+        return revision;
+    }
+
+
+    /**
+     * @param revision the revision to set
+     */
+    public void setRevision( long revision )
+    {
+        this.revision = revision;
+    }
+
+
+    /**
+     * @return the nbElems
+     */
+    public long getNbElems()
+    {
+        return nbElems;
+    }
+
+
+    /**
+     * @param nbElems the nbElems to set
+     */
+    public void setNbElems( long nbElems )
+    {
+        this.nbElems = nbElems;
+    }
+
+
+    /**
+     * @return the nextBtreeOffset
+     */
+    public long getNextBtreeOffset()
+    {
+        return nextBtreeOffset;
+    }
+
+
+    /**
+     * @param nextBtreeOffset the nextBtreeOffset to set
+     */
+    public void setNextBtreeOffset( long nextBtreeOffset )
+    {
+        this.nextBtreeOffset = nextBtreeOffset;
+    }
+
+
+    /**
+     * @return the pageSize
+     */
+    public long getPageSize()
+    {
+        return pageSize;
+    }
+
+
+    /**
+     * @param pageSize the pageSize to set
+     */
+    public void setPageSize( long pageSize )
+    {
+        this.pageSize = pageSize;
+    }
+
+
+    /**
+     * @return the keySerializerFQCN
+     */
+    public String getKeySerializerFQCN()
+    {
+        return keySerializerFQCN;
+    }
+
+
+    /**
+     * @param keySerializerFQCN the keySerializerFQCN to set
+     */
+    public void setKeySerializerFQCN( String keySerializerFQCN )
+    {
+        this.keySerializerFQCN = keySerializerFQCN;
+    }
+
+
+    /**
+     * @return the valueSerializerFQCN
+     */
+    public String getValueSerializerFQCN()
+    {
+        return valueSerializerFQCN;
+    }
+
+
+    /**
+     * @param valueSerializerFQCN the valueSerializerFQCN to set
+     */
+    public void setValueSerializerFQCN( String valueSerializerFQCN )
+    {
+        this.valueSerializerFQCN = valueSerializerFQCN;
+    }
+
+
+    /**
      * @see Object#toString()
      */
     public String toString()
@@ -137,13 +273,15 @@ public class BtreeHeader
         StringBuilder sb = new StringBuilder();
 
         sb.append( "Btree '" ).append( name ).append( "'" );
-        sb.append( ", V[" ).append( version ).append( "]" );
+        sb.append( ", R[" ).append( revision ).append( "]" );
         sb.append( ", O[" ).append( offset ).append( "]\n" );
+        sb.append( ", root[" ).append( rootPageOffset ).append( "]\n" );
+        sb.append( ", next[" ).append( nextBtreeOffset ).append( "]\n" );
+        sb.append( ", N[" ).append( nbElems ).append( "]" );
+        sb.append( ", S[" ).append( pageSize ).append( "]" );
         sb.append( "{\n" );
         sb.append( "    Key serializer   : " ).append( keySerializerFQCN ).append( "\n" );
         sb.append( "    Value serializer : " ).append( valueSerializerFQCN ).append( "\n" );
-        sb.append( "    Key comparator   : " ).append( keyComparatorFQCN ).append( "\n" );
-        sb.append( "    Value comparator : " ).append( valueComparatorFQCN ).append( "\n" );
         sb.append( "}\n" );
 
         if ( ( versions != null ) && ( versions.length != 0 ) )



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