public static void writeVarInt(OutputStream output, long value) throws IOException {
        // https://github.com/ClickHouse/ClickHouse/blob/abe314feecd1647d7c2b952a25da7abf5c19f352/src/IO/VarInt.h#L187
        for (int i = 0; i < 9; i++) {
            byte b = (byte) (value & 0x7F);

            if (value > 0x7F) {
                b |= 0x80;
            }

            value >>= 7;
            output.write(b);

            if (value == 0) {
                return;
            }
        }
    }
Writes varint to given output stream.

@param output non-null output stream
@param value  long value
@throws IOException when failed to write value to output stream or reached
                    end of the stream
clickhouse-data/src/main/java/com/clickhouse/data/ClickHouseByteUtils.java