You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2015/03/09 07:30:49 UTC
svn commit: r1665131 -
/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java
Author: elecharny
Date: Mon Mar 9 06:30:49 2015
New Revision: 1665131
URL: http://svn.apache.org/r1665131
Log:
Speedup: we don't write the recordManager everytime a btree is modified, we do that when a full transaction is committed. Otherwise, we had this page written twice, once when the B-tree was updated, and another one when the BoB B-tree was updated.
Modified:
directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java
Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java?rev=1665131&r1=1665130&r2=1665131&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java Mon Mar 9 06:30:49 2015
@@ -2020,8 +2020,15 @@ public class RecordManager extends Abstr
try
{
- writeCounter.put( 0L, writeCounter.containsKey( 0L ) ? writeCounter.get( 0L ) + 1 : 1 );
- fileChannel.write( RECORD_MANAGER_HEADER_BUFFER, 0 );
+
+ Integer nbTxnStarted = context.get();
+
+ if ( ( nbTxnStarted == null ) || ( nbTxnStarted <= 1 ) )
+ {
+ //System.out.println( "Writing page at 0000" );
+ writeCounter.put( 0L, writeCounter.containsKey( 0L ) ? writeCounter.get( 0L ) + 1 : 1 );
+ fileChannel.write( RECORD_MANAGER_HEADER_BUFFER, 0 );
+ }
}
catch ( IOException ioe )
{
@@ -2523,6 +2530,7 @@ public class RecordManager extends Abstr
//fileChannel.force( false );
}
+ //System.out.println( "Writing page at " + Long.toHexString( pos ) );
writeCounter.put( pos, writeCounter.containsKey( pos ) ? writeCounter.get( pos ) + 1 : 1 );
nbUpdatePageIOs.incrementAndGet();
@@ -3060,6 +3068,7 @@ public class RecordManager extends Abstr
*/
private PageIO fetchNewPage() throws IOException
{
+ //System.out.println( "Fetching new page" );
if ( firstFreePage == NO_PAGE )
{
nbCreatedPages.incrementAndGet();
@@ -3950,6 +3959,8 @@ public class RecordManager extends Abstr
private void checkFreePages() throws EndOfFileExceededException, IOException
{
+ //System.out.println( "Checking the free pages, starting from " + Long.toHexString( firstFreePage ) );
+
// read all the free pages, add them into a set, to be sure we don't have a cycle
Set<Long> freePageOffsets = new HashSet<Long>();
@@ -3957,6 +3968,8 @@ public class RecordManager extends Abstr
while ( currentFreePageOffset != NO_PAGE )
{
+ //System.out.println( "Next page offset :" + Long.toHexString( currentFreePageOffset ) );
+
if ( ( currentFreePageOffset % pageSize ) != 0 )
{
throw new InvalidOffsetException( "Wrong offset : " + Long.toHexString( currentFreePageOffset ) );