<s>
A	O
quotient	B-Algorithm
filter	I-Algorithm
is	O
a	O
space-efficient	O
probabilistic	O
data	B-General_Concept
structure	I-General_Concept
used	O
to	O
test	O
whether	O
an	O
element	O
is	O
a	O
member	O
of	O
a	O
set	O
(	O
an	O
approximate	O
membership	O
query	O
filter	O
,	O
AMQ	O
)	O
.	O
</s>
<s>
A	O
typical	O
application	O
for	O
quotient	B-Algorithm
filters	I-Algorithm
,	O
and	O
other	O
AMQ	O
filters	O
,	O
is	O
to	O
serve	O
as	O
a	O
proxy	O
for	O
the	O
keys	O
in	O
a	O
database	O
on	O
disk	O
.	O
</s>
<s>
Any	O
lookup	O
will	O
first	O
consult	O
the	O
fast	O
quotient	B-Algorithm
filter	I-Algorithm
,	O
then	O
look	O
in	O
the	O
(	O
presumably	O
much	O
slower	O
)	O
database	O
only	O
if	O
the	O
quotient	B-Algorithm
filter	I-Algorithm
reported	O
the	O
presence	O
of	O
the	O
key	O
.	O
</s>
<s>
A	O
quotient	B-Algorithm
filter	I-Algorithm
has	O
the	O
usual	O
AMQ	O
operations	O
of	O
insert	O
and	O
query	O
.	O
</s>
<s>
In	O
addition	O
it	O
can	O
also	O
be	O
merged	O
and	O
re-sized	O
without	O
having	O
to	O
re-hash	O
the	O
original	O
keys	O
(	O
thereby	O
avoiding	O
the	O
need	O
to	O
access	O
those	O
keys	O
from	O
secondary	O
storage	O
)	O
.	O
</s>
<s>
This	O
property	O
benefits	O
certain	O
kinds	O
of	O
log-structured	B-Data_Structure
merge-trees	I-Data_Structure
.	O
</s>
<s>
The	O
compact	O
hash	B-Algorithm
table	I-Algorithm
underlying	O
a	O
quotient	B-Algorithm
filter	I-Algorithm
was	O
described	O
by	O
Cleary	O
in	O
1984	O
.	O
</s>
<s>
In	O
2009	O
,	O
Dillinger	O
and	O
Manolios	O
optimized	O
the	O
structure	O
's	O
metadata	O
,	O
added	O
in-place	O
accommodation	O
of	O
more	O
elements	O
,	O
and	O
applied	O
the	O
structure	O
to	O
explicit-state	O
model	B-Application
checking	I-Application
.	O
</s>
<s>
penned	O
the	O
name	O
"	O
quotient	B-Algorithm
filter	I-Algorithm
"	O
,	O
described	O
several	O
variants	O
with	O
different	O
metadata	O
encoding	O
trade-offs	O
,	O
showed	O
how	O
to	O
merge	O
and	O
resize	O
quotient	B-Algorithm
filters	I-Algorithm
,	O
presented	O
a	O
write-optimized	O
version	O
of	O
the	O
quotient	B-Algorithm
filter	I-Algorithm
for	O
use	O
on	O
disk	O
,	O
and	O
applied	O
the	O
structure	O
to	O
database	O
storage	O
problems	O
.	O
</s>
<s>
The	O
quotient	B-Algorithm
filter	I-Algorithm
is	O
based	O
on	O
a	O
kind	O
of	O
hash	B-Algorithm
table	I-Algorithm
in	O
which	O
entries	O
contain	O
only	O
a	O
portion	O
of	O
the	O
key	O
plus	O
some	O
additional	O
meta-data	O
bits	O
.	O
</s>
<s>
These	O
bits	O
are	O
used	O
to	O
deal	O
with	O
the	O
case	O
when	O
distinct	O
keys	O
happen	O
to	O
hash	B-Error_Name
to	O
the	O
same	O
table	O
entry	O
.	O
</s>
<s>
By	O
way	O
of	O
contrast	O
,	O
other	O
types	O
of	O
hash	B-Algorithm
tables	I-Algorithm
that	O
deal	O
with	O
such	O
collisions	O
by	O
linking	O
to	O
overflow	O
areas	O
are	O
not	O
compact	O
because	O
the	O
overhead	O
due	O
to	O
linkage	O
can	O
exceed	O
the	O
storage	O
used	O
to	O
store	O
the	O
key	O
.	O
</s>
<s>
In	O
a	O
quotient	B-Algorithm
filter	I-Algorithm
a	O
hash	B-Error_Name
function	I-Error_Name
generates	O
a	O
p-bit	O
fingerprint	O
.	O
</s>
<s>
The	O
hash	B-Algorithm
table	I-Algorithm
has	O
2q	O
slots	O
.	O
</s>
<s>
For	O
some	O
key	O
d	O
which	O
hashes	B-Error_Name
to	O
the	O
fingerprint	O
dH	O
,	O
let	O
its	O
quotient	O
be	O
dQ	O
and	O
the	O
remainder	O
be	O
dR	O
.	O
</s>
<s>
However	O
the	O
canonical	O
slot	O
might	O
already	O
be	O
occupied	O
because	O
multiple	O
keys	O
can	O
hash	B-Error_Name
to	O
the	O
same	O
fingerprint	O
—	O
a	O
hard	O
collision	O
—	O
or	O
because	O
even	O
when	O
the	O
keys	O
 '	O
fingerprints	O
are	O
distinct	O
they	O
can	O
have	O
the	O
same	O
quotient	O
—	O
a	O
soft	O
collision	O
.	O
</s>
<s>
We	O
can	O
test	O
if	O
a	O
quotient	B-Algorithm
filter	I-Algorithm
contains	O
some	O
key	O
,	O
d	O
,	O
as	O
follows	O
.	O
</s>
<s>
We	O
hash	B-Error_Name
the	O
key	O
to	O
produce	O
its	O
fingerprint	O
,	O
dH	O
,	O
which	O
we	O
then	O
partition	O
into	O
its	O
high-order	O
q	O
bits	O
,	O
dQ	O
,	O
which	O
comprise	O
its	O
quotient	O
,	O
and	O
its	O
low-order	O
r	O
bits	O
,	O
dR	O
,	O
which	O
comprise	O
its	O
remainder	O
.	O
</s>
<s>
We	O
would	O
compute	O
hash(e )	O
,	O
partition	O
it	O
into	O
its	O
remainder	O
,	O
eR	O
and	O
its	O
quotient	O
eQ	O
,	O
which	O
is	O
4	O
.	O
</s>
<s>
The	O
figure	O
shows	O
a	O
quotient	B-Algorithm
filter	I-Algorithm
proceeding	O
through	O
a	O
series	O
of	O
states	O
as	O
elements	O
are	O
added	O
.	O
</s>
<s>
If	O
the	O
hash	B-Error_Name
function	I-Error_Name
generates	O
uniformly	O
distributed	O
fingerprints	O
then	O
the	O
length	O
of	O
most	O
runs	O
is	O
O(1 )	O
and	O
it	O
is	O
highly	O
likely	O
that	O
all	O
runs	O
have	O
length	O
O(log m )	O
where	O
m	O
is	O
the	O
number	O
of	O
slots	O
in	O
the	O
table	O
.	O
</s>
<s>
when	O
the	O
hash	B-Error_Name
of	O
two	O
keys	O
results	O
in	O
the	O
same	O
fingerprint	O
)	O
in	O
terms	O
of	O
the	O
hash	B-Algorithm
table	I-Algorithm
's	O
remainder	O
size	O
and	O
load	O
factor	O
.	O
</s>
<s>
Then	O
,	O
for	O
a	O
good	O
hash	B-Error_Name
function	I-Error_Name
,	O
is	O
approximately	O
the	O
probability	O
of	O
a	O
hard	O
collision	O
.	O
</s>
<s>
Pandey	O
's	O
version	O
of	O
the	O
quotient	B-Algorithm
filter	I-Algorithm
requires	O
less	O
space	O
than	O
a	O
comparable	O
Bloom	B-Algorithm
filter	I-Algorithm
when	O
the	O
target	O
false-positive	O
rate	O
is	O
less	O
than	O
1/64	O
.	O
</s>
<s>
Quotient	B-Algorithm
filters	I-Algorithm
are	O
AMQs	O
and	O
,	O
as	O
such	O
,	O
provide	O
many	O
of	O
the	O
same	O
benefits	O
as	O
Bloom	B-Algorithm
filters	I-Algorithm
.	O
</s>
<s>
Quotient	B-Algorithm
filters	I-Algorithm
offer	O
two	O
benefits	O
in	O
some	O
applications	O
.	O
</s>
<s>
Two	O
quotient	B-Algorithm
filters	I-Algorithm
can	O
be	O
efficiently	O
merged	O
without	O
affecting	O
their	O
false	O
positive	O
rates	O
.	O
</s>
<s>
This	O
is	O
not	O
possible	O
with	O
Bloom	B-Algorithm
filters	I-Algorithm
.	O
</s>
<s>
The	O
space	O
used	O
by	O
quotient	B-Algorithm
filters	I-Algorithm
is	O
comparable	O
to	O
that	O
of	O
Bloom	B-Algorithm
filters	I-Algorithm
.	O
</s>
<s>
However	O
quotient	B-Algorithm
filters	I-Algorithm
can	O
be	O
efficiently	O
merged	O
within	O
memory	O
without	O
having	O
to	O
re-insert	O
the	O
original	O
keys	O
.	O
</s>
<s>
This	O
is	O
particularly	O
important	O
in	O
some	O
log	O
structured	O
storage	O
systems	O
that	O
use	O
the	O
log-structured	B-Data_Structure
merge-tree	I-Data_Structure
or	O
LSM-tree	B-Data_Structure
.	O
</s>
<s>
The	O
LSM-tree	B-Data_Structure
is	O
actually	O
a	O
collection	O
of	O
trees	O
but	O
which	O
is	O
treated	O
as	O
a	O
single	O
key-value	O
store	O
.	O
</s>
<s>
One	O
variation	O
of	O
the	O
LSM-Tree	B-Data_Structure
is	O
the	O
Sorted	O
Array	O
Merge	O
Tree	O
or	O
SAMT	O
.	O
</s>
<s>
Each	O
Wanna-B-tree	O
has	O
an	O
associated	O
quotient	B-Algorithm
filter	I-Algorithm
.	O
</s>
<s>
A	O
query	O
on	O
the	O
SAMT	O
is	O
directed	O
at	O
only	O
select	O
Wanna-B-trees	O
as	O
evidenced	O
by	O
their	O
quotient	B-Algorithm
filters	I-Algorithm
.	O
</s>
<s>
The	O
storage	O
system	O
in	O
its	O
normal	O
operation	O
compacts	O
the	O
SAMT	O
's	O
Wanna-B-trees	O
,	O
merging	O
smaller	O
Wanna-B-trees	O
into	O
larger	O
ones	O
and	O
merging	O
their	O
quotient	B-Algorithm
filters	I-Algorithm
.	O
</s>
<s>
An	O
essential	O
property	O
of	O
quotient	B-Algorithm
filters	I-Algorithm
is	O
that	O
they	O
can	O
be	O
efficiently	O
merged	O
without	O
having	O
to	O
re-insert	O
the	O
original	O
keys	O
.	O
</s>
<s>
By	O
construction	O
the	O
values	O
in	O
a	O
quotient	B-Algorithm
filter	I-Algorithm
are	O
stored	O
in	O
sorted	O
order	O
.	O
</s>
<s>
Merging	O
two	O
quotient	B-Algorithm
filters	I-Algorithm
is	O
then	O
a	O
simple	O
matter	O
of	O
converting	O
each	O
quotient	B-Algorithm
filter	I-Algorithm
into	O
such	O
a	O
list	O
,	O
merging	O
the	O
two	O
lists	O
and	O
using	O
it	O
to	O
populate	O
a	O
new	O
larger	O
quotient	B-Algorithm
filter	I-Algorithm
.	O
</s>
<s>
Similarly	O
,	O
we	O
can	O
halve	O
or	O
double	O
the	O
size	O
of	O
a	O
quotient	B-Algorithm
filter	I-Algorithm
without	O
rehashing	O
the	O
keys	O
since	O
the	O
fingerprints	O
can	O
be	O
recomputed	O
using	O
just	O
the	O
quotients	O
and	O
remainders	O
.	O
</s>
