public static boolean preadWithExtra(ByteBuff buff, FSDataInputStream dis, long position,
    int necessaryLen, int extraLen, boolean readAllBytes) throws IOException {
    boolean preadbytebuffer = dis.hasCapability("in:preadbytebuffer");

    if (preadbytebuffer) {
      return preadWithExtraDirectly(buff, dis, position, necessaryLen, extraLen, readAllBytes);
    } else {
      return preadWithExtraOnHeap(buff, dis, position, necessaryLen, extraLen, readAllBytes);
    }
  }
Read from an input stream at least <code>necessaryLen</code> and if possible,
<code>extraLen</code> also if available. Analogous to
{@link IOUtils#readFully(InputStream, byte[], int, int)}, but uses positional read and
specifies a number of "extra" bytes that would be desirable but not absolutely necessary to
read. If the input stream supports ByteBufferPositionedReadable, it reads to the byte buffer
directly, and does not allocate a temporary byte array.
@param buff         ByteBuff to read into.
@param dis          the input stream to read from
@param position     the position within the stream from which to start reading
@param necessaryLen the number of bytes that are absolutely necessary to read
@param extraLen     the number of extra bytes that would be nice to read
@param readAllBytes whether we must read the necessaryLen and extraLen
@return true if and only if extraLen is > 0 and reading those extra bytes was successful
@throws IOException if failed to read the necessary bytes
hbase-common/src/main/java/org/apache/hadoop/hbase/io/util/BlockIOUtils.java