doc: 阅读redis cuckoo filter文档
This commit is contained in:
@@ -141,6 +141,8 @@
|
||||
- [Reserving Bloom filters](#reserving-bloom-filters)
|
||||
- [total size of bloom filter](#total-size-of-bloom-filter)
|
||||
- [Performance](#performance)
|
||||
- [Cuckoo filter](#cuckoo-filter)
|
||||
- [User Cases](#user-cases)
|
||||
|
||||
|
||||
# redis
|
||||
@@ -2419,3 +2421,16 @@ memory_with_sets = capacity*(192b + value)
|
||||
|
||||
对bloom filter执行存在性检查的时间复杂度为`O(K)`或`O(K*n)`(针对stacked filters场景),`n`为stacked filters的数量
|
||||
|
||||
#### Cuckoo filter
|
||||
Cuckoo filter和Bloom filter类似,同样用于检测item在set中是否存在,其也提供了`a very fast and space efficient way`。除此之外,Cuckoo filter允许对item进行删除,且在部分场景下相比Bloom filter而言Cuckoo filter的性能要更好。
|
||||
|
||||
Bloom filter和Cuckoo filter的实现逻辑如下:
|
||||
- Bloom filter是一个bit array,在`hash function决定的位置bit将会被置为1`。
|
||||
- 而Cuckoo filter则是一个bucket array,`storing the fingerprints of the values in one of the buckets at positions decided by the two hash function`。
|
||||
- 通过两个hash function,能够计算出两个可能的bucket position,而item的fingerprint则存储在两个bucket的其中一个
|
||||
- 对于item x的membership query会针对x的fingerprint查找possible bucket,并且在查询到对应的fingerprint时返回true
|
||||
- 对于Cuckoo filter,其`fingerprint size`会决定其false positive rate
|
||||
|
||||
##### User Cases
|
||||
在应用中,Cuckoo filter拥有如下使用示例:
|
||||
- `Targeted ad campaigns`: 在该场景下,Cuckoo filter主要用于处理`用户是否参与了指定活动`
|
||||
|
||||
Reference in New Issue
Block a user