【发布时间】:2015-11-17 03:47:00
【问题描述】:
我正在我的公司构建 Bloom 过滤器,需要将它们序列化并保存到 MongoDB 中。我目前使用的文档结构如下:
{
'_id': unique ID,
'm': number of bits in Bloom filter,
'n': capacity of Bloom filter,
'k': number of hashes,
'bitarray': a string of the Bloom filter’s bitarray,
'seeds': a list of seeds for the k hashes
}
如您所见,位数组当前表示为字符串,而布隆过滤器位数组可以得到 huge 以获得更大的容量。我数据库中的单个文档现在大约 5 兆字节,这太糟糕了。
如果它有帮助,我正在用 Python 编程并使用 PyMongo 作为适配器。
我当然认为这不是保存位数组的正确方法,而且我在 Internet 上的其他地方找不到帮助。请帮帮我。
【问题讨论】:
标签: python mongodb bitarray database