labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1478380 - /labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java
Date Thu, 02 May 2013 14:21:39 GMT
Author: kayyagari
Date: Thu May  2 14:21:38 2013
New Revision: 1478380

URL: http://svn.apache.org/r1478380
Log:
o fixed the initialization of BTree when a type is set
o fixed the constructor with config

Modified:
    labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java

Modified: labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java
URL: http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java?rev=1478380&r1=1478379&r2=1478380&view=diff
==============================================================================
--- labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java (original)
+++ labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java Thu May 
2 14:21:38 2013
@@ -342,13 +342,19 @@ public class BTree<K, V>
         btreeHeader = new BTreeHeader();
         btreeHeader.setName( name );
         btreeHeader.setPageSize( configuration.getPageSize() );
+        
         keySerializer = configuration.getKeySerializer();
+        btreeHeader.setKeySerializerFQCN( keySerializer.getClass().getName() );
+
         valueSerializer = configuration.getValueSerializer();
+        btreeHeader.setValueSerializerFQCN( valueSerializer.getClass().getName() );
+
         comparator = keySerializer.getComparator();
         readTimeOut = configuration.getReadTimeOut();
         writeBufferSize = configuration.getWriteBufferSize();
         allowDuplicates = configuration.isAllowDuplicates();
-
+        type = configuration.getType();
+        
         if ( comparator == null )
         {
             throw new IllegalArgumentException( "Comparator should not be null" );
@@ -374,7 +380,7 @@ public class BTree<K, V>
         this( name, null, keySerializer, valueSerializer, DEFAULT_PAGE_SIZE );
     }
 
-
+    
     /**
      * Creates a new in-memory BTree with a default page size and key/value serializers.
      * 
@@ -416,7 +422,7 @@ public class BTree<K, V>
     {
         btreeHeader = new BTreeHeader();
         btreeHeader.setName( name );
-
+        
         if( dataDir != null )
         {
             envDir = new File( dataDir );
@@ -451,11 +457,8 @@ public class BTree<K, V>
      */
     public void init() throws IOException
     {
-        if ( envDir == null )
-        {
-            type = BTreeTypeEnum.IN_MEMORY;
-        }
-        else
+        // if not in-memory then default to persist mode instead of managed
+        if( ( envDir != null ) && ( type != BTreeTypeEnum.MANAGED ) )
         {
             if( !envDir.exists() )
             {
@@ -468,12 +471,8 @@ public class BTree<K, V>
             
             this.file = new File( envDir, btreeHeader.getName() + DATA_SUFFIX );
 
-            // if not in-memory then default to persist mode instead of managed
-            if( type != BTreeTypeEnum.MANAGED )
-            {
-                this.journal = new File( envDir, file.getName() + JOURNAL_SUFFIX );
-                type = BTreeTypeEnum.PERSISTENT;
-            }
+            this.journal = new File( envDir, file.getName() + JOURNAL_SUFFIX );
+            type = BTreeTypeEnum.PERSISTENT;
         }
 
         // Create the queue containing the pending read transactions
@@ -515,7 +514,11 @@ public class BTree<K, V>
             // Initialize the Journal manager thread if it's not a in-memory btree
             createJournalManager();
         }
-
+        else if ( type == null )
+        {
+            type = BTreeTypeEnum.IN_MEMORY;
+        }
+        
         // Initialize the txnManager thread
         createTransactionManager();
     }
@@ -540,7 +543,7 @@ public class BTree<K, V>
             // Flush the data
             flush();
         }
-
+        
         rootPage = null;
     }
 
@@ -673,7 +676,8 @@ public class BTree<K, V>
         this.type = BTreeTypeEnum.MANAGED;
     }
 
-
+    
+    
     /**
      * @return the pageSize
      */



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


Mime
View raw message