long generateRandomLongWithExactBytesSet(int bytesSet) {
            long lowerBound = 1L << ((bytesSet - 1) * 8);
            long upperBound = (1L << (bytesSet * 8)) - 1;
            if (lowerBound >= upperBound) {
                throw new IllegalArgumentException();
            }
            return lowerBound +
                random.longs(lowerBound, upperBound).findFirst()
                    .orElseThrow(() -> new IllegalStateException("Unable to create a random long in the range=[" + lowerBound + ", " + upperBound + "]"));
        }
Generates a random int64 number which occupies exactly bytesSet in the variable length encoding for int64

Upper bound is set by finding the largest number that can be represented by N bits. This number is found
by bit shifting by N and subtracting decimal 1. For example, for 2 bytes = 16 bits, we calculate the
upper bound by:
1. 0001 0000 0000 0000 0000 // bit shift by 16 = 65536 decimal
2. Subtract 1 from 65536 = 65535
3. 65535 is the upper bound which is represented in binary as 1111 1111 1111 1111 i.e. largest number
   that could be represented by 2 bytes.

Hence, range of random number of different byte length is:
1 byte - [1, 255)
2 byte - [256, 65535)
... and so on.
jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java