Skip to content

Commit 37aa2af

Browse files
committed
fixed a bug where we couldn't run all 8 loops
1 parent 48dde3e commit 37aa2af

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

HyperLogLogEstimator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ def HyperLogLog(hashes, off, k):
1313
#loop through all hashes
1414
for hash in hashes:
1515
#encode the hash in binary
16-
hash = bin(int(hash, 16))
17-
18-
temp = hash[len(hash)-(32+off):len(hash)-off]
16+
hash = '{:256b}'.format(int(hash, 16)).replace(' ','0')
17+
18+
temp = hash[len(hash)-(32+off)+1:len(hash)-off]
1919

2020
#get bucket{j} of the hash (first k bits)
2121
j = temp[:k]

LogLogEstimator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ def LogLog(hashes, off, k):
1313
#loop through all hashes
1414
for hash in hashes:
1515
#encode the hash in binary
16-
hash = bin(int(hash, 16))
17-
18-
temp = hash[len(hash)-(32+off):len(hash)-off]
16+
hash = '{:256b}'.format(int(hash, 16)).replace(' ','0')
17+
18+
temp = hash[len(hash)-(32+off)+1:len(hash)-off]
1919

2020
#get bucket{j} of the hash (first k bits)
2121
j = temp[:k]

SuperLogLogEstimator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ def SuperLogLog(hashes, off, k):
1313
#loop through all hashes
1414
for hash in hashes:
1515
#encode the hash in binary
16-
hash = bin(int(hash, 16))
17-
18-
temp = hash[len(hash)-(32+off):len(hash)-off]
16+
hash = '{:256b}'.format(int(hash, 16)).replace(' ','0')
17+
18+
temp = hash[len(hash)-(32+off)+1:len(hash)-off]
1919

2020
#get bucket{j} of the hash (first k bits)
2121
j = temp[:k]

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
ex_buckets = 8
1414

1515
# number of runs to average with different hashes
16-
loops_to_run = 1
16+
loops_to_run = 8
1717

1818
print ("LogLog, SuperLogLog, and HyperLogLog Demo")
1919
print ("by Dawsin Blanchard, Sam Braga, Brian Couture, and Ethan Trott\n")

0 commit comments

Comments
 (0)