private static int getItemIndexForByteBuff(ByteBuff byteBuff, int offset, int length) {
    if (byteBuff instanceof SingleByteBuff) {
      ByteBuffer byteBuffer = byteBuff.nioByteBuffers()[0];
      if (offset + length > byteBuffer.limit()) {
        throw new BufferUnderflowException();
      }
      return 0;
    }
    MultiByteBuff multiByteBuff = (MultiByteBuff) byteBuff;
    return multiByteBuff.getItemIndex(offset);
  }
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