@Test public void testBloomNumHashFunctions() { assertEquals(1, Bloom1Filter.optimalNumOfHashFunctions(-1, -1)); assertEquals(1, Bloom1Filter.optimalNumOfHashFunctions(0, 0)); assertEquals(1, Bloom1Filter.optimalNumOfHashFunctions(10, 0)); assertEquals(1, Bloom1Filter.optimalNumOfHashFunctions(10, 10)); assertEquals(7, Bloom1Filter.optimalNumOfHashFunctions(10, 100)); assertEquals(1, Bloom1Filter.optimalNumOfHashFunctions(100, 100)); assertEquals(1, Bloom1Filter.optimalNumOfHashFunctions(1000, 100)); assertEquals(1, Bloom1Filter.optimalNumOfHashFunctions(10000, 100)); assertEquals(1, Bloom1Filter.optimalNumOfHashFunctions(100000, 100)); assertEquals(1, Bloom1Filter.optimalNumOfHashFunctions(1000000, 100)); }
static int optimalNumOfHashFunctions(long n, long m) { return Math.max(1, (int) Math.round((double) m / n * Math.log(2))); }
Bloom1Filter { static int optimalNumOfHashFunctions(long n, long m) { return Math.max(1, (int) Math.round((double) m / n * Math.log(2))); } }
Bloom1Filter { static int optimalNumOfHashFunctions(long n, long m) { return Math.max(1, (int) Math.round((double) m / n * Math.log(2))); } Bloom1Filter(long maxNumEntries);  Bloom1Filter(long maxNumEntries, double fpp);  Bloom1Filter(List<Long> serializedBloom); }
Bloom1Filter { static int optimalNumOfHashFunctions(long n, long m) { return Math.max(1, (int) Math.round((double) m / n * Math.log(2))); } Bloom1Filter(long maxNumEntries);  Bloom1Filter(long maxNumEntries, double fpp);  Bloom1Filter(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(Bloom1Filter that); void merge(Bloom1Filter that); }
Bloom1Filter { static int optimalNumOfHashFunctions(long n, long m) { return Math.max(1, (int) Math.round((double) m / n * Math.log(2))); } Bloom1Filter(long maxNumEntries);  Bloom1Filter(long maxNumEntries, double fpp);  Bloom1Filter(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(Bloom1Filter that); void merge(Bloom1Filter that);  }