@Override
  public final void readFully(byte[] buffer, int offset, int length)
      throws IOException {
    if (length < 0) {
      throw new IndexOutOfBoundsException();
    }
    if (length == 0) {
      return;
    }
    if (in == null || buffer == null) {
      throw new NullPointerException("Null Pointer to underlying input stream");
    }

    if (offset < 0 || offset > buffer.length - length) {
      throw new IndexOutOfBoundsException();
    }
    while (length > 0) {
      int result = in.read(buffer, offset, length);
      if (result < 0) {
        throw new EOFException();
      }
      offset += result;
      length -= result;
    }
  }
Reads bytes from this stream and stores them in the byte array
<code>buffer</code> starting at the position <code>offset</code>. This
method blocks until <code>count</code> bytes have been read.

@param buffer
         the byte array into which the data is read
@param offset
         the offset the operation start at
@param length
         the maximum number of bytes to read

@throws IOException
          if a problem occurs while reading from this stream
@throws EOFException
          if reaches the end of the stream before enough bytes have been
          read
ql/src/java/org/apache/hadoop/hive/ql/io/NonSyncDataInputBuffer.java