private static ByteBuffer getItemByteBuffer(ByteBuff buf, int byteBufferIndex) {
    if (buf instanceof SingleByteBuff) {
      if (byteBufferIndex != 0) {
        throw new IndexOutOfBoundsException(
          "index:[" + byteBufferIndex + "],but only index 0 is valid.");
      }
      return buf.nioByteBuffers()[0];
    }
    MultiByteBuff multiByteBuff = (MultiByteBuff) buf;
    if (byteBufferIndex < 0 || byteBufferIndex >= multiByteBuff.items.length) {
      throw new IndexOutOfBoundsException("index:[" + byteBufferIndex + "],but only index [0-"
        + multiByteBuff.items.length + ") is valid.");
    }
    return multiByteBuff.items[byteBufferIndex];
  }
Copies from a src BB to this MBB. This will be absolute positional copying and won't affect the
position of any of the buffers.
@param destOffset the position in this MBB to which the copy should happen
@param src        the src MBB
@param srcOffset  the offset in the src MBB from where the elements should be read
@param length     the length upto which the copy should happen
@throws BufferUnderflowException If there are fewer than length bytes remaining in src
                                 ByteBuff.
@throws BufferOverflowException  If there is insufficient available space in this MBB for
                                 length bytes.
hbase-common/src/main/java/org/apache/hadoop/hbase/nio/MultiByteBuff.java