public static int computeFoldableByteSize(long bitSize, int foldFactor) {
    long byteSizeLong = (bitSize + 7) / 8;
    int mask = (1 << foldFactor) - 1;
    if ((mask & byteSizeLong) != 0) {
      byteSizeLong >>= foldFactor;
      ++byteSizeLong;
      byteSizeLong <<= foldFactor;
    }
    if (byteSizeLong > Integer.MAX_VALUE) {
      throw new IllegalArgumentException("byteSize=" + byteSizeLong + " too " + "large for bitSize="
        + bitSize + ", foldFactor=" + foldFactor);
    }
    return (int) byteSizeLong;
  }
Increases the given byte size of a Bloom filter until it can be folded by the given factor.
@return Foldable byte size
hbase-server/src/main/java/org/apache/hadoop/hbase/util/BloomFilterUtil.java