Search code examples
javaguavabloom-filter

guava bloom filter hight expected false positive percent after insertions


I tries to insert high number of longs to bloom filter and check them with low error. Constructor promise me expected percent for number of insertions, but after all inserts, new expected percent different and very high.

BloomFilter<Long> longBloomFilter = BloomFilter.create(Funnels.longFunnel(), 258112656, Math.pow(10, -8));
for (int i = 0; i < 258112656; i++) {
  longBloomFilter.put((long) i);
}
System.out.println(longBloomFilter.expectedFpp());

prints 0.17

I don't really trust, that bloom filter can give such great error rate, but why expectations before and after so different?


Solution

  • I strongly suspect you are using an outdated version of Guava. When I run your code with Guava 18.0, I get 1.001370499582369E-8, which is a perfectly reasonable output.