(long[] keys, double bitsPerKey)
| 7 | public class Bloom { |
| 8 | |
| 9 | public static Bloom construct(long[] keys, double bitsPerKey) { |
| 10 | long n = keys.length; |
| 11 | int k = getBestK(bitsPerKey); |
| 12 | Bloom f = new Bloom((int) n, bitsPerKey, k); |
| 13 | for(long x : keys) { |
| 14 | f.add(x); |
| 15 | } |
| 16 | return f; |
| 17 | } |
| 18 | |
| 19 | private static int getBestK(double bitsPerKey) { |
| 20 | return Math.max(1, (int) Math.round(bitsPerKey * Math.log(2))); |