Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix name construction for all values of b #190

Merged
merged 2 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datasketch/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def __init__(self, cassandra_params, name, buffer_size):
# only one Cassandra table for both table types (so we can keep one single storage) and
# we specify different encoders/decoders based on the table type.
if b'bucket' in name:
basename, _, ret = name.split(b'_')
basename, _, ret = name.split(b'_', 2)
name = basename + b'_bucket_' + binascii.hexlify(ret)
self._key_decoder = lambda x: x
self._key_encoder = lambda x: x
Expand Down
10 changes: 10 additions & 0 deletions test/test_lsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ def test__H(self):
lsh.insert("m", m)
sizes = [len(H) for ht in lsh.hashtables for H in ht]
self.assertTrue(all(sizes[0] == s for s in sizes))

def test_unpacking(self):
for b in range(1, 1024 + 1):
lsh = MinHashLSH(num_perm=b * 4, params=(b, 4))
m = MinHash(num_perm=b * 4)
m.update("abcdefg".encode("utf8"))
m.update("1234567".encode("utf8"))
lsh.insert("m", m)
sizes = [len(H) for ht in lsh.hashtables for H in ht]
self.assertTrue(all(sizes[0] == s for s in sizes))

def test_insert(self):
lsh = MinHashLSH(threshold=0.5, num_perm=16)
Expand Down