directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1235326 [7/28] - in /directory/apacheds/trunk: jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ jdbm-partition...
Date Tue, 24 Jan 2012 16:15:29 GMT
Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreeLogicalRowIdPage.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreeLogicalRowIdPage.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreeLogicalRowIdPage.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreeLogicalRowIdPage.java Tue Jan 24 16:15:05 2012
@@ -47,44 +47,43 @@
 package jdbm.recman;
 
 
-
 /**
  * Class describing a page that holds logical rowids that were freed. Note
  * that the methods have *physical* rowids in their signatures - this is
  * because logical and physical rowids are internally the same, only their
  * external representation (i.e. in the client API) differs.
  */
-class FreeLogicalRowIdPage extends PageHeader 
+class FreeLogicalRowIdPage extends PageHeader
 {
     /** The offset for the number of free pages */
     private static final short O_COUNT = PageHeader.SIZE; // short count
-    
+
     /** Offset of the number of free row Ids */
     static final short O_FREE = O_COUNT + Magic.SZ_SHORT;
-    
+
     /** The number of elements by page */
     static final short ELEMS_PER_PAGE = ( RecordFile.BLOCK_SIZE - O_FREE ) / PhysicalRowId.SIZE;
 
     /** */
     final PhysicalRowId[] slots = new PhysicalRowId[ELEMS_PER_PAGE];
 
-    
+
     /**
      * Constructs a data page view from the indicated block.
      */
-    FreeLogicalRowIdPage( BlockIo blockIo ) 
+    FreeLogicalRowIdPage( BlockIo blockIo )
     {
         super( blockIo );
     }
-    
+
 
     /**
      * Factory method to create or return a data page for the indicated block.
      */
-    static FreeLogicalRowIdPage getFreeLogicalRowIdPageView( BlockIo blockIo ) 
+    static FreeLogicalRowIdPage getFreeLogicalRowIdPageView( BlockIo blockIo )
     {
         BlockView view = blockIo.getView();
-        
+
         if ( ( view != null ) && ( view instanceof FreeLogicalRowIdPage ) )
         {
             return ( FreeLogicalRowIdPage ) view;
@@ -95,143 +94,144 @@ class FreeLogicalRowIdPage extends PageH
         }
     }
 
-    
+
     /** 
      * @return the number of free rowids 
      */
-    short getCount() 
+    short getCount()
     {
         return blockIo.readShort( O_COUNT );
     }
-    
+
 
     /** 
      * Sets the number of free rowids 
      */
-    private void setCount( short i ) 
+    private void setCount( short i )
     {
         blockIo.writeShort( O_COUNT, i );
     }
-    
+
 
     /** 
      * Frees a slot 
      */
-    void free( int slot ) 
+    void free( int slot )
     {
         get( slot ).setBlock( 0 );
-        setCount( (short) ( getCount() - 1 ) );
+        setCount( ( short ) ( getCount() - 1 ) );
     }
-    
+
 
     /** 
      * Allocates a slot 
      */
-    PhysicalRowId alloc( int slot ) 
+    PhysicalRowId alloc( int slot )
     {
-        setCount( (short) ( getCount() + 1 ) );
+        setCount( ( short ) ( getCount() + 1 ) );
         get( slot ).setBlock( -1 );
-        
+
         return get( slot );
     }
-    
+
 
     /** 
      * Returns true if a slot is allocated 
      */
-    private boolean isAllocated( int slot ) 
+    private boolean isAllocated( int slot )
     {
         return get( slot ).getBlock() > 0;
     }
-    
+
 
     /** 
      * Returns true if a slot is free 
      */
-    private boolean isFree( int slot ) 
+    private boolean isFree( int slot )
     {
-        return !isAllocated(slot);
+        return !isAllocated( slot );
     }
 
 
     /** 
      * Returns the value of the indicated slot 
      */
-    PhysicalRowId get( int slot ) 
+    PhysicalRowId get( int slot )
     {
         if ( slots[slot] == null )
         {
             slots[slot] = new PhysicalRowId( blockIo, slotToOffset( slot ) );
         }
-        
+
         return slots[slot];
     }
-    
+
 
     /** 
      * Converts slot to offset 
      */
-    private short slotToOffset( int slot ) 
+    private short slotToOffset( int slot )
     {
-        return (short) ( O_FREE + ( slot * PhysicalRowId.SIZE ) );
+        return ( short ) ( O_FREE + ( slot * PhysicalRowId.SIZE ) );
     }
-    
+
 
     /**
      *  Returns first free slot, -1 if no slots are available
      */
-    int getFirstFree() 
+    int getFirstFree()
     {
-        for ( int i = 0; i < ELEMS_PER_PAGE; i++ ) 
+        for ( int i = 0; i < ELEMS_PER_PAGE; i++ )
         {
             if ( isFree( i ) )
             {
                 return i;
             }
         }
-        
+
         return -1;
     }
-    
+
 
     /**
      * @return The first allocated slot, -1 if no slots are available.
      */
-    int getFirstAllocated() 
+    int getFirstAllocated()
     {
-        for ( int i = 0; i < ELEMS_PER_PAGE; i++ ) 
+        for ( int i = 0; i < ELEMS_PER_PAGE; i++ )
         {
             if ( isAllocated( i ) )
             {
                 return i;
             }
         }
-        
+
         return -1;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
-    public String toString() 
+    public String toString()
     {
         StringBuilder sb = new StringBuilder();
-        
+
         sb.append( "FreeLogRowIdPage ( " );
-        
+
         // The blockIO
         sb.append( super.toString() ).append( ", " );
-        
+
         // The first rowId
         sb.append( "count: " ).append( getCount() );
-        
+
         // Dump the Physical row id
         for ( int i = 0; i < ELEMS_PER_PAGE; i++ )
         {
             if ( slots[i] != null )
             {
-                sb.append( ", [" ).append( i ).append( "]=<" ).append( slots[i].getBlock() ).append( ", " ).append( slots[i].getOffset() ).append( ">" );
+                sb.append( ", [" ).append( i ).append( "]=<" ).append( slots[i].getBlock() ).append( ", " )
+                    .append( slots[i].getOffset() ).append( ">" );
             }
         }
 

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreeLogicalRowIdPageManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreeLogicalRowIdPageManager.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreeLogicalRowIdPageManager.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreeLogicalRowIdPageManager.java Tue Jan 24 16:15:05 2012
@@ -47,97 +47,100 @@
 
 package jdbm.recman;
 
+
 import java.io.IOException;
 
+
 /**
  *  This class manages free Logical rowid pages and provides methods
  *  to free and allocate Logical rowids on a high level.
  */
-final class FreeLogicalRowIdPageManager 
+final class FreeLogicalRowIdPageManager
 {
     /** our record recordFile */
     private RecordFile recordFile;
-    
+
     /** our page manager */
     private PageManager pageManager;
 
+
     /**
      *  Creates a new instance using the indicated record file and
      *  page manager.
      */
-    FreeLogicalRowIdPageManager( PageManager pageManager) throws IOException 
+    FreeLogicalRowIdPageManager( PageManager pageManager ) throws IOException
     {
         this.pageManager = pageManager;
         this.recordFile = pageManager.getRecordFile();
     }
-    
+
 
     /**
      *  Returns a free Logical rowid, or null if nothing was found.
      */
-    Location get() throws IOException 
+    Location get() throws IOException
     {
         // Loop through the free Logical rowid list until we find
         // the first rowid.
         // Create a cursor to browse the pages
         PageCursor cursor = new PageCursor( pageManager, Magic.FREELOGIDS_PAGE );
-        
+
         // Loop on the pages now
-        while ( cursor.next() != 0 ) 
+        while ( cursor.next() != 0 )
         {
             // Get the blockIo associated with the blockId
             BlockIo blockIo = recordFile.get( cursor.getBlockId() );
             FreeLogicalRowIdPage fp = FreeLogicalRowIdPage.getFreeLogicalRowIdPageView( blockIo );
-            
+
             // Get the first allocated FreeLogicalRowId
             int slot = fp.getFirstAllocated();
-            
-            if ( slot != -1 ) 
+
+            if ( slot != -1 )
             {
                 // got one!
                 Location location = new Location( fp.get( slot ) );
-                
+
                 // Remove the block from the page
                 fp.free( slot );
-                
+
                 boolean hasMore = fp.getCount() != 0;
-                
+
                 // Upate the recordFile
                 recordFile.release( cursor.getBlockId(), hasMore );
 
-                if ( !hasMore ) 
+                if ( !hasMore )
                 {
                     // page became empty - free it
                     pageManager.free( Magic.FREELOGIDS_PAGE, cursor.getBlockId() );
                 }
-                
+
                 return location;
             }
-            else 
+            else
             {
                 // no luck, go to next page
                 recordFile.release( cursor.getBlockId(), false );
             }
         }
-        
+
         return null;
     }
 
-    
+
     /**
      *  Puts the indicated rowid on the free list
      *  
      *  @param rowId The Location where we will store the rowId
      */
-    void put( Location rowId ) throws IOException 
+    void put( Location rowId ) throws IOException
     {
-        
+
         PhysicalRowId free = null;
-        
+
         // Create a cursor on the FREELOGIDs list
         PageCursor curs = new PageCursor( pageManager, Magic.FREELOGIDS_PAGE );
         long freePage = 0;
-        
+
         // Loop on all the list
         while ( curs.next() != 0 )
         {
@@ -145,17 +148,17 @@ final class FreeLogicalRowIdPageManager 
             BlockIo curBlockIo = recordFile.get( freePage );
             FreeLogicalRowIdPage fp = FreeLogicalRowIdPage.getFreeLogicalRowIdPageView( curBlockIo );
             int slot = fp.getFirstFree();
-            
-            if ( slot != -1 ) 
+
+            if ( slot != -1 )
             {
-                free = fp.alloc(slot);
+                free = fp.alloc( slot );
                 break;
             }
-            
+
             recordFile.release( curBlockIo );
         }
-        
-        if ( free == null ) 
+
+        if ( free == null )
         {
             // No more space on the free list, add a page.
             freePage = pageManager.allocate( Magic.FREELOGIDS_PAGE );
@@ -163,7 +166,7 @@ final class FreeLogicalRowIdPageManager 
             FreeLogicalRowIdPage fp = FreeLogicalRowIdPage.getFreeLogicalRowIdPageView( curBlockIo );
             free = fp.alloc( 0 );
         }
-        
+
         free.setBlock( rowId.getBlock() );
         free.setOffset( rowId.getOffset() );
         recordFile.release( freePage, true );

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreePhysicalRowId.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreePhysicalRowId.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreePhysicalRowId.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreePhysicalRowId.java Tue Jan 24 16:15:05 2012
@@ -51,32 +51,32 @@ package jdbm.recman;
  * This class extends the physical rowid with a size value to indicate
  * the size of a free rowid on the free rowid list.
  */
-final class FreePhysicalRowId extends PhysicalRowId 
+final class FreePhysicalRowId extends PhysicalRowId
 {
     // offsets
     private static final short O_SIZE = PhysicalRowId.SIZE; // int size
     static final short SIZE = O_SIZE + Magic.SZ_INT;
 
-    
+
     /**
      * Constructs a physical rowid from the indicated data starting at
      * the indicated position.
      */
-    FreePhysicalRowId( BlockIo block, short pos ) 
+    FreePhysicalRowId( BlockIo block, short pos )
     {
         super( block, pos );
     }
-    
+
 
     /** Returns the size */
-    int getSize() 
+    int getSize()
     {
         return block.readInt( pos + O_SIZE );
     }
-    
+
 
     /** Sets the size */
-    void setSize( int value ) 
+    void setSize( int value )
     {
         block.writeInt( pos + O_SIZE, value );
     }

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreePhysicalRowIdPage.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreePhysicalRowIdPage.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreePhysicalRowIdPage.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreePhysicalRowIdPage.java Tue Jan 24 16:15:05 2012
@@ -47,37 +47,36 @@
 package jdbm.recman;
 
 
-
 /**
  * Class describing a page that holds physical rowids that were freed.
  */
-final class FreePhysicalRowIdPage extends PageHeader 
+final class FreePhysicalRowIdPage extends PageHeader
 {
     // offsets
     private static final short O_COUNT = PageHeader.SIZE; // short count
     static final short O_FREE = O_COUNT + Magic.SZ_SHORT;
-    static final short ELEMS_PER_PAGE =  ( RecordFile.BLOCK_SIZE - O_FREE ) / FreePhysicalRowId.SIZE;
-    
+    static final short ELEMS_PER_PAGE = ( RecordFile.BLOCK_SIZE - O_FREE ) / FreePhysicalRowId.SIZE;
+
     // slots we returned.
     FreePhysicalRowId[] slots = new FreePhysicalRowId[ELEMS_PER_PAGE];
 
-    
+
     /**
      * Constructs a data page view from the indicated block.
      */
-    FreePhysicalRowIdPage( BlockIo block ) 
+    FreePhysicalRowIdPage( BlockIo block )
     {
         super( block );
     }
-    
+
 
     /**
      * Factory method to create or return a data page for the indicated block.
      */
-    static FreePhysicalRowIdPage getFreePhysicalRowIdPageView( BlockIo block ) 
+    static FreePhysicalRowIdPage getFreePhysicalRowIdPageView( BlockIo block )
     {
         BlockView view = block.getView();
-        
+
         if ( view != null && view instanceof FreePhysicalRowIdPage )
         {
             return ( FreePhysicalRowIdPage ) view;
@@ -87,151 +86,151 @@ final class FreePhysicalRowIdPage extend
             return new FreePhysicalRowIdPage( block );
         }
     }
-    
+
 
     /** 
      * Returns the number of free rowids 
      */
-    short getCount() 
+    short getCount()
     {
         return blockIo.readShort( O_COUNT );
     }
 
-    
+
     /** 
      * Sets the number of free rowids 
      */
-    private void setCount( short i ) 
+    private void setCount( short i )
     {
         blockIo.writeShort( O_COUNT, i );
     }
 
-    
+
     /** 
      * Frees a slot 
      */
-    void free( int slot ) 
+    void free( int slot )
     {
         get( slot ).setSize( 0 );
         setCount( ( short ) ( getCount() - 1 ) );
     }
 
-    
+
     /** 
      * Allocates a slot 
      */
-    FreePhysicalRowId alloc( int slot ) 
+    FreePhysicalRowId alloc( int slot )
     {
         setCount( ( short ) ( getCount() + 1 ) );
         return get( slot );
     }
 
-    
+
     /** 
      * Returns true if a slot is allocated 
      */
-    boolean isAllocated( int slot ) 
+    boolean isAllocated( int slot )
     {
         return get( slot ).getSize() != 0;
     }
-    
+
 
     /** 
      * Returns true if a slot is free 
      */
-    boolean isFree( int slot ) 
+    boolean isFree( int slot )
     {
-        return ! isAllocated( slot );
+        return !isAllocated( slot );
     }
-    
-    
+
+
     /** 
      * Returns the value of the indicated slot 
      */
-    FreePhysicalRowId get( int slot ) 
+    FreePhysicalRowId get( int slot )
     {
         if ( slots[slot] == null )
         {
-            slots[slot] = new FreePhysicalRowId( blockIo, slotToOffset( slot ) ) ;
+            slots[slot] = new FreePhysicalRowId( blockIo, slotToOffset( slot ) );
         }
-  
+
         return slots[slot];
     }
-    
+
 
     /** 
      * Converts slot to offset 
      */
-    short slotToOffset( int slot ) 
+    short slotToOffset( int slot )
     {
         return ( short ) ( O_FREE + ( slot * FreePhysicalRowId.SIZE ) );
     }
-    
-    
+
+
     /** 
      * @return first free slot, -1 if no slots are available
      */
-    int getFirstFree() 
+    int getFirstFree()
     {
-        for ( int i = 0; i < ELEMS_PER_PAGE; i++ ) 
+        for ( int i = 0; i < ELEMS_PER_PAGE; i++ )
         {
             if ( isFree( i ) )
             {
                 return i;
             }
         }
-  
+
         return -1;
     }
-    
+
 
     /** 
      * @return first slot with available size >= indicated size, or -1 if no 
      * slots are available.
      */
-    int getFirstLargerThan( int size ) 
+    int getFirstLargerThan( int size )
     {
-        for ( int i = 0; i < ELEMS_PER_PAGE; i++ ) 
+        for ( int i = 0; i < ELEMS_PER_PAGE; i++ )
         {
             if ( isAllocated( i ) && get( i ).getSize() >= size )
             {
                 return i;
             }
         }
-  
+
         return -1;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
-    public String toString() 
+    public String toString()
     {
         StringBuilder sb = new StringBuilder();
-        
+
         sb.append( "FreePhysRowIdPage ( " );
-        
+
         // The blockIO
         sb.append( super.toString() ).append( ", " );
-        
+
         // The first rowId
         sb.append( "count: " ).append( getCount() );
-        
+
         // Dump the Physical row id
         for ( int i = 0; i < ELEMS_PER_PAGE; i++ )
         {
             if ( slots[i] != null )
             {
                 sb.append( ", [" ).append( i ).append( "]=<" ).
-                append( slots[i].getBlock() ).append( ", " ).
-                append( slots[i].getOffset() ).append( ", " ).
-                append( slots[i].getSize() ).append( ">" );
+                    append( slots[i].getBlock() ).append( ", " ).
+                    append( slots[i].getOffset() ).append( ", " ).
+                    append( slots[i].getSize() ).append( ">" );
             }
         }
-        
+
         sb.append( ")" );
-        
+
         return sb.toString();
     }
 }
\ No newline at end of file

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreePhysicalRowIdPageManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreePhysicalRowIdPageManager.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreePhysicalRowIdPageManager.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/FreePhysicalRowIdPageManager.java Tue Jan 24 16:15:05 2012
@@ -62,7 +62,7 @@ final class FreePhysicalRowIdPageManager
     // our page manager
     protected PageManager pageManager;
 
-    
+
     /**
      * Creates a new instance using the indicated record recordFile and page manager.
      */
@@ -84,32 +84,32 @@ final class FreePhysicalRowIdPageManager
         Location retval = null;
         PageCursor curs = new PageCursor( pageManager, Magic.FREEPHYSIDS_PAGE );
 
-        while ( curs.next() != 0 ) 
+        while ( curs.next() != 0 )
         {
             FreePhysicalRowIdPage fp = FreePhysicalRowIdPage
                 .getFreePhysicalRowIdPageView( recordFile.get( curs.getBlockId() ) );
             int slot = fp.getFirstLargerThan( size );
-            
-            if ( slot != -1 ) 
+
+            if ( slot != -1 )
             {
                 // got one!
                 retval = new Location( fp.get( slot ) );
 
                 fp.free( slot );
-                if ( fp.getCount() == 0 ) 
+                if ( fp.getCount() == 0 )
                 {
                     // page became empty - free it
                     recordFile.release( curs.getBlockId(), false );
                     pageManager.free( Magic.FREEPHYSIDS_PAGE, curs.getBlockId() );
-                } 
-                else 
+                }
+                else
                 {
                     recordFile.release( curs.getBlockId(), true );
                 }
 
                 return retval;
-            } 
-            else 
+            }
+            else
             {
                 // no luck, go to next page
                 recordFile.release( curs.getBlockId(), false );
@@ -117,25 +117,25 @@ final class FreePhysicalRowIdPageManager
         }
         return null;
     }
-    
+
 
     /**
      * Puts the indicated rowid on the free list.
      */
-    void put( Location rowid, int size ) throws IOException 
+    void put( Location rowid, int size ) throws IOException
     {
         FreePhysicalRowId free = null;
         PageCursor curs = new PageCursor( pageManager, Magic.FREEPHYSIDS_PAGE );
         long freePage = 0;
-        
-        while ( curs.next() != 0 ) 
+
+        while ( curs.next() != 0 )
         {
             freePage = curs.getBlockId();
             BlockIo curBlock = recordFile.get( freePage );
             FreePhysicalRowIdPage fp = FreePhysicalRowIdPage.getFreePhysicalRowIdPageView( curBlock );
             int slot = fp.getFirstFree();
-      
-            if ( slot != -1 ) 
+
+            if ( slot != -1 )
             {
                 free = fp.alloc( slot );
                 break;
@@ -143,8 +143,8 @@ final class FreePhysicalRowIdPageManager
 
             recordFile.release( curBlock );
         }
-  
-        if ( free == null ) 
+
+        if ( free == null )
         {
             // No more space on the free list, add a page.
             freePage = pageManager.allocate( Magic.FREEPHYSIDS_PAGE );

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/Location.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/Location.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/Location.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/Location.java Tue Jan 24 16:15:05 2012
@@ -52,82 +52,82 @@ package jdbm.recman;
  * logical rowids are based on locations internally - this version is
  * used when there is no file block to back the location's data.
  */
-final class Location 
+final class Location
 {
     /** The block in which the data is stored */
     private long blockId;
-    
+
     /** The offset within this block */
     private short offset;
 
-    
+
     /**
      * Creates a location from a (block, offset) tuple.
      * 
      * @param blockId The block identifier
      * @param offset the offset in the block
      */
-    Location( long blockId, short offset ) 
+    Location( long blockId, short offset )
     {
         this.blockId = blockId;
         this.offset = offset;
     }
 
-    
+
     /**
      * Creates a location from a combined block/offset long, as used in the 
      * external representation of logical rowids. A recid is a logical rowid.
      * 
      * @param blockOffset The block + offset combinaison
      */
-    Location( long blockOffset ) 
+    Location( long blockOffset )
     {
         this.offset = ( short ) ( blockOffset & 0xffff );
         this.blockId = blockOffset >> 16;
     }
 
-    
+
     /**
      * Creates a location based on the data of the physical rowid.
      * 
      * @param physicalRowId The physical row id used as a base for the Location creation
      */
-    Location( PhysicalRowId physicalRowId ) 
+    Location( PhysicalRowId physicalRowId )
     {
         blockId = physicalRowId.getBlock();
         offset = physicalRowId.getOffset();
     }
 
-    
+
     /**
      * @eturn the blockId of the location
      */
-    long getBlock() 
+    long getBlock()
     {
         return blockId;
     }
 
-    
+
     /**
      * Returns the offset within the block of the location
      */
-    short getOffset() 
+    short getOffset()
     {
         return offset;
     }
 
-    
+
     /**
      * Returns the external representation of a location when used
      * as a logical rowid, which combines the block and the offset
      * in a single long.
      */
-    long toLong() 
+    long toLong()
     {
         return ( blockId << 16 ) + ( long ) offset;
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
@@ -137,32 +137,33 @@ final class Location 
         return 663;
     }
 
+
     /**
      * {@inheritDoc}
      */
     @Override
-   public boolean equals( Object o ) 
+    public boolean equals( Object o )
     {
-        if ( ( o == null ) || ! ( o instanceof Location ) )
+        if ( ( o == null ) || !( o instanceof Location ) )
         {
             return false;
         }
-        
+
         Location ol = ( Location ) o;
-        
+
         return ( ol.blockId == blockId ) && ( ol.offset == offset );
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
-    public String toString() 
+    public String toString()
     {
         StringBuilder sb = new StringBuilder();
         sb.append( "Location ( " ).append( blockId ).append( " : " );
         sb.append( offset ).append( " ) " );
-        
+
         return sb.toString();
     }
 }

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/LogicalRowIdManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/LogicalRowIdManager.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/LogicalRowIdManager.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/LogicalRowIdManager.java Tue Jan 24 16:15:05 2012
@@ -143,7 +143,7 @@ final class LogicalRowIdManager
     Location fetch( Location rowid ) throws IOException
     {
         TranslationPage xlatPage = TranslationPage.getTranslationPageView( recordFile.get( rowid.getBlock() ) );
-        
+
         try
         {
             Location retval = new Location( xlatPage.get( rowid.getOffset() ) );

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/Magic.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/Magic.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/Magic.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/Magic.java Tue Jan 24 16:15:05 2012
@@ -51,7 +51,7 @@ package jdbm.recman;
  * This interface contains magic cookies.
  * Final reference -> class shouldn't be extended
  */
-public final class Magic 
+public final class Magic
 {
     /**
      *  Ensures no construction of this class, also ensures there is no need for final keyword above
@@ -62,7 +62,6 @@ public final class Magic 
     {
     }
 
-    
     /** Magic cookie at start of file */
     public final static short FILE_HEADER = 0x1350;
 

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PageCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PageCursor.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PageCursor.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PageCursor.java Tue Jan 24 16:15:05 2012
@@ -53,30 +53,30 @@ import java.io.IOException;
 /**
  * This class provides a cursor that can follow lists of pages bi-directionally.
  */
-final class PageCursor 
+final class PageCursor
 {
     /** The PageManager */
     PageManager pageManager;
-    
+
     /** The current block ID */
     long blockId;
-    
+
     /** The page type */
     short type;
-    
+
 
     /**
      * Constructs a page cursor that starts at the indicated block.
      * 
      * @param pageManager The PageManager
      */
-    PageCursor( PageManager pageManager, long blockId ) 
+    PageCursor( PageManager pageManager, long blockId )
     {
         this.pageManager = pageManager;
         this.blockId = blockId;
     }
-    
-    
+
+
     /**
      * Constructs a page cursor that starts at the first block of the 
      * indicated list.
@@ -84,26 +84,26 @@ final class PageCursor 
      * @param pageManager The PageManager
      * @param type The page type
      */
-    PageCursor( PageManager pageManager, short type ) throws IOException 
+    PageCursor( PageManager pageManager, short type ) throws IOException
     {
         this.pageManager = pageManager;
         this.type = type;
     }
-    
-    
+
+
     /**
      * @return the BlockId
      */
-    long getBlockId() throws IOException 
+    long getBlockId() throws IOException
     {
         return blockId;
     }
-    
-    
+
+
     /**
      * @return the next blockId 
      */
-    long next() throws IOException 
+    long next() throws IOException
     {
         if ( blockId == 0 )
         {
@@ -113,22 +113,22 @@ final class PageCursor 
         {
             blockId = pageManager.getNext( blockId );
         }
-        
+
         return blockId;
-    } 
-    
-    
+    }
+
+
     /**
      * @return the previous blockId
      */
-    long prev() throws IOException 
+    long prev() throws IOException
     {
         blockId = pageManager.getPrev( blockId );
-        
+
         return blockId;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PageHeader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PageHeader.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PageHeader.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PageHeader.java Tue Jan 24 16:15:05 2012
@@ -65,62 +65,62 @@ import org.apache.directory.server.i18n.
  * 
  * The page header block view hence sees 18 bytes of page header data.
  */
-public class PageHeader implements BlockView 
+public class PageHeader implements BlockView
 {
     // offsets into page header's (BlockIo's) buffer
     /** the page (BlockIo's type code) short magic code */
-    private static final short O_MAGIC = 0; 
-    
+    private static final short O_MAGIC = 0;
+
     /** the long block id of the next block in the block list */
-    private static final short O_NEXT = Magic.SZ_SHORT;  
-    
+    private static final short O_NEXT = Magic.SZ_SHORT;
+
     /** the long block id of the previous block in the block list */
-    private static final short O_PREV = O_NEXT + Magic.SZ_LONG; 
-    
+    private static final short O_PREV = O_NEXT + Magic.SZ_LONG;
+
     /** the size of this page header */
     protected static final short SIZE = O_PREV + Magic.SZ_LONG;
 
     /** the page header block this view is associated with */
     protected BlockIo blockIo;
 
-    
+
     /**
      * Constructs a PageHeader object from a block
      *
      * @param blockIo The block that contains the page header
      * @throws IOException if the block is too short to keep the page header.
      */
-    protected PageHeader( BlockIo blockIo ) 
+    protected PageHeader( BlockIo blockIo )
     {
         this.blockIo = blockIo;
         blockIo.setView( this );
-        
-        if ( ! magicOk() )
+
+        if ( !magicOk() )
         {
             throw new Error( I18n.err( I18n.ERR_546, blockIo.getBlockId(), getMagic() ) );
         }
     }
-    
-    
+
+
     /**
      * Constructs a new PageHeader of the indicated type. Used for newly
      * created pages.
      */
-    PageHeader( BlockIo blockIo, short type ) 
+    PageHeader( BlockIo blockIo, short type )
     {
         this.blockIo = blockIo;
         blockIo.setView( this );
         setType( type );
     }
-    
-    
+
+
     /**
      * Factory method to create or return a page header for the indicated block.
      */
-    static PageHeader getView ( BlockIo blockIo ) 
+    static PageHeader getView( BlockIo blockIo )
     {
         BlockView view = blockIo.getView();
-        
+
         if ( view != null && view instanceof PageHeader )
         {
             return ( PageHeader ) view;
@@ -130,91 +130,91 @@ public class PageHeader implements Block
             return new PageHeader( blockIo );
         }
     }
-    
-    
+
+
     /**
      * Returns true if the magic corresponds with the fileHeader magic.
      */
-    private boolean magicOk() 
+    private boolean magicOk()
     {
         int magic = getMagic();
-        
+
         return magic >= Magic.BLOCK
             && magic <= ( Magic.BLOCK + Magic.FREEPHYSIDS_PAGE );
     }
-    
-    
+
+
     /**
      * For paranoia mode
      */
-    protected void paranoiaMagicOk() 
+    protected void paranoiaMagicOk()
     {
-        if ( ! magicOk() )
+        if ( !magicOk() )
         {
             throw new Error( I18n.err( I18n.ERR_547, getMagic() ) );
         }
     }
-    
-    
+
+
     /** 
      * @return The magic code (ie, the 2 first bytes of the inner BlockIo) 
      */
-    short getMagic() 
+    short getMagic()
     {
         return blockIo.readShort( O_MAGIC );
     }
 
-    
+
     /**
      * @return the next block (ie the long at position 2 in the BlockIo)
      */
-    long getNext() 
+    long getNext()
     {
         paranoiaMagicOk();
-        
+
         return blockIo.readLong( O_NEXT );
     }
-    
-    
+
+
     /** 
      * Sets the next blockIo.
      * 
      * @param The next Block ID
      */
-    void setNext( long next ) 
+    void setNext( long next )
     {
         paranoiaMagicOk();
         blockIo.writeLong( O_NEXT, next );
     }
-    
-    
+
+
     /** 
      * @return the previous block (ie the long at position 10 in the BlockIo)
      */
-    long getPrev() 
+    long getPrev()
     {
         paranoiaMagicOk();
-        
+
         return blockIo.readLong( O_PREV );
     }
-    
-    
+
+
     /** 
      * Sets the previous block. 
      */
-    void setPrev( long prev ) 
+    void setPrev( long prev )
     {
         paranoiaMagicOk();
         blockIo.writeLong( O_PREV, prev );
     }
-    
-    
+
+
     /** 
      * Sets the type of the page header
      * 
      *  @param type The PageHeader type to store at position 0
      */
-    void setType( short type ) 
+    void setType( short type )
     {
         blockIo.writeShort( O_MAGIC, ( short ) ( Magic.BLOCK + type ) );
     }
@@ -223,18 +223,18 @@ public class PageHeader implements Block
     /**
      * {@inheritDoc}
      */
-    public String toString() 
+    public String toString()
     {
         StringBuilder sb = new StringBuilder();
-        
+
         sb.append( "PageHeader ( " );
-        
+
         // The blockIO
         sb.append( "BlockIO ( " );
-        
+
         // The blockID
         sb.append( blockIo.getBlockId() ).append( ", " );
-        
+
         // Is it dirty ?
         if ( blockIo.isDirty() )
         {
@@ -244,7 +244,7 @@ public class PageHeader implements Block
         {
             sb.append( "clean, " );
         }
-        
+
         // The transaction count
         if ( blockIo.isInTransaction() )
         {
@@ -256,40 +256,40 @@ public class PageHeader implements Block
         }
 
         sb.append( " ), " );
-        
+
         // The Type
         int magic = getMagic();
-        
+
         switch ( magic - Magic.BLOCK )
         {
-            case Magic.FREE_PAGE :
+            case Magic.FREE_PAGE:
                 sb.append( "FREE_PAGE" ).append( ", " );
                 break;
-                
-            case Magic.USED_PAGE :
+
+            case Magic.USED_PAGE:
                 sb.append( "USED_PAGE" ).append( ", " );
                 break;
-                
-            case Magic.TRANSLATION_PAGE :
+
+            case Magic.TRANSLATION_PAGE:
                 sb.append( "TRANSLATION_PAGE" ).append( ", " );
                 break;
-                
-            case Magic.FREELOGIDS_PAGE :
+
+            case Magic.FREELOGIDS_PAGE:
                 sb.append( "FREELOGIDS_PAGE" ).append( ", " );
                 break;
-                
-            case Magic.FREEPHYSIDS_PAGE :
+
+            case Magic.FREEPHYSIDS_PAGE:
                 sb.append( "FREEPHYSIDS_PAGE" ).append( ", " );
                 break;
-                
+
         }
-        
+
         // The previous page
         sb.append( "[p:" ).append( getPrev() ).append( ", " );
-        
+
         // The next page
         sb.append( "n:" ).append( getNext() ).append( "] )" );
-        
+
         return sb.toString();
     }
 }

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PageManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PageManager.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PageManager.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PageManager.java Tue Jan 24 16:15:05 2012
@@ -56,18 +56,18 @@ import org.apache.directory.server.i18n.
  * This class manages the linked lists of pages that make up a recordFile. It contains
  * a FileHeadrer and a reference to the recordFile it manages.<br/>
  */
-final class PageManager 
+final class PageManager
 {
     /** our record recordFile */
     private RecordFile recordFile;
-    
+
     /** header data */
     private FileHeader header;
-    
+
     /** recordFile header containing block */
     private BlockIo headerBuf;
 
-    
+
     /**
      * Creates a new page manager using the indicated record recordFile.
      * We will load in memory the associated FileHeader, which is
@@ -76,46 +76,46 @@ final class PageManager 
      * @param The associated RecordFile
      * @throws IOException If there is an issue storing data into the recordFile
      */
-    PageManager( RecordFile recordFile ) throws IOException 
+    PageManager( RecordFile recordFile ) throws IOException
     {
         this.recordFile = recordFile;
-        
+
         // Note that we hold on to the recordFile header node.
         headerBuf = recordFile.get( 0 );
-        
+
         // Assume recordFile is new if the recordFile header's magic number is 0. 
         boolean isNew = headerBuf.readShort( 0 ) == 0;
 
         header = new FileHeader( headerBuf, isNew );
     }
-    
-    
+
+
     /**
      * Allocates a page of the indicated type. 
      * 
      * @param The page type we want to allocate
      * @return The record ID of the page.
      */
-    long allocate( short type ) throws IOException 
+    long allocate( short type ) throws IOException
     {
         if ( type == Magic.FREE_PAGE )
         {
             // We can't allocate FREE page. A page becomes FREE after it ha sbeen used.
             throw new Error( I18n.err( I18n.ERR_548 ) );
         }
-        
+
         boolean isNew = false;
-        
+
         // Do we have something on the free list?
         long freeBlock = header.getFirstOf( Magic.FREE_PAGE );
-        
-        if ( freeBlock != 0 ) 
+
+        if ( freeBlock != 0 )
         {
             // yes. Point to it and make the next of that page the
             // new first free page.
             header.setFirstOf( Magic.FREE_PAGE, getNext( freeBlock ) );
         }
-        else 
+        else
         {
             // nope. make a new record
             freeBlock = header.getLastOf( Magic.FREE_PAGE );
@@ -125,15 +125,15 @@ final class PageManager 
                 // very new recordFile - allocate record #1
                 freeBlock = 1;
             }
-            
+
             header.setLastOf( Magic.FREE_PAGE, freeBlock + 1 );
             isNew = true;
         }
-        
+
         // Cool. We have a record, add it to the correct list
         BlockIo buf = recordFile.get( freeBlock );
         PageHeader pageHdr = null;
-        
+
         if ( isNew )
         {
             pageHdr = new PageHeader( buf, type );
@@ -142,152 +142,152 @@ final class PageManager 
         {
             pageHdr = PageHeader.getView( buf );
         }
-        
+
         long oldLast = header.getLastOf( type );
-        
+
         // Clean data.
         System.arraycopy( RecordFile.cleanData, 0, buf.getData(), 0, RecordFile.BLOCK_SIZE );
         pageHdr.setType( type );
         pageHdr.setPrev( oldLast );
         pageHdr.setNext( 0 );
-        
+
         if ( oldLast == 0 )
         {
             // This was the first one of this type
             header.setFirstOf( type, freeBlock );
         }
-        
+
         header.setLastOf( type, freeBlock );
         recordFile.release( freeBlock, true );
-        
+
         // If there's a previous, fix up its pointer
-        if ( oldLast != 0 ) 
+        if ( oldLast != 0 )
         {
             buf = recordFile.get( oldLast );
             pageHdr = PageHeader.getView( buf );
             pageHdr.setNext( freeBlock );
             recordFile.release( oldLast, true );
         }
-        
+
         // remove the view, we have modified the type.
         buf.setView( null );
-        
+
         return freeBlock;
     }
-    
-    
+
+
     /**
      * Frees a page of the indicated type.
      */
-    void free( short type, long recid ) throws IOException 
+    void free( short type, long recid ) throws IOException
     {
         if ( type == Magic.FREE_PAGE )
         {
             throw new Error( I18n.err( I18n.ERR_549 ) );
         }
-        
+
         if ( recid == 0 )
         {
             throw new Error( I18n.err( I18n.ERR_550 ) );
         }
-        
+
         // get the page and read next and previous pointers
         BlockIo buf = recordFile.get( recid );
         PageHeader pageHdr = PageHeader.getView( buf );
         long prev = pageHdr.getPrev();
         long next = pageHdr.getNext();
-        
+
         // put the page at the front of the free list.
         pageHdr.setType( Magic.FREE_PAGE );
         pageHdr.setNext( header.getFirstOf( Magic.FREE_PAGE ) );
         pageHdr.setPrev( 0 );
-        
+
         header.setFirstOf( Magic.FREE_PAGE, recid );
         recordFile.release( recid, true );
-        
+
         // remove the page from its old list
-        if ( prev != 0 ) 
+        if ( prev != 0 )
         {
             buf = recordFile.get( prev );
             pageHdr = PageHeader.getView( buf );
             pageHdr.setNext( next );
             recordFile.release( prev, true );
         }
-        else 
+        else
         {
             header.setFirstOf( type, next );
         }
-        
-        if ( next != 0 ) 
+
+        if ( next != 0 )
         {
             buf = recordFile.get( next );
             pageHdr = PageHeader.getView( buf );
             pageHdr.setPrev( prev );
             recordFile.release( next, true );
         }
-        else 
+        else
         {
             header.setLastOf( type, prev );
         }
     }
-    
-    
+
+
     /**
      * Returns the page following the indicated block
      */
-    long getNext( long block ) throws IOException 
+    long getNext( long block ) throws IOException
     {
-        try 
+        try
         {
             return PageHeader.getView( recordFile.get( block ) ).getNext();
-        } 
-        finally 
+        }
+        finally
         {
             recordFile.release( block, false );
         }
     }
-    
-    
+
+
     /**
      * Returns the page before the indicated block
      */
-    long getPrev( long block ) throws IOException 
+    long getPrev( long block ) throws IOException
     {
-        try 
+        try
         {
             return PageHeader.getView( recordFile.get( block ) ).getPrev();
-        } 
-        finally 
+        }
+        finally
         {
             recordFile.release( block, false );
         }
     }
-    
-    
+
+
     /**
      * Returns the first page on the indicated list.
      */
-    long getFirst( short type ) throws IOException 
+    long getFirst( short type ) throws IOException
     {
         return header.getFirstOf( type );
     }
 
-    
+
     /**
      * Returns the last page on the indicated list.
      */
-    long getLast( short type ) throws IOException 
+    long getLast( short type ) throws IOException
     {
         return header.getLastOf( type );
     }
-    
-    
+
+
     /**
      * Commit all pending (in-memory) data by flushing the page manager.
      * This forces a flush of all outstanding blocks (this is an implicit
      * {@link RecordFile#commit} as well).
      */
-    void commit() throws IOException 
+    void commit() throws IOException
     {
         // write the header out
         recordFile.release( headerBuf );
@@ -298,21 +298,21 @@ final class PageManager 
         header = new FileHeader( headerBuf, false );
     }
 
-    
+
     /**
      * Flushes the page manager. This forces a flush of all outstanding
      * blocks (this is an implicit {@link RecordFile#commit} as well).
      * 
      * @TODO completely wrong description of method
      */
-    void rollback() throws IOException 
+    void rollback() throws IOException
     {
         // release header
         recordFile.discard( headerBuf );
         recordFile.rollback();
         // and obtain it again
         headerBuf = recordFile.get( 0 );
-        
+
         if ( headerBuf.readShort( 0 ) == 0 )
         {
             header = new FileHeader( headerBuf, true );
@@ -322,30 +322,31 @@ final class PageManager 
             header = new FileHeader( headerBuf, false );
         }
     }
-    
-    
+
+
     /**
      * Closes the page manager. This flushes the page manager and releases
      * the lock on the header.
      */
-    void close() throws IOException 
-    {   
+    void close() throws IOException
+    {
         recordFile.release( headerBuf );
         recordFile.commit();
         headerBuf = null;
         header = null;
         recordFile = null;
     }
-    
-    
+
+
     /**
      *  Returns the recordFile header.
      */
-    FileHeader getFileHeader() 
+    FileHeader getFileHeader()
     {
         return header;
-    }    
-    
+    }
+
+
     RecordFile getRecordFile()
     {
         return recordFile;

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PhysicalRowId.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PhysicalRowId.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PhysicalRowId.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PhysicalRowId.java Tue Jan 24 16:15:05 2012
@@ -54,52 +54,52 @@ package jdbm.recman;
  * <B>Note</B>: The fact that the offset is modeled as a short limits 
  * the block size to 32k.
  */
-class PhysicalRowId 
+class PhysicalRowId
 {
     // offsets
     private static final short O_BLOCK = 0; // long block
     private static final short O_OFFSET = Magic.SZ_LONG; // short offset
     static final int SIZE = O_OFFSET + Magic.SZ_SHORT;
-    
+
     // my block and the position within the block
     BlockIo block;
     short pos;
 
-    
+
     /**
      * Constructs a physical rowid from the indicated data starting at the 
      * indicated position.
      */
-    PhysicalRowId( BlockIo block, short pos ) 
+    PhysicalRowId( BlockIo block, short pos )
     {
         this.block = block;
         this.pos = pos;
     }
-    
-    
+
+
     /** Returns the block number */
-    long getBlock() 
+    long getBlock()
     {
         return block.readLong( pos + O_BLOCK );
     }
-    
-    
+
+
     /** Sets the block number */
-    void setBlock( long value ) 
+    void setBlock( long value )
     {
         block.writeLong( pos + O_BLOCK, value );
     }
-    
-    
+
+
     /** Returns the offset */
-    short getOffset() 
+    short getOffset()
     {
         return block.readShort( pos + O_OFFSET );
     }
-    
-    
+
+
     /** Sets the offset */
-    void setOffset( short value ) 
+    void setOffset( short value )
     {
         block.writeShort( pos + O_OFFSET, value );
     }

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PhysicalRowIdManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PhysicalRowIdManager.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PhysicalRowIdManager.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/PhysicalRowIdManager.java Tue Jan 24 16:15:05 2012
@@ -57,13 +57,14 @@ final class PhysicalRowIdManager
 {
     /** The file we're talking to and the associated page manager. */
     private RecordFile file;
-    
+
     /** The page manager */
     private PageManager pageManager;
-    
+
     /** The FreePage manager */
     private FreePhysicalRowIdPageManager freePageManager;
 
+
     /**
      *  Creates a new rowid manager using the indicated record file.
      *  and page manager.
@@ -75,7 +76,7 @@ final class PhysicalRowIdManager
         file = pageManager.getRecordFile();
         freePageManager = new FreePhysicalRowIdPageManager( pageManager );
     }
-    
+
 
     /**
      *  Inserts a new record. Returns the new physical rowid.
@@ -84,13 +85,13 @@ final class PhysicalRowIdManager
     {
         // Find the location for the added data
         Location retval = alloc( length );
-        
+
         // And write it
         write( retval, data, start, length );
-        
+
         return retval;
     }
-    
+
 
     /**
      *  Updates an existing record. Returns the possibly changed
@@ -101,25 +102,25 @@ final class PhysicalRowIdManager
         // fetch the record header
         BlockIo block = pageManager.getRecordFile().get( rowid.getBlock() );
         RecordHeader head = new RecordHeader( block, rowid.getOffset() );
-        
-        if ( length > head.getAvailableSize() ) 
+
+        if ( length > head.getAvailableSize() )
         {
             // not enough space - we need to copy to a new rowid.
             pageManager.getRecordFile().release( block );
             free( rowid );
             rowid = alloc( length );
-        } 
-        else 
+        }
+        else
         {
             pageManager.getRecordFile().release( block );
         }
 
         // 'nuff space, write it in and return the rowid.
         write( rowid, data, start, length );
-        
+
         return rowid;
     }
-    
+
 
     /**
      *  Deletes a record.
@@ -128,12 +129,12 @@ final class PhysicalRowIdManager
     {
         free( rowid );
     }
-    
+
 
     /**
      *  Retrieves a record.
      */
-    byte[] fetch( Location rowid ) throws IOException 
+    byte[] fetch( Location rowid ) throws IOException
     {
         // fetch the record header
         PageCursor curs = new PageCursor( pageManager, rowid.getBlock() );
@@ -141,9 +142,9 @@ final class PhysicalRowIdManager
         RecordHeader head = new RecordHeader( block, rowid.getOffset() );
 
         // allocate a return buffer
-        byte[] retval = new byte[ head.getCurrentSize() ];
-        
-        if ( retval.length == 0 ) 
+        byte[] retval = new byte[head.getCurrentSize()];
+
+        if ( retval.length == 0 )
         {
             file.release( curs.getBlockId(), false );
             return retval;
@@ -152,21 +153,21 @@ final class PhysicalRowIdManager
         // copy bytes in
         int offsetInBuffer = 0;
         int leftToRead = retval.length;
-        short dataOffset = (short) (rowid.getOffset() + RecordHeader.SIZE);
-        
-        while ( leftToRead > 0 ) 
+        short dataOffset = ( short ) ( rowid.getOffset() + RecordHeader.SIZE );
+
+        while ( leftToRead > 0 )
         {
             // copy current page's data to return buffer
             int toCopy = RecordFile.BLOCK_SIZE - dataOffset;
-            
-            if ( leftToRead < toCopy ) 
+
+            if ( leftToRead < toCopy )
             {
                 toCopy = leftToRead;
             }
-            
+
             System.arraycopy( block.getData(), dataOffset,
-                              retval, offsetInBuffer,
-                              toCopy );
+                retval, offsetInBuffer,
+                toCopy );
 
             // Go to the next block
             leftToRead -= toCopy;
@@ -174,7 +175,7 @@ final class PhysicalRowIdManager
 
             file.release( block );
 
-            if ( leftToRead > 0 ) 
+            if ( leftToRead > 0 )
             {
                 block = file.get( curs.next() );
                 dataOffset = DataPage.O_DATA;
@@ -185,22 +186,24 @@ final class PhysicalRowIdManager
         return retval;
     }
 
+
     /**
      *  Allocate a new rowid with the indicated size.
      */
     private Location alloc( int size ) throws IOException
     {
         Location retval = freePageManager.get( size );
-        
-        if ( retval == null ) 
+
+        if ( retval == null )
         {
             // temporary work around for DIRSERVER-1459
             retval = allocNew( size * 2, pageManager.getLast( Magic.USED_PAGE ) );
         }
-        
+
         return retval;
     }
 
+
     /**
      *  Allocates a new rowid. The second parameter is there to
      *  allow for a recursive call - it indicates where the search
@@ -210,8 +213,8 @@ final class PhysicalRowIdManager
     {
         BlockIo curBlock;
         DataPage curPage;
-        
-        if ( start == 0 ) 
+
+        if ( start == 0 )
         {
             // we need to create a new page.
             start = pageManager.allocate( Magic.USED_PAGE );
@@ -221,8 +224,8 @@ final class PhysicalRowIdManager
             RecordHeader hdr = new RecordHeader( curBlock, DataPage.O_DATA );
             hdr.setAvailableSize( 0 );
             hdr.setCurrentSize( 0 );
-        } 
-        else 
+        }
+        else
         {
             curBlock = file.get( start );
             curPage = DataPage.getDataPageView( curBlock );
@@ -231,8 +234,8 @@ final class PhysicalRowIdManager
         // follow the rowids on this page to get to the last one. We don't
         // fall off, because this is the last page, remember?
         short pos = curPage.getFirst();
-        
-        if ( pos == 0 ) 
+
+        if ( pos == 0 )
         {
             // page is exactly filled by the last block of a record
             file.release( curBlock );
@@ -240,12 +243,12 @@ final class PhysicalRowIdManager
         }
 
         RecordHeader hdr = new RecordHeader( curBlock, pos );
-        
-        while ( hdr.getAvailableSize() != 0 && pos < RecordFile.BLOCK_SIZE ) 
+
+        while ( hdr.getAvailableSize() != 0 && pos < RecordFile.BLOCK_SIZE )
         {
             pos += hdr.getAvailableSize() + RecordHeader.SIZE;
-            
-            if ( pos == RecordFile.BLOCK_SIZE ) 
+
+            if ( pos == RecordFile.BLOCK_SIZE )
             {
                 // Again, a filled page.
                 file.release( curBlock );
@@ -255,7 +258,7 @@ final class PhysicalRowIdManager
             hdr = new RecordHeader( curBlock, pos );
         }
 
-        if ( pos == RecordHeader.SIZE ) 
+        if ( pos == RecordHeader.SIZE )
         {
             // the last record exactly filled the page. Restart forcing
             // a new page.
@@ -266,17 +269,17 @@ final class PhysicalRowIdManager
         // enough space.
         Location retval = new Location( start, pos );
         int freeHere = RecordFile.BLOCK_SIZE - pos - RecordHeader.SIZE;
-        
-        if ( freeHere < size ) 
+
+        if ( freeHere < size )
         {
             // check whether the last page would have only a small bit left.
             // if yes, increase the allocation. A small bit is a record
             // header plus 16 bytes.
-            int lastSize = (size - freeHere) % DataPage.DATA_PER_PAGE;
-            
-            if (( DataPage.DATA_PER_PAGE - lastSize ) < (RecordHeader.SIZE + 16) ) 
+            int lastSize = ( size - freeHere ) % DataPage.DATA_PER_PAGE;
+
+            if ( ( DataPage.DATA_PER_PAGE - lastSize ) < ( RecordHeader.SIZE + 16 ) )
             {
-                size += (DataPage.DATA_PER_PAGE - lastSize);
+                size += ( DataPage.DATA_PER_PAGE - lastSize );
             }
 
             // write out the header now so we don't have to come back.
@@ -284,41 +287,42 @@ final class PhysicalRowIdManager
             file.release( start, true );
 
             int neededLeft = size - freeHere;
-            
+
             // Refactor these two blocks!
-            while ( neededLeft >= DataPage.DATA_PER_PAGE ) 
+            while ( neededLeft >= DataPage.DATA_PER_PAGE )
             {
                 start = pageManager.allocate( Magic.USED_PAGE );
                 curBlock = file.get( start );
                 curPage = DataPage.getDataPageView( curBlock );
-                curPage.setFirst( (short) 0 ); // no rowids, just data
+                curPage.setFirst( ( short ) 0 ); // no rowids, just data
                 file.release( start, true );
                 neededLeft -= DataPage.DATA_PER_PAGE;
             }
-            
-            if ( neededLeft > 0 ) 
+
+            if ( neededLeft > 0 )
             {
                 // done with whole chunks, allocate last fragment.
                 start = pageManager.allocate( Magic.USED_PAGE );
                 curBlock = file.get( start );
                 curPage = DataPage.getDataPageView( curBlock );
-                curPage.setFirst( (short) (DataPage.O_DATA + neededLeft) );
+                curPage.setFirst( ( short ) ( DataPage.O_DATA + neededLeft ) );
                 file.release( start, true );
             }
-        } else 
+        }
+        else
         {
             // just update the current page. If there's less than 16 bytes
             // left, we increase the allocation (16 bytes is an arbitrary
             // number).
-            if ( freeHere - size <= (16 + RecordHeader.SIZE) ) 
+            if ( freeHere - size <= ( 16 + RecordHeader.SIZE ) )
             {
                 size = freeHere;
             }
-            
+
             hdr.setAvailableSize( size );
             file.release( start, true );
         }
-        
+
         return retval;
     }
 
@@ -334,42 +338,42 @@ final class PhysicalRowIdManager
         // write the rowid to the free list
         freePageManager.put( id, hdr.getAvailableSize() );
     }
-    
+
 
     /**
      *  Writes out data to a rowid. Assumes that any resizing has been
      *  done.
      */
-    private void write(Location rowid, byte[] data, int start, int length )
+    private void write( Location rowid, byte[] data, int start, int length )
         throws IOException
     {
         PageCursor curs = new PageCursor( pageManager, rowid.getBlock() );
         BlockIo block = file.get( curs.getBlockId() );
         RecordHeader hdr = new RecordHeader( block, rowid.getOffset() );
         hdr.setCurrentSize( length );
-        
-        if ( length == 0 ) 
+
+        if ( length == 0 )
         {
             file.release( curs.getBlockId(), true );
-            
+
             return;
         }
 
         // copy bytes in
         int offsetInBuffer = start;
         int leftToWrite = length;
-        short dataOffset = (short) (rowid.getOffset() + RecordHeader.SIZE);
-        
-        while ( leftToWrite > 0 ) 
+        short dataOffset = ( short ) ( rowid.getOffset() + RecordHeader.SIZE );
+
+        while ( leftToWrite > 0 )
         {
             // copy current page's data to return buffer
             int toCopy = RecordFile.BLOCK_SIZE - dataOffset;
 
-            if ( leftToWrite < toCopy ) 
+            if ( leftToWrite < toCopy )
             {
                 toCopy = leftToWrite;
             }
-            
+
             System.arraycopy( data, offsetInBuffer, block.getData(), dataOffset, toCopy );
 
             // Go to the next block
@@ -378,7 +382,7 @@ final class PhysicalRowIdManager
 
             file.release( curs.getBlockId(), true );
 
-            if ( leftToWrite > 0 ) 
+            if ( leftToWrite > 0 )
             {
                 block = file.get( curs.next() );
                 dataOffset = DataPage.O_DATA;
@@ -386,4 +390,3 @@ final class PhysicalRowIdManager
         }
     }
 }
-

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/Provider.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/Provider.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/Provider.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/Provider.java Tue Jan 24 16:15:05 2012
@@ -48,6 +48,7 @@
 
 package jdbm.recman;
 
+
 import java.io.IOException;
 import java.util.Properties;
 
@@ -58,6 +59,7 @@ import jdbm.helper.MRU;
 
 import org.apache.directory.server.i18n.I18n;
 
+
 /**
  * Provider of the default RecordManager implementation.
  *
@@ -81,8 +83,8 @@ public final class Provider implements R
         RecordManager recman = new BaseRecordManager( name );
 
         String value = options.getProperty( RecordManagerOptions.DISABLE_TRANSACTIONS, "false" );
-        
-        if ( value.equalsIgnoreCase( "TRUE" ) ) 
+
+        if ( value.equalsIgnoreCase( "TRUE" ) )
         {
             ( ( BaseRecordManager ) recman ).disableTransactions();
         }
@@ -91,21 +93,21 @@ public final class Provider implements R
         int cacheSize = Integer.parseInt( value );
 
         value = options.getProperty( RecordManagerOptions.CACHE_TYPE, RecordManagerOptions.NORMAL_CACHE );
-        
-        if ( value.equalsIgnoreCase( RecordManagerOptions.NORMAL_CACHE ) ) 
+
+        if ( value.equalsIgnoreCase( RecordManagerOptions.NORMAL_CACHE ) )
         {
             MRU cache = new MRU( cacheSize );
             recman = new CacheRecordManager( recman, cache );
-        } 
-        else if ( value.equalsIgnoreCase( RecordManagerOptions.SOFT_REF_CACHE ) ) 
+        }
+        else if ( value.equalsIgnoreCase( RecordManagerOptions.SOFT_REF_CACHE ) )
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_551 ) );
-        } 
-        else if ( value.equalsIgnoreCase( RecordManagerOptions.WEAK_REF_CACHE ) ) 
+        }
+        else if ( value.equalsIgnoreCase( RecordManagerOptions.WEAK_REF_CACHE ) )
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_552 ) );
-        } 
-        else 
+        }
+        else
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_553, value ) );
         }

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordCache.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordCache.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordCache.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordCache.java Tue Jan 24 16:15:05 2012
@@ -47,30 +47,36 @@
 
 package jdbm.recman;
 
+
 import java.io.IOException;
 
+
 /**
  *  This interface is used for synchronization.
  *  <p>
  *  RecordManager ensures that the cache has the up-to-date information
  *  by way of an invalidation protocol.
  */
-public interface RecordCache {
+public interface RecordCache
+{
 
     /**
      * Notification to flush content related to a given record.
      */
-    public void flush(long recid) throws IOException;
+    public void flush( long recid ) throws IOException;
+
 
     /**
      * Notification to flush data all of records.
      */
     public void flushAll() throws IOException;
 
+
     /**
      * Notification to invalidate content related to given record.
      */
-    public void invalidate(long recid) throws IOException;
+    public void invalidate( long recid ) throws IOException;
+
 
     /**
      * Notification to invalidate content of all records.

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordFile.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordFile.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordFile.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordFile.java Tue Jan 24 16:15:05 2012
@@ -64,7 +64,7 @@ import org.apache.directory.server.i18n.
  *  The set of dirty records on the in-use list constitutes a transaction.
  *  Later on, we will send these records to some recovery thingy.
  */
-public final class RecordFile 
+public final class RecordFile
 {
     private TransactionManager transactionManager;
 
@@ -72,15 +72,15 @@ public final class RecordFile 
     // free is a cache, thus a FIFO. The rest are hashes.
     /** The list of free pages */
     private final LinkedList<BlockIo> free = new LinkedList<BlockIo>();
-    
+
     /** The map of pages being currently used */
-    private final HashMap<Long,BlockIo> inUse = new HashMap<Long,BlockIo>();
-    
+    private final HashMap<Long, BlockIo> inUse = new HashMap<Long, BlockIo>();
+
     /** The map of dirty pages (page being modified) */
-    private final HashMap<Long,BlockIo> dirty = new HashMap<Long,BlockIo>();
-    
+    private final HashMap<Long, BlockIo> dirty = new HashMap<Long, BlockIo>();
+
     /** The map of page in a transaction */
-    private final HashMap<Long,BlockIo> inTxn = new HashMap<Long,BlockIo>();
+    private final HashMap<Long, BlockIo> inTxn = new HashMap<Long, BlockIo>();
 
     /** A flag set if transactions is disabled. Default to false */
     private boolean transactionsDisabled = false;
@@ -96,11 +96,11 @@ public final class RecordFile 
 
     /** The underlying file */
     private RandomAccessFile file;
-    
+
     /** The file name */
     private final String fileName;
 
-    
+
     /**
      * Creates a new object on the indicated filename. The file is
      * opened in read/write mode.
@@ -110,7 +110,7 @@ public final class RecordFile 
      * @throws IOException whenever the creation of the underlying
      *         RandomAccessFile throws it.
      */
-    RecordFile( String fileName ) throws IOException 
+    RecordFile( String fileName ) throws IOException
     {
         this.fileName = fileName;
         file = new RandomAccessFile( fileName + EXTENSION, "rw" );
@@ -127,12 +127,12 @@ public final class RecordFile 
         {
             throw new IllegalStateException( "Transactions are disabled." );
         }
-        
+
         if ( transactionManager == null )
         {
             transactionManager = new TransactionManager( this );
         }
-        
+
         return transactionManager;
     }
 
@@ -140,22 +140,22 @@ public final class RecordFile 
     /**
      * @return the file name.
      */
-    String getFileName() 
+    String getFileName()
     {
         return fileName;
     }
 
-    
+
     /**
      * Disables transactions: doesn't sync and doesn't use the
      * transaction manager.
      */
-    void disableTransactions() 
+    void disableTransactions()
     {
         transactionsDisabled = true;
     }
 
-    
+
     /**
      * Gets a block from the file. The returned byte array is the in-memory 
      * copy of the record, and thus can be written (and subsequently released 
@@ -163,64 +163,64 @@ public final class RecordFile 
      *
      * @param blockId The record number to retrieve.
      */
-     BlockIo get( long blockId ) throws IOException 
-     {
-         // try in transaction list, dirty list, free list
-         BlockIo blockIo = inTxn.get( blockId );
-         
-         if ( blockIo != null ) 
-         {
-             inTxn.remove( blockId );
-             inUse.put( blockId, blockIo );
-             
-             return blockIo;
-         }
-         
-         blockIo = dirty.get( blockId );
-         
-         if ( blockIo != null ) 
-         {
-             dirty.remove( blockId );
-             inUse.put( blockId, blockIo );
-             
-             return blockIo;
-         }
-         
-         for ( Iterator<BlockIo> iterator = free.iterator(); iterator.hasNext(); ) 
-         {
-             BlockIo cur = iterator.next();
-             
-             if ( cur.getBlockId() == blockId ) 
-             {
-                 blockIo = cur;
-                 iterator.remove();
-                 inUse.put( blockId, blockIo );
-                 
-                 return blockIo;
-             }
-         }
-
-         // sanity check: can't be on in use list
-         if ( inUse.get( blockId ) != null ) 
-         {
-             throw new Error( I18n.err( I18n.ERR_554, blockId ) );
-         }
-
-         // get a new node and read it from the file
-         blockIo = getNewBlockIo( blockId );
-         long offset = blockId * BLOCK_SIZE;
-         long fileLength = file.length();
-         
-         if ( ( fileLength > 0 ) && ( offset <= fileLength ) ) 
-         {
-             read( file, offset, blockIo.getData(), BLOCK_SIZE );
-         } 
-         
-         inUse.put( blockId, blockIo );
-         blockIo.setClean();
-         
-         return blockIo;
-     }
+    BlockIo get( long blockId ) throws IOException
+    {
+        // try in transaction list, dirty list, free list
+        BlockIo blockIo = inTxn.get( blockId );
+
+        if ( blockIo != null )
+        {
+            inTxn.remove( blockId );
+            inUse.put( blockId, blockIo );
+
+            return blockIo;
+        }
+
+        blockIo = dirty.get( blockId );
+
+        if ( blockIo != null )
+        {
+            dirty.remove( blockId );
+            inUse.put( blockId, blockIo );
+
+            return blockIo;
+        }
+
+        for ( Iterator<BlockIo> iterator = free.iterator(); iterator.hasNext(); )
+        {
+            BlockIo cur = iterator.next();
+
+            if ( cur.getBlockId() == blockId )
+            {
+                blockIo = cur;
+                iterator.remove();
+                inUse.put( blockId, blockIo );
+
+                return blockIo;
+            }
+        }
+
+        // sanity check: can't be on in use list
+        if ( inUse.get( blockId ) != null )
+        {
+            throw new Error( I18n.err( I18n.ERR_554, blockId ) );
+        }
+
+        // get a new node and read it from the file
+        blockIo = getNewBlockIo( blockId );
+        long offset = blockId * BLOCK_SIZE;
+        long fileLength = file.length();
+
+        if ( ( fileLength > 0 ) && ( offset <= fileLength ) )
+        {
+            read( file, offset, blockIo.getData(), BLOCK_SIZE );
+        }
+
+        inUse.put( blockId, blockIo );
+        blockIo.setClean();
+
+        return blockIo;
+    }
 
 
     /**
@@ -229,58 +229,58 @@ public final class RecordFile 
      * @param blockId The record number to release.
      * @param isDirty If true, the block was modified since the get().
      */
-    void release( long blockId, boolean isDirty ) throws IOException 
+    void release( long blockId, boolean isDirty ) throws IOException
     {
         BlockIo blockIo = inUse.get( blockId );
-        
+
         if ( blockIo == null )
         {
             throw new IOException( I18n.err( I18n.ERR_555, blockId ) );
         }
-        
-        if ( ! blockIo.isDirty() && isDirty )
+
+        if ( !blockIo.isDirty() && isDirty )
         {
             blockIo.setDirty();
         }
-            
+
         release( blockIo );
     }
 
-    
+
     /**
      * Releases a block.
      *
      * @param block The block to release.
      */
-    void release( BlockIo block ) 
+    void release( BlockIo block )
     {
         inUse.remove( block.getBlockId() );
-        
-        if ( block.isDirty() ) 
+
+        if ( block.isDirty() )
         {
             // System.out.println( "Dirty: " + key + block );
             dirty.put( block.getBlockId(), block );
-        } 
-        else 
+        }
+        else
         {
-            if ( ! transactionsDisabled && block.isInTransaction() ) 
+            if ( !transactionsDisabled && block.isInTransaction() )
             {
                 inTxn.put( block.getBlockId(), block );
-            } 
-            else 
+            }
+            else
             {
                 free.add( block );
             }
         }
     }
-    
+
 
     /**
      * Discards a block (will not write the block even if it's dirty)
      *
      * @param block The block to discard.
      */
-    void discard( BlockIo block ) 
+    void discard( BlockIo block )
     {
         inUse.remove( block.getBlockId() );
 
@@ -288,14 +288,14 @@ public final class RecordFile 
         //       it's considered invalid
     }
 
-    
+
     /**
      * Commits the current transaction by flushing all dirty buffers to disk.
      */
-    void commit() throws IOException 
+    void commit() throws IOException
     {
         // debugging...
-        if ( ! inUse.isEmpty() && inUse.size() > 1 ) 
+        if ( !inUse.isEmpty() && inUse.size() > 1 )
         {
             showList( inUse.values().iterator() );
             throw new Error( I18n.err( I18n.ERR_556, inUse.size() ) );
@@ -303,102 +303,100 @@ public final class RecordFile 
 
         //  System.out.println("committing...");
 
-        if ( dirty.size() == 0 ) 
+        if ( dirty.size() == 0 )
         {
             // if no dirty blocks, skip commit process
             return;
         }
 
-        
-        if ( ! transactionsDisabled ) 
+        if ( !transactionsDisabled )
         {
             getTxnMgr().start();
         }
 
-        
-        for ( BlockIo blockIo : dirty.values() ) 
+        for ( BlockIo blockIo : dirty.values() )
         {
             // System.out.println("node " + node + " map size now " + dirty.size());
-            if ( transactionsDisabled ) 
+            if ( transactionsDisabled )
             {
                 sync( blockIo );
                 blockIo.setClean();
                 free.add( blockIo );
             }
-            else 
+            else
             {
                 getTxnMgr().add( blockIo );
                 inTxn.put( blockIo.getBlockId(), blockIo );
             }
         }
-        
+
         dirty.clear();
 
-        if ( ! transactionsDisabled ) 
+        if ( !transactionsDisabled )
         {
             getTxnMgr().commit();
         }
     }
 
-    
+
     /**
      * Rollback the current transaction by discarding all dirty buffers
      */
-    void rollback() throws IOException 
+    void rollback() throws IOException
     {
         // debugging...
-        if ( ! inUse.isEmpty() ) 
+        if ( !inUse.isEmpty() )
         {
             showList( inUse.values().iterator() );
             throw new Error( I18n.err( I18n.ERR_557, inUse.size() ) );
         }
-    
+
         //  System.out.println("rollback...");
         dirty.clear();
 
-        if ( ! transactionsDisabled ) 
+        if ( !transactionsDisabled )
         {
             getTxnMgr().synchronizeLogFromDisk();
         }
 
-        if ( ! inTxn.isEmpty() ) 
+        if ( !inTxn.isEmpty() )
         {
             showList( inTxn.values().iterator() );
             throw new Error( I18n.err( I18n.ERR_558, inTxn.size() ) );
         }
     }
 
-    
+
     /**
      * Commits and closes file.
      */
-    void close() throws IOException 
+    void close() throws IOException
     {
-        if ( ! dirty.isEmpty() ) 
+        if ( !dirty.isEmpty() )
         {
             commit();
         }
-        
-        if( ! transactionsDisabled )
+
+        if ( !transactionsDisabled )
         {
             getTxnMgr().shutdown();
         }
 
-        if ( ! inTxn.isEmpty() ) 
+        if ( !inTxn.isEmpty() )
         {
             showList( inTxn.values().iterator() );
             throw new Error( I18n.err( I18n.ERR_559 ) );
         }
 
         // these actually ain't that bad in a production release
-        if ( ! dirty.isEmpty() ) 
+        if ( !dirty.isEmpty() )
         {
             System.out.println( "ERROR: dirty blocks at close time" );
             showList( dirty.values().iterator() );
             throw new Error( I18n.err( I18n.ERR_560 ) );
         }
-        
-        if ( ! inUse.isEmpty() ) 
+
+        if ( !inUse.isEmpty() )
         {
             System.out.println( "ERROR: inUse blocks at close time" );
             showList( inUse.values().iterator() );
@@ -416,23 +414,23 @@ public final class RecordFile 
      * Force closing the file and underlying transaction manager.
      * Used for testing purposed only.
      */
-    void forceClose() throws IOException 
+    void forceClose() throws IOException
     {
-        if ( ! transactionsDisabled ) 
+        if ( !transactionsDisabled )
         {
             getTxnMgr().forceClose();
         }
         file.close();
     }
 
-    
+
     /**
      * Prints contents of a list
      */
-    private void showList( Iterator<BlockIo> i ) 
+    private void showList( Iterator<BlockIo> i )
     {
         int cnt = 0;
-        while ( i.hasNext() ) 
+        while ( i.hasNext() )
         {
             System.out.println( "elem " + cnt + ": " + i.next() );
             cnt++;
@@ -444,26 +442,26 @@ public final class RecordFile 
      * Returns a new BlockIo. The BlockIo is retrieved (and removed) from the 
      * released list or created new.
      */
-    private BlockIo getNewBlockIo( long blockId ) throws IOException 
+    private BlockIo getNewBlockIo( long blockId ) throws IOException
     {
         BlockIo blockIo = null;
 
-        if ( ! free.isEmpty() ) 
+        if ( !free.isEmpty() )
         {
             blockIo = ( BlockIo ) free.removeFirst();
             blockIo.setBlockId( blockId );
         }
-        
+
         if ( blockIo == null )
         {
             blockIo = new BlockIo( blockId, new byte[BLOCK_SIZE] );
         }
-        
+
         blockIo.setView( null );
-        
+
         return blockIo;
     }
-    
+
 
     /**
      * Synchronizes a BlockIo to disk. This is called by the transaction manager's
@@ -472,11 +470,11 @@ public final class RecordFile 
      * @param blockIo The blocIo to write on disk
      * @exception IOException If we have a problem while trying to write the blockIo to disk
      */
-    void sync( BlockIo blockIo ) throws IOException 
+    void sync( BlockIo blockIo ) throws IOException
     {
         byte[] data = blockIo.getData();
-        
-        if ( data != null ) 
+
+        if ( data != null )
         {
             // Write the data to disk now.
             long offset = blockIo.getBlockId() * BLOCK_SIZE;
@@ -485,25 +483,25 @@ public final class RecordFile 
         }
     }
 
-    
+
     /**
      * Releases a node from the transaction list, if it was sitting there.
      *
      * @param recycle true if block data can be reused
      */
-    void releaseFromTransaction( BlockIo node, boolean recycle ) throws IOException 
+    void releaseFromTransaction( BlockIo node, boolean recycle ) throws IOException
     {
-        if ( ( inTxn.remove( node.getBlockId() ) != null ) && recycle ) 
+        if ( ( inTxn.remove( node.getBlockId() ) != null ) && recycle )
         {
             free.add( node );
         }
     }
-    
+
 
     /**
      * Synchronizes the file.
      */
-    void sync() throws IOException 
+    void sync() throws IOException
     {
         file.getFD().sync();
     }
@@ -512,15 +510,15 @@ public final class RecordFile 
     /**
      * Utility method: Read a block from a RandomAccessFile
      */
-    private static void read( RandomAccessFile file, long offset, byte[] buffer, int nBytes ) throws IOException 
+    private static void read( RandomAccessFile file, long offset, byte[] buffer, int nBytes ) throws IOException
     {
         file.seek( offset );
         int remaining = nBytes;
         int pos = 0;
-        while ( remaining > 0 ) 
+        while ( remaining > 0 )
         {
             int read = file.read( buffer, pos, remaining );
-            if ( read == -1 ) 
+            if ( read == -1 )
             {
                 System.arraycopy( cleanData, 0, buffer, pos, remaining );
                 break;
@@ -529,20 +527,20 @@ public final class RecordFile 
             pos += read;
         }
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
     public String toString()
     {
         StringBuilder sb = new StringBuilder();
-        
+
         sb.append( "RecordFile<" ).append( fileName ).append( ", " );
-        
+
         // The file size
         sb.append( "size : " );
-        
+
         try
         {
             sb.append( file.length() ).append( "bytes" );
@@ -551,7 +549,7 @@ public final class RecordFile 
         {
             sb.append( "unknown" );
         }
-        
+
         // Transactions
         if ( transactionsDisabled )
         {
@@ -561,44 +559,43 @@ public final class RecordFile 
         {
             sb.append( "(Tx)" );
         }
-        
+
         // Dump the free blocks
         sb.append( "\n    Free blockIo : " ).append( free.size() );
-                
+
         for ( BlockIo blockIo : free )
         {
             sb.append( "\n         " );
             sb.append( blockIo );
         }
-        
+
         // Dump the inUse blocks
         sb.append( "\n    InUse blockIo : " ).append( inUse.size() );
-        
+
         for ( BlockIo blockIo : inUse.values() )
         {
             sb.append( "\n         " );
             sb.append( blockIo );
         }
-        
+
         // Dump the dirty blocks
         sb.append( "\n    Dirty blockIo : " ).append( dirty.size() );
-        
+
         for ( BlockIo blockIo : dirty.values() )
         {
             sb.append( "\n         " );
             sb.append( blockIo );
         }
-        
+
         // Dump the inTxn blocks
         sb.append( "\n    InTxn blockIo : " ).append( inTxn.size() );
-        
+
         for ( BlockIo blockIo : inTxn.values() )
         {
             sb.append( "\n         " );
             sb.append( blockIo );
         }
 
-        
         return sb.toString();
     }
 }

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordHeader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordHeader.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordHeader.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordHeader.java Tue Jan 24 16:15:05 2012
@@ -57,68 +57,68 @@ import org.apache.directory.server.i18n.
  * be moved and which allows the system to put small records in larger free 
  * spots.
  */
-class RecordHeader 
+class RecordHeader
 {
     // offsets
     private static final short O_CURRENTSIZE = 0; // int currentSize
     private static final short O_AVAILABLESIZE = Magic.SZ_INT; // int availableSize
     static final int SIZE = O_AVAILABLESIZE + Magic.SZ_INT;
-    
+
     // my block and the position within the block
     private BlockIo block;
     private short pos;
 
-    
+
     /**
      * Constructs a record header from the indicated data starting at the 
      * indicated position.
      */
-    RecordHeader( BlockIo block, short pos ) 
+    RecordHeader( BlockIo block, short pos )
     {
         this.block = block;
         this.pos = pos;
-        
+
         if ( pos > ( RecordFile.BLOCK_SIZE - SIZE ) )
         {
             throw new Error( I18n.err( I18n.ERR_562, block.getBlockId(), pos ) );
         }
     }
 
-    
+
     /** Returns the current size */
-    int getCurrentSize() 
+    int getCurrentSize()
     {
         return block.readInt( pos + O_CURRENTSIZE );
     }
-    
-    
+
+
     /** Sets the current size */
-    void setCurrentSize( int value ) 
+    void setCurrentSize( int value )
     {
         block.writeInt( pos + O_CURRENTSIZE, value );
     }
-    
-    
+
+
     /** Returns the available size */
-    int getAvailableSize() 
+    int getAvailableSize()
     {
         return block.readInt( pos + O_AVAILABLESIZE );
     }
-    
-    
+
+
     /** Sets the available size */
-    void setAvailableSize( int value ) 
+    void setAvailableSize( int value )
     {
         block.writeInt( pos + O_AVAILABLESIZE, value );
     }
 
-    
+
     // overrides java.lang.Object
-    public String toString() 
+    public String toString()
     {
-        return "RH( " + block.getBlockId() + " : " + pos 
+        return "RH( " + block.getBlockId() + " : " + pos
             + ", avl = " + getAvailableSize()
-            + ", cur = " + getCurrentSize() 
+            + ", cur = " + getCurrentSize()
             + " )";
     }
 }
\ No newline at end of file



Mime
View raw message