public static void copyFromArrayToBuffer(ByteBuffer out, byte[] in, int inOffset, int length) {
    if (out.hasArray()) {
      System.arraycopy(in, inOffset, out.array(), out.arrayOffset() + out.position(), length);
      // Move the position in out by length
      out.position(out.position() + length);
    } else if (UNSAFE_AVAIL) {
      UnsafeAccess.copy(in, inOffset, out, out.position(), length);
      // Move the position in out by length
      out.position(out.position() + length);
    } else {
      out.put(in, inOffset, length);
    }
  }
Copies the bytes from given array's offset to length part into the given buffer. Puts the bytes
to buffer's current position. This also advances the position in the 'out' buffer by 'length'
@param out      output bytebuffer to copy to
@param in       input array to copy from
@param inOffset input offset to copy from
@param length   the number of bytes to copy
hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java