private static int searchEntry ( final List < OMMapBufferEntry > fileEntries , final long iBeginOffset , final int iSize ) { if ( fileEntries == null || fileEntries . size ( ) == 0 ) return - 1 ; int high = fileEntries . size ( ) - 1 ; if ( high < 0 ) // NOT FOUND return - 1 ; int low = 0 ; int mid = - 1 ; // BINARY SEARCH OMMapBufferEntry e ; while ( low <= high ) { mid = ( low + high ) >>> 1 ; e = fileEntries . get ( mid ) ; if ( iBeginOffset >= e . beginOffset && iBeginOffset + iSize <= e . beginOffset + e . size ) { // FOUND: USE IT OProfiler . getInstance ( ) . updateCounter ( "OMMapManager.reusedPage" , 1 ) ; e . counter ++ ; return mid ; } if ( low == high ) { if ( iBeginOffset > e . beginOffset ) // NEXT POSITION low ++ ; // NOT FOUND return ( low + 2 ) * - 1 ; } if ( iBeginOffset >= e . beginOffset ) low = mid + 1 ; else high = mid ; } // NOT FOUND return mid ; }
Search for a buffer in the ordered list .