@Override
    protected void writeVarInt32(int value) throws IOException {
        //        ensureCapacity(5);
        //        int position = nioBuffer.position();
        //        while (true) {
        //            if ((value & ~0x7F) == 0) {
        //                UnsafeDirectBufferUtil.setByte(address(position++), (byte) value);
        //                nioBuffer.position(position);
        //                return;
        //            } else {
        //                UnsafeDirectBufferUtil.setByte(address(position++), (byte) ((value & 0x7F) | 0x80));
        //                value >>>= 7;
        //            }
        //        }
        //
        // The following implementation is no different from the above code function,
        // just aggregate multiple setBytes into a setShort/setInt
        //
        ensureCapacity(5);
        int position = nioBuffer.position();
        if ((value & (~0 << 7)) == 0) {
            // size == 1
            UnsafeDirectBufferUtil.setByte(address(position++), (byte) value);
        } else if ((value & (~0 << 14)) == 0) {
            // size == 2
            UnsafeDirectBufferUtil.setShort(address(position), (((value & 0x7F) | 0x80) << 8) | (value >>> 7));
            position += 2;
        } else if ((value & (~0 << 21)) == 0) {
            // size == 3
            UnsafeDirectBufferUtil.setShort(address(position), (((value & 0x7F) | 0x80) << 8)
                                                               | ((value >>> 7 & 0x7F) | 0x80));
            position += 2;
            UnsafeDirectBufferUtil.setByte(address(position++), (byte) (value >>> 14));
        } else if ((value & (~0 << 28)) == 0) {
            // size == 4
            UnsafeDirectBufferUtil.setInt(address(position), (((value & 0x7F) | 0x80) << 24)
                                                             | (((value >>> 7 & 0x7F) | 0x80) << 16)
                                                             | (((value >>> 14 & 0x7F) | 0x80) << 8) | (value >>> 21));
            position += 4;
        } else {
            // size == 5
            UnsafeDirectBufferUtil.setInt(address(position), (((value & 0x7F) | 0x80) << 24)
                                                             | (((value >>> 7 & 0x7F) | 0x80) << 16)
                                                             | (((value >>> 14 & 0x7F) | 0x80) << 8)
                                                             | ((value >>> 21 & 0x7F) | 0x80));
            position += 4;
            UnsafeDirectBufferUtil.setByte(address(position++), (byte) (value >>> 28));
        }
        BufferUtils.position(nioBuffer, position);
    }
Start address of the memory buffer The memory buffer should be non-movable, which normally means that is is allocated
off-heap
jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/serialization/impl/protostuff/io/UnsafeNioBufOutput.java