I'd like to implement a bloom filter using MySQL (other a suggested alternative).我想实现一个布隆过滤器使用MySQL(另外一个建议的替代)。
The problem is as follows:问题是如下:
Suppose I have a table that stores 8 bit integers, with these following values:假设我有一个表,用于存储8位整数,以下值:
1: 10011010 2: 00110101 3: 10010100 4: 00100110 5: 00111011 6: 01101010
I'd like to find all results that are bitwise AND to this:我想找到的所有结果按位与此:
00011000
The results should be rows 1 and 5.结果应该是1行和第5行。
However, in my problem, they aren't 8 bit integers, but rather n-bit integers.然而,在我的问题,他们是不是8位整数,而是n位整数。 How do I store this, and how do I query?我如何保存这一点,我怎么查询呢? Speed is key.速度是关键。
Create a table with int field for value, no need to store numbers as sequence of 0 and 1.创建一个表整型字段值,没有必要存储0和1的序列号。 For you data it will look like this:你的数据,它看起来像这样:
and you need to find all entries matching 24.你需要找到所有的匹配项24。
Then you can run a query like然后,您可以执行这样的查询
If you want to avoid convertion into 10 base numbers in your application you can hand it over to mysql:如果你想避免皈依为10个基数,在您的应用程序,你可以把它交给到MySQL:
and search like this和搜索这样的