DataStructure.BloomFilter

Bloom Filters Ref[1]

1. 简介

Bloom filter(布隆过滤器;有更好的或正确的翻译,告诉我) 是一个数据结构,该数据结构快速并且内存高效,它可以告诉你某个元素是否在集合中。

作为高效的代价,Bloom filter是存在概率的数据结构:它告诉我们某个元素一定不在集合中,或者可能在集合中。

Bloom filter的基本数据结构是Bit Vector。

在Ref[1]中有简单形象的例子来说明Bloom Filter。

1.1 Hash Functions

在Bloom Filter中的hash function应该是独立的并且是均匀分布的。应该选用尽可能快的hash function。(sha1虽然被广泛使用,

但是在Bloom Filter的实现中并不是好的选择)。

hash function有:murmur, fnv, Jenkins Hashes。

1.2 How big should I make my Bloom filter?

false positive rate: (1-e-kn/m)k

false positive rate: 是指假肯定率(Q[1]: false positive rate 是指???)

k: hash function的个数

m: filter中的bits数

n: 已经被插入到filter里的元素个数

1.3 应该使用多少hash function?

hash function越多,bloom filter越慢,bloom filter就越容易被填满。如果hash function太少,就会得到太多的假肯定(false positive)。

由于在创建filter时必须为k选择一个值,你需要对n的变动范围进行界定。一旦范围确定了,仍然需要选择一个潜在的m和k。

幸运地,给定m和n,我们有一个函数来选择k的最佳值:(m/n)ln(2)

接下来选定bloom filter的尺寸/大小:

  1. 选择一个n的范围值

  2. 为m选择一个值

  3. 计算k的最佳值

  4. 根据n,m,k来计算error rate。如果该值不可接受,需要返回第二步并修改m的值。

1.4 How fast and space efficient is a Bloom filter?

一个给定有m个bits和k个hash function的Bloom filter,插入和成员身份的测试是O(k)

2. Bloom Filter的应用案例

[Todo]



Reference

1. Bloom Filters by Example

http://billmill.org/bloomfilter-tutorial/

1.1 http://blip.tv/pycon-us-videos-2009-2010-2011/pycon-2011-handling-ridiculous-amounts-of-data-with-probabilistic-data-structures-4899047

1.2 Network Application of Bloom Filter: A Survey

http://citeseer.ist.psu.edu/viewdoc/download;jsessionid=6CA79DD1A90B3EFD3D62ACE5523B99E7?doi=10.1.1.127.9672&rep=rep1&type=pdf

1.3 Less Hashing, Same Performance

http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.152.579&rank=1

1.4 Scalable Bloom Filters [AAAA]

http://gsd.di.uminho.pt/members/cbm/ps/dbloom.pdf

1.5

https://sites.google.com/site/murmurhash/

1.6

http://isthe.com/chongo/tech/comp/fnv/

1.7

http://www.burtleburtle.net/bob/hash/doobs.html

2. Bloom Filter  [AAAAA]

http://en.wikipedia.org/wiki/Bloom_filter

时间: 2024-07-30 11:09:32

DataStructure.BloomFilter的相关文章

网络爬虫:URL去重策略之布隆过滤器(BloomFilter)的使用

前言: 最近被网络爬虫中的去重策略所困扰.使用一些其他的"理想"的去重策略,不过在运行过程中总是会不太听话.不过当我发现了BloomFilter这个东西的时候,的确,这里是我目前找到的最靠谱的一种方法. 如果,你说URL去重嘛,有什么难的.那么你可以看完下面的一些问题再说这句话. 关于BloomFilter: Bloom filter 是由 Howard Bloom 在 1970 年提出的二进制向量数据结构,它具有很好的空间和时间效率,被用来检测一个元素是不是集合中的一个成员.如果检测

【DataStructure】Description and Introduction of Tree

[Description] At ree is a nonlinear data structure that models a hierarchical organization. The characteristic eatures are that each element may have several successors (called its "children") and every element except one (called the "root&

【DataStructure】Description and usage of queue

[Description] A queue is a collection that implements the first-in-first-out protocal. This means that the only accessiable object in the collection in the first one that was inserted. The most common example of a queue is a waiting line. [Interface]

【DataStructure】One of queue usage: Simulation System

Statements: This blog was written by me, but most of content  is quoted from book[Data Structure with Java Hubbard] [Description] This simulationillustrates objectoriented programming(OOP). Java objects are instantiated to represent all the interacti

[DataStructure]稀疏矩阵的三元组存储及乘法运算

P.S.我去..我大作业不会打成系数矩阵了吧!!!!!!!!!!! 一.题目描述: 对于一个Rows X Columns稀疏矩阵,使用三元组的方法进行存储. 并在此基础上计算矩阵的乘法 二.解题报告 1.建立结构_Matrix 1 MAXVALUE为预估零元峰值个数, 2 struct _Matrix 3 { 4 int Sum;//实际输入总非零点数 5 int Rows,Columns;//矩阵行数,列数 6 double Data[MAXVALUE+1];//数据域,第i个数据的值 7 i

HBase之BloomFilter

HBase的Get/Scan操作流程 hbase中有BloomFilter的功能,可以在有些情况下过滤掉不需要的hfile,节省IO. BloomFilter作用 BloomFilter在HBase中的作用? HBase**利用BloomFilter来提高随机读**(Get)的性能,对于顺序(Scan)而言,设置Bloomfilter是没有作用的(0.92以后,如果设置了bloomfilter为ROWCOL,对于指定了qualiter的Scan有一定的优化). BloomFilter在HBase

【DataStructure】Implemantation of Binary Tree

Statements: This blog was written by me, but most of content  is quoted from book[Data Structure with Java Hubbard] Here is a class for binary trees that directly implements the recursive definition. By extending the AbstractCollectionclass, it remai

【DataStructure】Another usage of List: Polynomial

Statements: This blog was written by me, but most of content  is quoted from book[Data Structure with Java Hubbard] [Description] Apolynomialis a mathematical function of the form: p(x) = a0xn+ a1xn–1+a2xn–2+ ???+an–1x + an The greatest exponent, 

第三百五十八节,Python分布式爬虫打造搜索引擎Scrapy精讲—将bloomfilter(布隆过滤器)集成到scrapy-redis中

第三百五十八节,Python分布式爬虫打造搜索引擎Scrapy精讲-将bloomfilter(布隆过滤器)集成到scrapy-redis中,判断URL是否重复 布隆过滤器(Bloom Filter)详解 基本概念 如果想判断一个元素是不是在一个集合里,一般想到的是将所有元素保存起来,然后通过比较确定.链表,树等等数据结构都是这种思路. 但是随着集合中元素的增加,我们需要的存储空间越来越大,检索速度也越来越慢.不过世界上还有一种叫作散列表(又叫哈希表,Hash table)的数据结构.它可以通过一