Approximate membership query filters (hereafter, AMQ filters) comprise a group of space-efficient probabilistic data structures that support approximate membership queries. An approximate membership query answers whether an element is in a set or not with a false positive rate of ϵ. Bloom filters are the most known AMQ filter, but there are other AMQ filters that support additional operations or have different space requirements. AMQ filters have numerous applications, mainly in distributed systems and databases. There, they are often used to avoid network request or I/O operations that result from requesting elements that do not exist.
Approximate membership query problem The approximate membership query problem is to store information about a set of elements S in a space-efficient way. The goal is to answer queries about whether an element x is in the set S or not, while constraining false positives to a maximal probability ϵ. All AMQ filters support this lookup operation. Dynamic AMQ filters allow insertions at any time whereas static AMQ filters must be rebuilt after inserting additional elements. Some AMQ filters support additional operations such as deleting elements, or merging two filters.
Lookup An AMQ filter lookup will determine whether an element is definitely not in the set or probably in the set. In other words, if the filter represents a set S and we are interested in a value s, then the lookup function applied to s behaves as follows:
if s∈S: always returns true. if s∉S: returns false with probability 1−ϵ. A false positive is a lookup of an element that is not part of the set, but where the lookup returns true. The probability of this happening is the false positive rate ϵ. False negatives (the lookup returns false although the element is part of the set) are not allowed for AMQ filters.
Insertion After an element is inserted the lookup for this element must return true. Dynamic AMQ filters support inserting elements one at a time without rebuilding the data structure. Other AMQ filters have to be rebuilt after each insertion. Those are called static AMQ filters.
False positive rate vs. space There is a tradeoff between storage size and the false positive rate ϵ. Increasing the storage space reduces the false positive rate. The theoretical lower bound is log2(1/ϵ) bits for each element. Dynamic AMQ filters cannot reach this lower bound. They need at least nlog2(1/ϵ)(1+o(1)) bits for n insertions. Different AMQ filters have different ranges of false positive rates and space requirements. Choosing the best AMQ filter depends on the application.
Theoretical Results and Problem History AMQ filters were first introduced in 1970 by Bloom, who introduced the Bloom filter and proved that it use space ≈1.44nlog2ϵ−1 bits of space. In 1978, Carter proved that the optimal space for a static filter is between nlog2ϵ−1 and nlog2ϵ−1+o(n) bits, and introduced the algorithmic technique of building a filter by storing a collection of fingerprints (hashes of the keys) in a compact or succinct hash table. Such filters are sometimes referred to as fingerprint filters, and include modern practical constructions such as quotient filters and the cuckoo filters. In 2005, Pagh, Pagh, and Srinivasa showed how to build a constant-time fingerprint filter using space (1+o(1))nlog2ϵ−1+O(n) bits of space. In 2021, Bender, Farach-Colton, Kuszmaul, Kuszmaul, and Liu constructed a constant-time fingerprint filter using space nlog2ϵ−1+nlog2e+o(n) bits, so long as logϵ−1∈ω(1)∩O(logn/loglogn). This bound was subsequently shown to be information-theoretically optimal for any dynamic filter (any filter that supports insertions and deletions), regardless of time complexity. For filters that support insertions only, the information-theoretically optimal space bound has been shown to be nlog2ϵ−1+Θ(n) when ϵ=Θ(1), and nlog2ϵ−1+o(n) when ϵ=o(1). For static filters, where insertions/deletions are disallowed, there is a tradeoff between query time and space, with matching upper and lower bounds due to Hu et al. For filters that grow over time, with n defined to be the current number of keys at any given moment, the optimal space bound is nlog2ϵ−1+Θ(nloglogn) bits.
Data structures There are different ways to solve the approximate membership query problem. The most known data structure are Bloom filters, but there are other data structures that perform better for some false positive rates and space requirements, support additional operations, or have other insertion and lookup times. Below we describe some well known AMQ filters.
Bloom filter A Bloom filter is a bit array of m bits with k hash functions. Each hash function maps an element to one of the m positions in the array. In the beginning, all bits of the array are set to zero. To insert an element, all hash functions are calculated and all corresponding bits in the array are set to one. To lookup an element, all k hash functions are calculated. If all corresponding bits are set, true is returned. To reduce the false positive rate, the number of hash functions and m can be increased.
Quotient filter The idea of quotient filters is to hash an element and to split its fingerprint into the r least significant bits called the remainder dR and the most significant bits called the quotient dQ. The quotient determines where in the hash table the remainder is stored. An additional three bits for every slot in the hash table are used to resolve soft collisions (same quotient but different remainders).
Cuckoo filter Cuckoo filters are based on cuckoo hashing, but only fingerprints of the elements are stored in the hash table. Each element has two possible locations. The second location is calculated based on the first location and the fingerprint of the element. This is necessary to enable moving already inserted elements if both possible slots for an element are full. After reaching a load threshold the insertion speed of cuckoo filter degrades. It is possible that an insertion fails, and the table must be rehashed.
… excerpt ends here. Continue reading the full article.