-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBloomFilter.py
More file actions
59 lines (39 loc) · 1.3 KB
/
BloomFilter.py
File metadata and controls
59 lines (39 loc) · 1.3 KB
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
51
52
53
54
55
56
57
58
59
from bloom_filter import BloomFilter
'''
#Instantiate custom bloomfilter
bloom = BloomFilter(max_elements=500, error_rate=0.1)
#Test whether bloom-filter has seen a key
assert 'test-key' in bloom is False
#Mark the key as seen
bloom.add('test-key')
#check again
assert 'test-key' in bloom is True
'''
'''
filter = BloomFilter()
def generateFilter(inputData):
map = inputData in filter
print('this is the data to be converted into a bloomfilter'.format(inputData, map))
print('H3llo, {}'.format(inputData))
#iteratively populate bloomfilter
def addToFilter(inputData):
filter.add(inputData)
print('Format input data: ')
print(format(inputData))
print('')
for inputData in ['Hannah', 'Eric']:
generateFilter(inputData)
addToFilter(inputData)
'''
# In the paper, multi-sets are converted into sets
# single data set to be translated into bloom-filter, Sn denotes multiple sets
S = ['entry one', 'entry two', 'entry three', 'entry four', 'entry five', 'entry six']
# Instantiate bloom-filter, Ld denotes bloom-filters
L = BloomFilter(max_elements=1000, error_rate=0.01)
arr = []
# Populate Bloom-filter with data
for inputData in S:
filter.add(inputData)
map = inputData in filter
arr.append(map)
print(arr)