@Test public void testBloomNumHashFunctions() { assertEquals(1, BloomKFilter.optimalNumOfHashFunctions(-1, -1)); assertEquals(1, BloomKFilter.optimalNumOfHashFunctions(0, 0)); assertEquals(1, BloomKFilter.optimalNumOfHashFunctions(10, 0)); assertEquals(1, BloomKFilter.optimalNumOfHashFunctions(10, 10)); assertEquals(7, BloomKFilter.optimalNumOfHashFunctions(10, 100)); assertEquals(1, BloomKFilter.optimalNumOfHashFunctions(100, 100)); assertEquals(1, BloomKFilter.optimalNumOfHashFunctions(1000, 100)); assertEquals(1, BloomKFilter.optimalNumOfHashFunctions(10000, 100)); assertEquals(1, BloomKFilter.optimalNumOfHashFunctions(100000, 100)); assertEquals(1, BloomKFilter.optimalNumOfHashFunctions(1000000, 100)); }
static int optimalNumOfHashFunctions(long n, long m) { return Math.max(1, (int) Math.round((double) m / n * Math.log(2))); }
BloomKFilter { static int optimalNumOfHashFunctions(long n, long m) { return Math.max(1, (int) Math.round((double) m / n * Math.log(2))); } }
BloomKFilter { static int optimalNumOfHashFunctions(long n, long m) { return Math.max(1, (int) Math.round((double) m / n * Math.log(2))); } BloomKFilter(long maxNumEntries);  BloomKFilter(long maxNumEntries, double fpp);  BloomKFilter(List<Long> serializedBloom); }
BloomKFilter { static int optimalNumOfHashFunctions(long n, long m) { return Math.max(1, (int) Math.round((double) m / n * Math.log(2))); } BloomKFilter(long maxNumEntries);  BloomKFilter(long maxNumEntries, double fpp);  BloomKFilter(List<Long> serializedBloom); long sizeInBytes(); void add(byte[] val); void addBytes(byte[] val); void addString(String val); void addByte(byte val); void addInt(int val); void addLong(long val); void addFloat(float val); void addDouble(double val); boolean test(byte[] val); boolean testBytes(byte[] val); boolean testString(String val); boolean testByte(byte val); boolean testInt(int val); boolean testLong(long val); boolean testFloat(float val); boolean testDouble(double val); long getBitSize(); int getNumHashFunctions(); double getFalsePositivePercent(); long getExpectedNumEntries(); List<Long> serialize(); boolean isCompatible(BloomKFilter that); void merge(BloomKFilter that); long getNumBits(); long[] getBitSet(); }
BloomKFilter { static int optimalNumOfHashFunctions(long n, long m) { return Math.max(1, (int) Math.round((double) m / n * Math.log(2))); } BloomKFilter(long maxNumEntries);  BloomKFilter(long maxNumEntries, double fpp);  BloomKFilter(List<Long> serializedBloom); long sizeInBytes(); void add(byte[] val); void addBytes(byte[] val); void addString(String val); void addByte(byte val); void addInt(int val); void addLong(long val); void addFloat(float val); void addDouble(double val); boolean test(byte[] val); boolean testBytes(byte[] val); boolean testString(String val); boolean testByte(byte val); boolean testInt(int val); boolean testLong(long val); boolean testFloat(float val); boolean testDouble(double val); long getBitSize(); int getNumHashFunctions(); double getFalsePositivePercent(); long getExpectedNumEntries(); List<Long> serialize(); boolean isCompatible(BloomKFilter that); void merge(BloomKFilter that); long getNumBits(); long[] getBitSet();  }