public static void copy(ByteBuffer src, int srcOffset, ByteBuffer dest, int destOffset,
    int length) {
    long srcAddress, destAddress;
    Object srcBase = null, destBase = null;
    if (src.isDirect()) {
      srcAddress = srcOffset + directBufferAddress(src);
    } else {
      srcAddress = (long) srcOffset + src.arrayOffset() + BYTE_ARRAY_BASE_OFFSET;
      srcBase = src.array();
    }
    if (dest.isDirect()) {
      destAddress = destOffset + directBufferAddress(dest);
    } else {
      destAddress = destOffset + BYTE_ARRAY_BASE_OFFSET + dest.arrayOffset();
      destBase = dest.array();
    }
    unsafeCopy(srcBase, srcAddress, destBase, destAddress, length);
  }
Copies specified number of bytes from given offset of {@code src} buffer into the {@code dest}
buffer.
@param src        source buffer
@param srcOffset  offset into source buffer
@param dest       destination buffer
@param destOffset offset into destination buffer
@param length     length of data to copy
hbase-common/src/main/java/org/apache/hadoop/hbase/util/UnsafeAccess.java