Require: |
database of fingerprints binned by bit count Bs |
Ensure: |
hits contains top K hits which satisfy Similarity() > T
|
1: |
hits ← MinHeap() |
2: |
bounds ← List() |
3: |
for all B in database do //iterate over bins |
4: |
tuple ← Tuple(Bound(A,B),B) |
5: |
ListAppend(bounds, tuple) |
6: |
end for |
7: |
Quicksort(bounds) //NOTE: the length of bounds is constant |
8: |
for all bound, B in bounds do //iterate in order of decreasing bound
|
9: |
if bound < T then
|
10: |
break //threshold stopping condition |
11: |
end if
|
12: |
if K ≤ HeapSize(hits) and bound <MinSimilarity(hits) then
|
13: |
break //top-K stopping condition |
14: |
end if
|
15: |
for all in database[B] do
|
16: |
S=Similarity() |
17: |
tuple ← Tuple(S,) |
18: |
if S ≤ T then
|
19: |
continue //ignore this and continue to next |
20: |
else if Length(hits)< K then
|
21: |
HeapPush(hits, tuple) |
22: |
else if S > MinSimilarity(hits) then
|
23: |
HeapPopMin(hits) |
24: |
HeapPush(hits,tuple) |
25: |
end if
|
26: |
end for
|
27: |
end for |
28: |
return hits
|