protected ByteBuffer acquireByteBuffer(final int iSize) {
    if (iSize > BYTEBUFFER_POOLABLE_SIZE) {
      try {
        OProfiler.getInstance().updateStat("MMap.extraBufferSize", iSize);
        // CREATE A BUFFER AT THE FLY. IT WILL BE DISCARDED WHEN FINISHED
        return ByteBuffer.allocate(iSize);
      } catch (OutOfMemoryError e) {
        // LOG THE EXCEPTION AND RE-THROW IT
        OLogManager.instance().error(this, "Error on allocating direct buffer of size %d bytes", e, iSize);
        throw e;
      }
    }

    // POP THE FIRST AVAILABLE
    ByteBuffer buffer = bufferPool.poll();
    if (buffer != null)
      OProfiler.getInstance().updateCounter("system.file.mmap.pooledBuffers", -1);
    else {
      buffer = ByteBuffer.allocateDirect(BYTEBUFFER_POOLABLE_SIZE);
      OProfiler.getInstance().updateStat("system.file.mmap.pooledBufferSize", BYTEBUFFER_POOLABLE_SIZE);
    }

    buffer.limit(iSize);

    return buffer;
  }
protected ByteBuffer acquireByteBuffer ( final int iSize ) { if ( iSize > BYTEBUFFER_POOLABLE_SIZE ) { try { OProfiler . getInstance ( ) . updateStat ( "MMap.extraBufferSize" , iSize ) ; return ByteBuffer . allocate ( iSize ) ; } catch ( OutOfMemoryError e ) { OLogManager . instance ( ) . error ( this , "Error on allocating direct buffer of size %d bytes" , e , iSize ) ; throw e ; } } ByteBuffer buffer = bufferPool . poll ( ) ; if ( buffer != null ) OProfiler . getInstance ( ) . updateCounter ( "system.file.mmap.pooledBuffers" , - 1 ) ; else { buffer = ByteBuffer . allocateDirect ( BYTEBUFFER_POOLABLE_SIZE ) ; OProfiler . getInstance ( ) . updateStat ( "system.file.mmap.pooledBufferSize" , BYTEBUFFER_POOLABLE_SIZE ) ; } buffer . limit ( iSize ) ; return buffer ; }
Acquires a byte buffer to use in read/write operations. If the requested size is minor-equals to BYTEBUFFER_POOLABLE_SIZE
bytes, then is returned from the bufferPool if any. Buffer bigger than BYTEBUFFER_POOLABLE_SIZE bytes.

@param iSize
The requested size
@return A buffer in the pool if any and if size is compatible, otherwise a new one