-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbloomfilter.py
More file actions
53 lines (43 loc) · 795 Bytes
/
bloomfilter.py
File metadata and controls
53 lines (43 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#1998,2001,2004,2007,2010,2013,
import sys
setIndex=[]
def bloomFilter(A):
A=A.split(',')
A=[ int(x) for x in A]
res={}
val=""
for i in A:
res[i]=bloomHash(i,0)
print res
def bloomHash(K,n):
print "K"+str(K)
global setIndex
m=32
haslist=[]
for ha in range(1,4):
biton=(((K**2+K**3)*ha)%32)
print "biton is " + str(biton)
if n==0:
setIndex.append(biton)
haslist.append(biton);
print haslist
return haslist
def checkFalsePositive():
print "ENTERED"
global setIndex
n=1987
while True:
a=bloomHash(n,1)
print a
if len(set(a) & set(setIndex)) == len(set(a)):
print set(a),set(setIndex)
print n
break
else:
n=n+1
bloomFilter(sys.argv[1])
print setIndex
print set(setIndex)
print len(set(setIndex))
print "*****"
checkFalsePositive()