pybloom is a module that includes a Bloom Filter data structure along with
an implmentation of Scalable Bloom Filters as discussed in:
P. Almeida, C.Baquero, N. Preguiça, D. Hutchison, Scalable Bloom Filters,
(GLOBECOM 2007), IEEE, 2007.
Bloom filters are great if you understand what amount of bits you need to set
aside early to store your entire set. Scalable Bloom Filters allow your bloom
filter bits to grow as a function of false positive probability and size.
A filter is "full" when at capacity: M * ((ln 2 ^ 2) / abs(ln p)), where M
is the number of bits and p is the false positive probability. When capacity
is reached a new filter is then created exponentially larger than the last
with a tighter probability of false positives and a larger number of hash
functions.
>>> from pybloom import BloomFilter
>>> f = BloomFilter(capacity=1000, error_rate=0.001)
>>> [f.add(x) for x in range(10)]
[False, False, False, False, False, False, False, False, False, False]
>>> all([(x in f) for x in range(10)])
True
>>> 10 in f
False
>>> 5 in f
True
>>> f = BloomFilter(capacity=1000, error_rate=0.001)
>>> for i in xrange(0, f.capacity):
... _ = f.add(i)
>>> abs((len(f) / float(f.capacity)) - 1.0) <= f.error_rate
True
>>> from pybloom import ScalableBloomFilter
>>> sbf = ScalableBloomFilter(mode=ScalableBloomFilter.SMALL_SET_GROWTH)
>>> count = 10000
>>> for i in xrange(0, count):
... _ = sbf.add(i)
...
>>> abs((len(sbf) / float(count)) - 1.0) <= sbf.error_rate
True
# len(sbf) may not equal the entire input length. 0.006% error is well
# below the default 0.1% error threshold
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
pybloom-python3.5.zip (33个子文件)
pybloom-python3.5
MANIFEST.in 20B
PKG-INFO 912B
README.txt 2KB
pybloom.egg-info
PKG-INFO 913B
requires.txt 16B
SOURCES.txt 289B
top_level.txt 8B
dependency_links.txt 1B
zip-safe 1B
ez_setup.py 9KB
.git
hooks
pre-push.sample 1KB
prepare-commit-msg.sample 1KB
applypatch-msg.sample 478B
pre-commit.sample 2KB
pre-applypatch.sample 424B
commit-msg.sample 896B
pre-rebase.sample 5KB
update.sample 4KB
post-update.sample 189B
config 263B
description 73B
refs
tags
heads
objects
info
pack
info
exclude 240B
HEAD 23B
FETCH_HEAD 0B
.DS_Store 6KB
setup.cfg 59B
setup.py 1KB
pybloom
pybloom.py 14KB
__pycache__
__init__.cpython-35.pyc 306B
pybloom.cpython-35.pyc 14KB
.DS_Store 8KB
__init__.py 116B
tests.py 3KB
共 33 条
- 1
资源评论
- GrowthDiary0072019-07-12可以使用,谢谢您
- qq_358039222019-08-19不错,可以使用,感谢!
- Chen-Lee2017-09-25非常不错!很好用
- OnlyKiyone2017-12-25非常不错。
- jjf0122017-03-18不错,python3.5可以使用。
面向未来的历史
- 粉丝: 96
- 资源: 14
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功