Filter bloom = BloomFactory.NewBloomInstance( numElems, pct);
for( int i = 0; i< numElems; ++i ) {
UUID uuid = UUID.randomUUID();
Key key = new Key(uuid.toString().getBytes() );
bloom.add( key );
Assert.assertTrue( bloom.membershipTest(key));
if( (i % 10000) == 0 ) {
System.out.println(" Added " + i + " elements.");
}
}
int numHits = 0;
for( int i=0; i< numElems; ++i) {
UUID uuid = UUID.randomUUID();
Key key = new Key(uuid.toString().getBytes() );
if( bloom.membershipTest(key)) {
numHits++;
}
}
System.out.print("Number of hits = " + numHits + " out of " + numElems + " or " + ((double)numHits/(double)numElems)*100.0 + " %");