public long popLastEntryPosition ( ) throws IOException { // BROWSE IN ASCENDING ORDER UNTIL A GOOD POSITION IS FOUND (!=-1) for ( int pos = getHoles ( ) - 1 ; pos >= 0 ; -- pos ) { final long recycledPosition = file . readLong ( pos * RECORD_SIZE ) ; if ( recycledPosition > - 1 ) { if ( OLogManager . instance ( ) . isDebugEnabled ( ) ) OLogManager . instance ( ) . debug ( this , "Recycled hole %s/#%d -> #%d:%d" , owner . getName ( ) , pos , owner . getId ( ) , recycledPosition ) ; // SHRINK THE FILE file . removeTail ( ( getHoles ( ) - pos ) * RECORD_SIZE ) ; return recycledPosition ; } } return - 1 ; }
Returns and remove the recycled position if any .