protected boolean readAtOffset(FSDataInputStream istream, ByteBuff dest, int size,
      boolean peekIntoNextBlock, long fileOffset, boolean pread) throws IOException {
      if (!pread) {
        // Seek + read. Better for scanning.
        istream.seek(fileOffset);
        long realOffset = istream.getPos();
        if (realOffset != fileOffset) {
          throw new IOException("Tried to seek to " + fileOffset + " to read " + size
            + " bytes, but pos=" + realOffset + " after seek");
        }
        if (!peekIntoNextBlock) {
          BlockIOUtils.readFully(dest, istream, size);
          return false;
        }

        // Try to read the next block header
        if (!BlockIOUtils.readWithExtra(dest, istream, size, hdrSize)) {
          // did not read the next block header.
          return false;
        }
      } else {
        // Positional read. Better for random reads; or when the streamLock is already locked.
        int extraSize = peekIntoNextBlock ? hdrSize : 0;
        if (
          !BlockIOUtils.preadWithExtra(dest, istream, fileOffset, size, extraSize, isPreadAllBytes)
        ) {
          // did not read the next block header.
          return false;
        }
      }
      assert peekIntoNextBlock;
      return true;
    }
Does a positional read or a seek and read into the given byte buffer. We need take care that
we will call the {@link ByteBuff#release()} for every exit to deallocate the ByteBuffers,
otherwise the memory leak may happen.
@param dest              destination buffer
@param size              size of read
@param peekIntoNextBlock whether to read the next block's on-disk size
@param fileOffset        position in the stream to read at
@param pread             whether we should do a positional read
@param istream           The input source of data
@return true to indicate the destination buffer include the next block header, otherwise only
        include the current block data without the next block header.
@throws IOException if any IO error happen.
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java