public boolean removeEntryWithPosition ( final long iPosition ) throws IOException { // BROWSE IN ASCENDING ORDER UNTIL THE REQUESTED POSITION IS FOUND boolean canShrink = true ; for ( int pos = getHoles ( ) - 1 ; pos >= 0 ; -- pos ) { final long recycledPosition = file . readLong ( pos * RECORD_SIZE ) ; if ( recycledPosition == iPosition ) { if ( OLogManager . instance ( ) . isDebugEnabled ( ) ) OLogManager . instance ( ) . debug ( this , "Removing hole #%d containing the position #%d:%d" , pos , owner . getId ( ) , recycledPosition ) ; file . writeLong ( pos * RECORD_SIZE , - 1 ) ; if ( canShrink ) // SHRINK THE FILE file . removeTail ( ( getHoles ( ) - pos ) * RECORD_SIZE ) ; return true ; } else if ( iPosition != - 1 ) // NO NULL ENTRY: CAN'T SHRINK WITHOUT LOST OF ENTRIES canShrink = false ; } return false ; }
Removes a hole . Called on transaction recover to invalidate a delete for a record . Try to shrink the file if the invalidated entry is not in the middle of valid entries .