结果
/**
* @author WeiJiQian
* BF_CARDINAL_THRESHOLD BF_FALSE_POSITIVE_RATE 保存的数据量
* 100,0000 0.01 391万
* 1000,0000 0.01 3700万
* 1,0000,0000 0.01 total:3.677亿 去重后:3.05亿
*/
测试代码
final int BF_CARDINAL_THRESHOLD = 10000000;
final double BF_FALSE_POSITIVE_RATE = 0.01;
BloomFilter bloomFilter = BloomFilter.create(Funnels.unencodedCharsFunnel(), BF_CARDINAL_THRESHOLD,
BF_FALSE_POSITIVE_RATE);
long i =0;
long m = 0;
Long phoneNumber = 10000000000l;
while (true){
i++;
phoneNumber++;
if (!bloomFilter.mightContain(String.valueOf(phoneNumber))) {
bloomFilter.put(String.valueOf(phoneNumber));
m++;
}
if (i%10000 == 0){
// 1千次打印一次.
System.out.println("total:"+i);
System.out.println("去重后:"+m);
}
}
}