Ejemplo n.º 1
0
 private static OMMapBufferEntry mapBuffer(
     final OFileMMap iFile, final long iBeginOffset, final int iSize) throws IOException {
   long timer = OProfiler.getInstance().startChrono();
   try {
     return new OMMapBufferEntry(iFile, iFile.map(iBeginOffset, iSize), iBeginOffset, iSize);
   } finally {
     OProfiler.getInstance().stopChrono("OMMapManager.loadPage", timer);
   }
 }
Ejemplo n.º 2
0
  private static int computeBestEntrySize(
      final OFileMMap iFile,
      final long iBeginOffset,
      final int iSize,
      final boolean iForce,
      List<OMMapBufferEntry> fileEntries,
      int p) {
    int bufferSize;
    if (p > -1 && p < fileEntries.size()) {
      // GET NEXT ENTRY AS SIZE LIMIT
      bufferSize = (int) (fileEntries.get(p).beginOffset - iBeginOffset);
      if (bufferSize < iSize)
        // ROUND TO THE BUFFER SIZE
        bufferSize = iSize;

      if (bufferSize < blockSize) bufferSize = blockSize;
    } else {
      // ROUND TO THE BUFFER SIZE
      bufferSize = iForce ? iSize : iSize < blockSize ? blockSize : iSize;

      if (iBeginOffset + bufferSize > iFile.getFileSize())
        // REQUESTED BUFFER IS TOO LARGE: GET AS MAXIMUM AS POSSIBLE
        bufferSize = (int) (iFile.getFileSize() - iBeginOffset);
    }

    if (bufferSize <= 0)
      throw new IllegalArgumentException(
          "Invalid range requested for file "
              + iFile
              + ". Requested "
              + iSize
              + " bytes from the address "
              + iBeginOffset
              + " while the total file size is "
              + iFile.getFileSize());

    return bufferSize;
  }