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/07/19 18:22:21 UTC
svn commit: r1504929 -
/labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/RecordManager.java
Author: elecharny
Date: Fri Jul 19 16:22:21 2013
New Revision: 1504929
URL: http://svn.apache.org/r1504929
Log:
Made the dupsAllowed value been stored in a byte instead of an integer.
Modified:
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/RecordManager.java
Modified: labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/RecordManager.java
URL: http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/RecordManager.java?rev=1504929&r1=1504928&r2=1504929&view=diff
==============================================================================
--- labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/RecordManager.java (original)
+++ labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/RecordManager.java Fri Jul 19 16:22:21 2013
@@ -111,6 +111,7 @@ public class RecordManager
private static final int LINK_SIZE = 8;
/** Some constants */
+ private static final int BYTE_SIZE = 1;
private static final int INT_SIZE = 4;
private static final int LONG_SIZE = 8;
@@ -478,17 +479,15 @@ public class RecordManager
// The tree name
byte[] btreeNameBytes = readBytes( pageIos, dataPos );
- dataPos += INT_SIZE;
-
- dataPos += btreeNameBytes.length;
+ dataPos += INT_SIZE + btreeNameBytes.length;
String btreeName = Strings.utf8ToString( btreeNameBytes );
BTreeFactory.setName( btree, btreeName );
// The keySerializer FQCN
byte[] keySerializerBytes = readBytes( pageIos, dataPos );
+ dataPos += INT_SIZE + keySerializerBytes.length;
String keySerializerFqcn = null;
- dataPos += INT_SIZE;
if ( keySerializerBytes != null )
{
@@ -506,11 +505,10 @@ public class RecordManager
byte[] valueSerializerBytes = readBytes( pageIos, dataPos );
String valueSerializerFqcn = null;
- dataPos += INT_SIZE;
+ dataPos += INT_SIZE + valueSerializerBytes.length;
if ( valueSerializerBytes != null )
{
- dataPos += valueSerializerBytes.length;
valueSerializerFqcn = Strings.utf8ToString( valueSerializerBytes );
}
else
@@ -521,9 +519,9 @@ public class RecordManager
BTreeFactory.setValueSerializer( btree, valueSerializerFqcn );
// The BTree allowDuplicates flag
- int allowDuplicates = readInt( pageIos, dataPos );
- btree.setAllowDuplicates( allowDuplicates == 1 );
- dataPos += INT_SIZE;
+ byte allowDuplicates = readByte( pageIos, dataPos );
+ btree.setAllowDuplicates( allowDuplicates != 0 );
+ dataPos += BYTE_SIZE;
// Now, init the BTree
btree.init();
@@ -799,6 +797,30 @@ public class RecordManager
/**
+ * Read a byte from pages
+ * @param pageIos The pages we want to read the byte from
+ * @param position The position in the data stored in those pages
+ * @return The byte we have read
+ */
+ private byte readByte( PageIO[] pageIos, long position )
+ {
+ // Compute the page in which we will store the data given the
+ // current position
+ int pageNb = computePageNb( position );
+
+ // Compute the position in the current page
+ int pagePos = ( int ) ( position + ( pageNb + 1 ) * LONG_SIZE + INT_SIZE ) - pageNb * pageSize;
+
+ ByteBuffer pageData = pageIos[pageNb].getData();
+ byte value = 0;
+
+ value = pageData.get( pagePos );
+
+ return value;
+ }
+
+
+ /**
* Read a long from pages
* @param pageIos The pages we want to read the long from
* @param position The position in the data stored in those pages
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org