Author: kayyagari
Date: Mon Jun 3 10:07:47 2013
New Revision: 1488948
URL: http://svn.apache.org/r1488948
Log:
moved keepRevisions flag to RecordManager
Modified:
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/RecordManager.java
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/RecordManagerTest.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=1488948&r1=1488947&r2=1488948&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
Mon Jun 3 10:07:47 2013
@@ -125,9 +125,6 @@ public class BTree<K, V>
/** The queue containing all the modifications applied on the bTree */
private BlockingQueue<Modification<K, V>> modificationsQueue;
- /** A flag set to true if we want to keep old revisions */
- private boolean keepRevisions = false;
-
private File envDir;
/**
@@ -899,19 +896,13 @@ public class BTree<K, V>
if ( isManaged() )
{
recordManager.addFreePages( this, ( List )
result.getCopiedPages() );
+
+ // Store the created rootPage into the revision BTree, this
will be stored in RecordManager only if revisions are set to keep
+ recordManager.storeRootPage( this, rootPage );
}
-
- // Store the created rootPage into the revision BTree
- if ( keepRevisions )
+ else
{
- if ( isManaged() )
- {
- recordManager.storeRootPage( this, rootPage );
- }
- else
- {
- // Todo
- }
+ // Todo
}
// Return the value we have found if it was modified
@@ -1258,21 +1249,14 @@ public class BTree<K, V>
if ( isManaged() )
{
recordManager.addFreePages( this, ( List ) result.getCopiedPages()
);
+ // Store the created rootPage into the revision BTree, this will
be stored in RecordManager only if revisions are set to keep
+ recordManager.storeRootPage( this, rootPage );
}
-
- // Store the created rootPage into the revision BTree
- if ( keepRevisions )
+ else
{
- if ( isManaged() )
- {
- recordManager.storeRootPage( this, rootPage );
- }
- else
- {
- // Todo
- }
+ // Todo
}
-
+
// Return the value we have found if it was modified
return result;
}
@@ -1849,24 +1833,6 @@ public class BTree<K, V>
/**
- * @return the keepRevisions
- */
- public boolean isKeepRevisions()
- {
- return keepRevisions;
- }
-
-
- /**
- * @param keepRevisions the keepRevisions to set
- */
- public void setKeepRevisions( boolean keepRevisions )
- {
- this.keepRevisions = keepRevisions;
- }
-
-
- /**
* @see Object#toString()
*/
public String toString()
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=1488948&r1=1488947&r2=1488948&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
Mon Jun 3 10:07:47 2013
@@ -139,6 +139,9 @@ public class RecordManager
private BTree<String, Long> offsetBTree;
+ /** A flag set to true if we want to keep old revisions */
+ private boolean keepRevisions;
+
/**
* Create a Record manager which will either create the underlying file
* or load an existing one. If a folder is provided, then we will create
@@ -1934,6 +1937,16 @@ public class RecordManager
*/
/* No qualifier */void storeRootPage( BTree btree, Page rootPage ) throws
IOException
{
+ if( !isKeepRevisions() )
+ {
+ return;
+ }
+
+ if( ( btree == copiedPageBTree ) || ( btree == revisionBTree ) || (
btree == offsetBTree ) )
+ {
+ return;
+ }
+
RevisionName revisionName = new RevisionName( rootPage.getRevision(),
btree.getName() );
revisionBTree.insert( revisionName, rootPage.getOffset(), 0 );
@@ -2039,7 +2052,7 @@ public class RecordManager
}
// if the btree doesn't keep revisions just add them to the free page
list
- if( !btree.isKeepRevisions() )
+ if( !isKeepRevisions() )
{
PageIO[] pages = new PageIO[freePages.size()];
@@ -2143,6 +2156,24 @@ public class RecordManager
/**
+ * @return the keepRevisions
+ */
+ public boolean isKeepRevisions()
+ {
+ return keepRevisions;
+ }
+
+
+ /**
+ * @param keepRevisions the keepRevisions to set
+ */
+ public void setKeepRevisions( boolean keepRevisions )
+ {
+ this.keepRevisions = keepRevisions;
+ }
+
+
+ /**
* Creates a BTree and automatically adds it to the list of managed btrees
*
* @param name the name of the BTree
Modified:
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/RecordManagerTest.java
URL:
http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/RecordManagerTest.java?rev=1488948&r1=1488947&r2=1488948&view=diff
==============================================================================
---
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/RecordManagerTest.java
(original)
+++
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/RecordManagerTest.java
Mon Jun 3 10:07:47 2013
@@ -354,7 +354,7 @@ public class RecordManagerTest
public void testRecordManagerBrowseWithKeepRevisions() throws IOException,
BTreeAlreadyManagedException,
KeyNotFoundException
{
- btree.setKeepRevisions( true );
+ recordManager1.setKeepRevisions( true );
// Now, add some elements in the BTree
btree.insert( 3L, "V3" );
@@ -426,7 +426,7 @@ public class RecordManagerTest
public void testRecordManagerBrowseFromWithRevision() throws IOException,
BTreeAlreadyManagedException,
KeyNotFoundException
{
- btree.setKeepRevisions( true );
+ recordManager1.setKeepRevisions( true );
// Now, add some elements in the BTree
btree.insert( 3L, "V3" );
@@ -497,7 +497,7 @@ public class RecordManagerTest
public void testGetWithRevision() throws IOException,
BTreeAlreadyManagedException,
KeyNotFoundException
{
- btree.setKeepRevisions( true );
+ recordManager1.setKeepRevisions( true );
// Now, add some elements in the BTree
btree.insert( 3L, "V3" );
@@ -605,7 +605,7 @@ public class RecordManagerTest
public void testContainWithRevision() throws IOException,
BTreeAlreadyManagedException,
KeyNotFoundException
{
- btree.setKeepRevisions( true );
+ recordManager1.setKeepRevisions( true );
// Now, add some elements in the BTree
btree.insert( 3L, "V3" );
@@ -701,7 +701,7 @@ public class RecordManagerTest
public void testHasKeyWithRevision() throws IOException,
BTreeAlreadyManagedException,
KeyNotFoundException
{
- btree.setKeepRevisions( true );
+ recordManager1.setKeepRevisions( true );
// Now, add some elements in the BTree
btree.insert( 3L, "V3" );
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]