1.Bloom Filter 默认的
BloomFilter filter =new BloomFilter(10,2,1); // 过滤器长度为10 ,用2哈希函数,MURMUR_HASH (1)
Key key =new Key("hadoop".getBytes()); filter.add(key); Key hb = new Key("hbase".getBytes()); boolean has =filter.membershipTest(key); System.out.println(has); System.out.println(filter.membershipTest(hb));2 CountingBloomFilter 可以增加删除key
CountingBloomFilter filter =new CountingBloomFilter(10,2,1); // 过滤器长度为10 ,用2哈希函数,MURMUR_HASH (1)
Key key =new Key("hadoop".getBytes()); filter.add(key); Key hb = new Key("hbase".getBytes()); boolean has =filter.membershipTest(key); System.out.println(has); System.out.println(filter.membershipTest(hb));3 .DynamicBloomFilter 过滤器长度可以扩容。
DynamicBloomFilter filter =new DynamicBloomFilter(10,2,1,0); 0 表示不扩容。 10 ,表示 默认长度为为10 ;2 两个hash函数。1 表示MURMUR_HASH (1)
Key key =new Key("hadoop".getBytes()); filter.add(key); Key hb = new Key("hbase".getBytes()); boolean has =filter.membershipTest(key); System.out.println(has); System.out.println(filter.membershipTest(hb));