code: private int binarySearch(OMMapBufferEntry[] fileEntries, long beginOffset, int beginPosition, int endPosition) {
      int midPosition;
  
      while (beginPosition <= endPosition) {
        midPosition = (beginPosition + endPosition) >>> 1;
  
        final OMMapBufferEntry entry = fileEntries[midPosition];
  
        if (entry.beginOffset + entry.size > beginOffset && entry.beginOffset <= beginOffset) {
          // FOUND: USE IT
          return midPosition;
        }
  
        if (beginPosition == endPosition) {
          // NOT FOUND
          return -1;
        }
  
        if (beginOffset > entry.beginOffset)
          beginPosition = midPosition + 1;
        else
          endPosition = midPosition;
      }
  
      // NOT FOUND
      return -1;
    }
docs: This method is used in
  com.orientechnologies.orient.core.storage.fs.OMMapManagerNew#searchAmongExisting(com.orientechnologies.orient
  .core.storage.fs.OFileMMap, com.orientechnologies.orient.core.storage.fs.OMMapBufferEntry[], long, int) to search necessary
  entry.
  
  @param fileEntries
  already mapped entries.
  @param beginOffset
  position in file that should be mmaped.
  @param beginPosition
  first position in fileEntries.
  @param endPosition
  last position in fileEntries.
  @return -1 if entries is not found. Otherwise returns middle position of file entries to perform new binary search step.