Skip to content

Adding reserve as an alias for create, so that we have BF.RESERVE and CF.RESERVE accuratenly supported #2331

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

Merged
merged 2 commits into from
Aug 29, 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
4 changes: 4 additions & 0 deletions redis/commands/bf/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def create(self, key, errorRate, capacity, expansion=None, noScale=None):
self.append_no_scale(params, noScale)
return self.execute_command(BF_RESERVE, *params)

reserve = create

def add(self, key, item):
"""
Add to a Bloom Filter `key` an `item`.
Expand Down Expand Up @@ -178,6 +180,8 @@ def create(
self.append_max_iterations(params, max_iterations)
return self.execute_command(CF_RESERVE, *params)

reserve = create

def add(self, key, item):
"""
Add an `item` to a Cuckoo Filter `key`.
Expand Down
15 changes: 15 additions & 0 deletions tests/test_bloom.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ def test_create(client):
assert client.topk().reserve("topk", 5, 100, 5, 0.9)


@pytest.mark.redismod
def test_bf_reserve(client):
"""Testing BF.RESERVE"""
assert client.bf().reserve("bloom", 0.01, 1000)
assert client.bf().reserve("bloom_e", 0.01, 1000, expansion=1)
assert client.bf().reserve("bloom_ns", 0.01, 1000, noScale=True)
assert client.cf().reserve("cuckoo", 1000)
assert client.cf().reserve("cuckoo_e", 1000, expansion=1)
assert client.cf().reserve("cuckoo_bs", 1000, bucket_size=4)
assert client.cf().reserve("cuckoo_mi", 1000, max_iterations=10)
assert client.cms().initbydim("cmsDim", 100, 5)
assert client.cms().initbyprob("cmsProb", 0.01, 0.01)
assert client.topk().reserve("topk", 5, 100, 5, 0.9)


@pytest.mark.redismod
@pytest.mark.experimental
def test_tdigest_create(client):
Expand Down