static BitSet randomBitSet(int size, int cardinality, Random rnd) {
        final BitSet result = new BitSet(size);
        final int[] chosen = new int[cardinality];
        int i;
        for (i = 0; i < cardinality; ++i) {
            chosen[i] = i;
            result.set(i);
        }
        for (; i < size; ++i) {
            final int j = rnd.nextInt(i + 1);
            if (j < cardinality) {
                result.clear(chosen[j]);
                result.set(i);
                chosen[j] = i;
            }
        }
        return result;
    }
Reservoir sampling algorithm borrowed from <a href=
"http://stackoverflow.com/questions/12817946/generate-a-random-bitset-with-n-1s">Stack Overflow</a>.
core/src/main/java/com/linecorp/armeria/common/util/CountingSampler.java