directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1167142 - in /directory/apacheds/trunk/jdbm/src: main/java/jdbm/btree/BPage.java main/java/jdbm/btree/BTree.java main/java/jdbm/helper/LRUCache.java test/java/jdbm/btree/TestSnapshotBTree.java
Date Fri, 09 Sep 2011 12:56:57 GMT
Author: elecharny
Date: Fri Sep  9 12:56:57 2011
New Revision: 1167142

URL: http://svn.apache.org/viewvc?rev=1167142&view=rev
Log:
Code formating

Modified:
    directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BPage.java
    directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BTree.java
    directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LRUCache.java
    directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/TestSnapshotBTree.java

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BPage.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BPage.java?rev=1167142&r1=1167141&r2=1167142&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BPage.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BPage.java Fri Sep  9 12:56:57
2011
@@ -221,10 +221,14 @@ public class BPage<K, V> implements Seri
         newPage.recordId = this.recordId;
         
         if ( this.children != null )
+        {
             this.copyChildren( this, 0, newPage, 0, btree.pageSize ); // this copies keys
as well
+        }
         
-        if (this.values != null ) 
+        if (this.values != null )
+        {
             this.copyEntries( this, 0, newPage, 0, btree.pageSize ); // this copies keys
as well
+        }
         
         return newPage;
     }
@@ -1494,7 +1498,9 @@ public class BPage<K, V> implements Seri
             finally
             {
                 if ( context != null )
+                {
                     btree.unsetAsCurrentAction( context );
+                }
             }
           
             return true;
@@ -1502,7 +1508,8 @@ public class BPage<K, V> implements Seri
 
         public boolean getPrevious( Tuple<K, V> tuple ) throws IOException
         {
-            btree.setAsCurrentAction( context );           
+            btree.setAsCurrentAction( context );
+            
             try
             {
                 if ( index == page.first )
@@ -1514,7 +1521,7 @@ public class BPage<K, V> implements Seri
                     }
                     else
                     {
-                        // reached beginning of the tree                                
                            
+                        // reached beginning of the tree
                         return false;
                     }
                 }
@@ -1533,8 +1540,10 @@ public class BPage<K, V> implements Seri
             finally
             {
                 if ( context != null )
+                {
                     btree.unsetAsCurrentAction( context );
-            }          
+                }
+            }
 
             return true;
         }
@@ -1552,6 +1561,7 @@ public class BPage<K, V> implements Seri
             }
             
             int browserCount = outstandingBrowsers.decrementAndGet();
+            
             if ( browserCount > 0 )
             {
                 //System.out.println( "JDBM btree browsers are outstanding after close: "
+ browserCount );

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BTree.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BTree.java?rev=1167142&r1=1167141&r2=1167142&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BTree.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BTree.java Fri Sep  9 12:56:57
2011
@@ -951,7 +951,9 @@ public class BTree<K, V> implements Exte
         
         
         if ( value == null )
+        {
             return null;
+        }
         
         if ( this.valueSerializer != null )
         {

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LRUCache.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LRUCache.java?rev=1167142&r1=1167141&r2=1167142&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LRUCache.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LRUCache.java Fri Sep  9 12:56:57
2011
@@ -242,6 +242,7 @@ public class LRUCache<K, V>
                                 
                                 entry.setNeverReplace();
                                 CacheEntry newEntry = null;
+                                
                                 try
                                 {
                                     newEntry = this.findNewEntry( key, hashIndex >>
LOG_BUCKET_PER_LATCH );
@@ -340,7 +341,9 @@ public class LRUCache<K, V>
         }
         
         if ( totalSleepTime != 0 )
+        {  
             this.cachePutSleeps++;
+        }
     }
     
     
@@ -404,8 +407,10 @@ public class LRUCache<K, V>
                         {
                             value = this.searchChainForVersion( entry, version );
                             
-                            if (value != null)
+                            if ( value != null )
+                            {
                                 break;
+                            }
                             
                             this.cacheMisses++;
                             
@@ -413,6 +418,7 @@ public class LRUCache<K, V>
                             
                             entry.setNeverReplace();
                             CacheEntry newEntry = null;
+                            
                             try
                             {
                                 newEntry = this.findNewEntry( key, hashIndex >> LOG_BUCKET_PER_LATCH
);
@@ -526,11 +532,15 @@ public class LRUCache<K, V>
         {
             
             boolean resetNeverReplace = true;
+            
             if ( entry.isNeverReplace() )
+            {  
                 resetNeverReplace = false;
+            }
             
             entry.setNeverReplace();
             CacheEntry newEntry = null;
+            
             try
             {
                 newEntry = this.findNewEntry( key, hashIndex >> LOG_BUCKET_PER_LATCH
);
@@ -538,11 +548,11 @@ public class LRUCache<K, V>
             finally
             {
                 if ( resetNeverReplace )
+                {
                     entry.clearNeverReplace();
+                }
             }
             
-            
-            
             // Set to new version 
             newEntry.setAsCurrentVersion( value, newVersion );
 

Modified: directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/TestSnapshotBTree.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/TestSnapshotBTree.java?rev=1167142&r1=1167141&r2=1167142&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/TestSnapshotBTree.java (original)
+++ directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/TestSnapshotBTree.java Fri Sep
 9 12:56:57 2011
@@ -37,10 +37,6 @@ import jdbm.recman.SnapshotRecordManager
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
-import org.junit.runner.RunWith;
-
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
 
 /**
  * 
@@ -48,8 +44,6 @@ import com.mycila.junit.concurrent.Concu
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-//@RunWith(ConcurrentJunitRunner.class)
-//@Concurrency()
 public class TestSnapshotBTree
 {
     @Rule
@@ -101,12 +95,12 @@ public class TestSnapshotBTree
         updateThread = new BasicTestThread( false, tree, browseSem, updateSem, numReadThreads
);      
         
         updateThread.start();
+        
         for ( idx = 0; idx < numReadThreads; idx++ )
         {
             readThreads[idx].start();
         }
         
-        
         for ( idx = 0; idx < numReadThreads; idx++ )
         {
             readThreads[idx].join();
@@ -161,7 +155,9 @@ public class TestSnapshotBTree
 
                 // Sleep a little randomly.                                             
                                                                                         
                       
                 if ( (count & 7) == 0 )
+                {
                     Thread.sleep( 1 );
+                }
 
                 assertTrue( tuple.getValue().value != -1 );
             }
@@ -175,6 +171,7 @@ public class TestSnapshotBTree
             browser = btree.browse( new Integer( 10 ) );
 
             browseSem.release();
+            
             for ( idx = 20; idx < 1024; idx++ )
             {
                 assertTrue( browser.getNext( tuple ) );
@@ -182,6 +179,7 @@ public class TestSnapshotBTree
                 //System.out.println( "key:"+ tuple.getKey().intValue() + " idx:" + idx );
                 assertTrue( tuple.getKey().intValue() == idx );
             }
+            
             browser.close();
         }
         
@@ -190,7 +188,9 @@ public class TestSnapshotBTree
             int idx;
 
             for ( idx = 0; idx < numReadThreads; idx++ )
+            {
                 browseSem.acquireUninterruptibly();
+            }
 
             
             Integer key = new Integer( 1023 );
@@ -214,6 +214,7 @@ public class TestSnapshotBTree
             
             btree.insert( key, value , true );
             btree.insert( new Integer(1024), new IntWrapper( -1 ), true );
+            
             for ( idx = 10; idx < 20; idx++ )
             {
                 btree.remove( new Integer( idx ) );
@@ -222,15 +223,19 @@ public class TestSnapshotBTree
             updateSem.release();
 
             for ( idx = 0; idx < numReadThreads; idx++ )
+            {
                 browseSem.acquireUninterruptibly();
+            }
 
             for ( idx = 0; idx < 10; idx++ )
+            {
                 btree.remove( new Integer( idx ) );
+            }
 
             for ( idx = 20; idx < 1024; idx++ )
+            {
                 btree.remove( new Integer( idx ) );
-
-
+            }
         }
 
 
@@ -239,9 +244,13 @@ public class TestSnapshotBTree
             try
             {
                 if ( readOnly )
+                {
                     this.readOnlyActions();
+                }
                 else
+                {
                     this.readWriteActions();
+                }
             }
             catch( IOException e )
             {
@@ -292,17 +301,18 @@ public class TestSnapshotBTree
         Thread.sleep( 10 );
         
         updateThread.start();
+        
         for ( idx = 1; idx < numReadThreads; idx++ )
         {
             Thread.sleep( 1000 );
             readThreads[idx].start();
         }
         
-        
         for ( idx = 0; idx < numReadThreads; idx++ )
         {
             readThreads[idx].join();
         }
+        
         updateThread.join();
         
         snapshotRecman.close();
@@ -401,9 +411,13 @@ public class TestSnapshotBTree
             try
             {
                 if ( readOnly )
+                {
                     this.readOnlyActions();
+                }
                 else
+                {
                     this.readWriteActions();
+                }
             }
             catch( IOException e )
             {
@@ -453,13 +467,13 @@ public class TestSnapshotBTree
         
         
         updateThread.start();
+        
         for ( idx = 0; idx < numReadThreads; idx++ )
         {
             Thread.sleep( 1000 );
             readThreads[idx].start();
         }
         
-        
         for ( idx = 0; idx < numReadThreads; idx++ )
         {
             readThreads[idx].join();
@@ -525,7 +539,9 @@ public class TestSnapshotBTree
             Random updateRandomizer = new Random();
             
             for ( idx = 0; idx < numReadThreads; idx++ )
+            {
                 browseSem.acquireUninterruptibly();
+            }
             
           
             Integer key;
@@ -542,15 +558,16 @@ public class TestSnapshotBTree
                     key = new Integer( startingIndex + updates );
                     
                     if ( key.intValue() >= numElements )
+                    {
                         break;
-                        
+                    }   
                         
                     btree.remove( key );
                 }
                 
                 for ( int updates = 0; updates < 32; updates++ )
-                {                    
-                    key = new Integer( startingIndex + updates );                       
  
+                {
+                    key = new Integer( startingIndex + updates );
                     btree.insert( key, value, true );
                 }
             }
@@ -565,9 +582,13 @@ public class TestSnapshotBTree
             try
             {
                 if ( readOnly )
+                {
                     this.readOnlyActions();
+                }
                 else
+                {
                     this.readWriteActions();
+                }
             }
             catch( IOException e )
             {
@@ -583,7 +604,4 @@ public class TestSnapshotBTree
             
         }
     } // end of class RemoveInsertTestThread
-    
-    
-    
 }
\ No newline at end of file



Mime
View raw message