Bloom Filter 小记

The Bloom filter principle: Wherever a list or set is used, and space is at a premium, consider using a Bloom filter if the effect of false positives can be mitigated.

   第一次听说Bloom filter的时候是讨论班上谢师姐的一个报告,当时觉得这玩意挺扯淡的,hash来hash去的也没有什么意思。后来直到自己也面临这个问题,在一个大数据集合中相当频繁的查找数据,数据集越大,访问代价和内存消耗就越大,大到非但老板,连自己都不能忍受。于是才又想起这个神奇的名字。这些天来细细琢磨,Bloom Filter的那些事儿

Bloom Filter是一种空间利用率很高的数据结构,有点类似位图。它被用来检测一个元素是否存在于一个特定的集合中,它的基本思想是:

  •    一个空的Bloom filter是一个长为m的位数组。
  •     除了位数组外,还有k个不同的hash函数,每个hash函数都能够将元素映射到位数组中的一个位上。
    • 针对每一个元素,将其hash K次得到位置 P1,P2,P3……Pn 。
    • 在插入时,将为数组中下标为Pi的位置为1
  • 在查询时,测试下标为P1,P2,P3……Pn 的位,如果这些位都为1,则认为该元素存在于集合中。

 其实Bloom Filter 是一个很古老的算法,允许在有限的内存里(你想在这块内存里存放关键字的完整列表),执行成员测试,用以避免使用磁盘或数据库惊醒查询的性能瓶颈。但是空间的节省并不是没有代价的,存在着可大可小的假命中风险,并且增加了一定的key和filter之后,就很难删除它。并却需要小心的配置其使用的hash函数,使其分布在具体的已经分配好的向量空间。

 

 

参考
· Bloom Filters -- the math. A good place to start for an overview of the math behind Bloom filters. 
· Some Motley Bloom Tricks. Handy filter tricks and theory page. 
· Bloom Filter Survey. A handy survey article on Bloom filter network applications. 
· LOAF. Our own system for incorporating social networks onto email using Bloom filters. 
· Compressed Bloom Filters. If you are passing filters around a network, you will want to optimize them for minimum size; this paper gives a good overview of compressed Bloom filters. 
· Bloom16. A CPAN module implementing a counting Bloom filter. 
· Text::Bloom. CPAN module for using Bloom filters with text collections. 
· Privacy-Enhanced Searches Using Encryted Bloom Filters. This paper discusses how to use encryption and Bloom filters to set up a query system that prevents the search engine from knowing the query you are running. 
· Bloom Filters as Summaries. Some performance data on actually using Bloom filters as cache summaries. 
·Using Bloom Filters for Authenticated Yes/No Answers in the DNS. Internet draft for using Bloom filters to implement Secure DNS

和仙子翻译的使用Bloom Filters

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值