Skip to content

Python: add BZPOPMIN and BZPOPMAX commands#1399

Merged
acarbonetto merged 4 commits intovalkey-io:mainfrom
Bit-Quill:python/integ_acongo_bzpopmax
May 14, 2024
Merged

Python: add BZPOPMIN and BZPOPMAX commands#1399
acarbonetto merged 4 commits intovalkey-io:mainfrom
Bit-Quill:python/integ_acongo_bzpopmax

Conversation

@aaron-congo
Copy link
Copy Markdown
Contributor

Issue #, if available:
N/A

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@aaron-congo aaron-congo requested a review from a team as a code owner May 9, 2024 23:08
@aaron-congo aaron-congo added the python 🐍 Python wrapper label May 9, 2024
Lolwut,
ArrayOfArraysOfDoubleOrNull,
ArrayOfKeyValuePairs,
KeyWithMemberAndScore,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come this wasn't included in the Java implementation?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ig it was forgotten, good catch:)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah its because the conversion is needed for RESP2 responses. The Java wrapper doesn't support RESP2 yet but Python does

if array.len() == 3
&& matches!(array[2], Value::BulkString(_) | Value::SimpleString(_)) =>
{
array[2] =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this only convert the third argument to double? Can there be more arguments with more keys where the timeout is greater than the third argument?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redis> ZADD zset1 0 a 1 b 2 c
(integer) 3
redis> BZPOPMIN zset1 zset2 0
1) "zset1"
2) "a"
3) "0"

replay can be one of the following:

Nil reply: when no element could be popped and the timeout expired.
Array reply: the keyname, popped member, and its score.

so when its an array replay, which means we popped an element, we want to convert just the score from string to double

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, thanks!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np

Lolwut,
ArrayOfArraysOfDoubleOrNull,
ArrayOfKeyValuePairs,
KeyWithMemberAndScore,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ig it was forgotten, good catch:)

if array.len() == 3
&& matches!(array[2], Value::BulkString(_) | Value::SimpleString(_)) =>
{
array[2] =
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redis> ZADD zset1 0 a 1 b 2 c
(integer) 3
redis> BZPOPMIN zset1 zset2 0
1) "zset1"
2) "a"
3) "0"

replay can be one of the following:

Nil reply: when no element could be popped and the timeout expired.
Array reply: the keyname, popped member, and its score.

so when its an array replay, which means we popped an element, we want to convert just the score from string to double

Comment on lines +2305 to +2307
BZPOPMAX is the blocking variant of ZPOPMAX.

BZPOPMAX is a client blocking command, see https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best practices.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
BZPOPMAX is the blocking variant of ZPOPMAX.
BZPOPMAX is a client blocking command, see https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best practices.
`BZPOPMAX` is the blocking variant of `ZPOPMAX`.
`BZPOPMAX` is a client blocking command, see https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best practices.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should do:

BBZPOPMAX is a client blocking command, see [Blocking commands](https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands) for more details and best practices.

image

Copy link
Copy Markdown
Contributor Author

@aaron-congo aaron-congo May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think hyperlinks like these are supported by default, according to this stack overflow post they aren't, but some tools and/or documentation generators may support them. Looks like VScode does, but I'm using pycharm and it doesn't. Let me know if you still want me to change this to a hyperlink though

image

@aaron-congo aaron-congo force-pushed the python/integ_acongo_bzpopmax branch from a67c7ba to 3f1e3c4 Compare May 13, 2024 21:12
@aaron-congo
Copy link
Copy Markdown
Contributor Author

@shohamazon Thanks for the review, all comments are addressed now

@Yury-Fridlyand
Copy link
Copy Markdown

@aaron-congo please, resolve conflicts and merge

@aaron-congo aaron-congo force-pushed the python/integ_acongo_bzpopmax branch from 9c3e15f to 6a23610 Compare May 13, 2024 23:54
@acarbonetto acarbonetto merged commit 8c590a7 into valkey-io:main May 14, 2024
@acarbonetto acarbonetto deleted the python/integ_acongo_bzpopmax branch May 14, 2024 05:25
avifenesh pushed a commit that referenced this pull request May 14, 2024
* Python: add BZPOPMIN and BZPOPMAX commands (#266)

* Update PR link

* PR suggestions

* Fix rust
cyip10 pushed a commit to Bit-Quill/valkey-glide that referenced this pull request Jun 24, 2024
* Python: add BZPOPMIN and BZPOPMAX commands (#266)

* Update PR link

* PR suggestions

* Fix rust
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python 🐍 Python wrapper

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants