private void countObjects ( ) throws IOException , EOFException , FileManagerException , ClassNotFoundException , HashtableOnDiskException { println ( "countObjects(): Hashtable " + filename + " was not closed properly. Validating " ) ; iterationLock . p ( ) ; int count = 0 ; try { for ( int i = 0 ; i < header . tablesize ( ) ; i ++ ) { // // We want to drop the lock between each iteration so that other // threads can continue to work // long next = getHtindex ( i , header . currentTableId ( ) ) ; // jrc 04/30/02 use cached entry while ( next != 0 ) { count ++ ; if ( ( count % 100 ) == 0 ) { if ( debug ) print ( "." ) ; } filemgr . seek ( next ) ; next = filemgr . readLong ( ) ; } } header . set_num_objects ( count ) ; header . write ( ) ; } finally { iterationLock . v ( ) ; } println ( "countObjects(): done[" + count + "]" ) ; }
This walks the hash table and sets the internal count of objects . It is streamlined to only get a count and not examine any objects .