Skip to content

Mark TOPK.COUNT as deprecated #2363

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
Sep 4, 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
3 changes: 3 additions & 0 deletions redis/commands/bf/commands.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from deprecated import deprecated

from redis.client import NEVER_DECODE
from redis.exceptions import ModuleError
from redis.utils import HIREDIS_AVAILABLE
Expand Down Expand Up @@ -318,6 +320,7 @@ def query(self, key, *items):
""" # noqa
return self.execute_command(TOPK_QUERY, key, *items)

@deprecated(version="4.4.0", reason="deprecated since redisbloom 2.4.0")
def count(self, key, *items):
"""
Return count for one `item` or more from `key`.
Expand Down
14 changes: 8 additions & 6 deletions tests/test_asyncio/test_bloom.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,10 @@ async def test_topk(modclient: redis.Redis):
assert [1, 1, 0, 0, 1, 0, 0] == await modclient.topk().query(
"topk", "A", "B", "C", "D", "E", "F", "G"
)
assert [4, 3, 2, 3, 3, 0, 1] == await modclient.topk().count(
"topk", "A", "B", "C", "D", "E", "F", "G"
)
with pytest.deprecated_call():
assert [4, 3, 2, 3, 3, 0, 1] == await modclient.topk().count(
"topk", "A", "B", "C", "D", "E", "F", "G"
)

# test full list
assert await modclient.topk().reserve("topklist", 3, 50, 3, 0.9)
Expand Down Expand Up @@ -307,9 +308,10 @@ async def test_topk_incrby(modclient: redis.Redis):
)
res = await modclient.topk().incrby("topk", ["42", "xyzzy"], [8, 4])
assert [None, "bar"] == res
assert [3, 6, 10, 4, 0] == await modclient.topk().count(
"topk", "bar", "baz", "42", "xyzzy", 4
)
with pytest.deprecated_call():
assert [3, 6, 10, 4, 0] == await modclient.topk().count(
"topk", "bar", "baz", "42", "xyzzy", 4
)


# region Test T-Digest
Expand Down
14 changes: 8 additions & 6 deletions tests/test_bloom.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,10 @@ def test_topk(client):
assert [1, 1, 0, 0, 1, 0, 0] == client.topk().query(
"topk", "A", "B", "C", "D", "E", "F", "G"
)
assert [4, 3, 2, 3, 3, 0, 1] == client.topk().count(
"topk", "A", "B", "C", "D", "E", "F", "G"
)
with pytest.deprecated_call():
assert [4, 3, 2, 3, 3, 0, 1] == client.topk().count(
"topk", "A", "B", "C", "D", "E", "F", "G"
)

# test full list
assert client.topk().reserve("topklist", 3, 50, 3, 0.9)
Expand Down Expand Up @@ -307,9 +308,10 @@ def test_topk_incrby(client):
"topk", ["bar", "baz", "42"], [3, 6, 2]
)
assert [None, "bar"] == client.topk().incrby("topk", ["42", "xyzzy"], [8, 4])
assert [3, 6, 10, 4, 0] == client.topk().count(
"topk", "bar", "baz", "42", "xyzzy", 4
)
with pytest.deprecated_call():
assert [3, 6, 10, 4, 0] == client.topk().count(
"topk", "bar", "baz", "42", "xyzzy", 4
)


# region Test T-Digest
Expand Down