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

Node: Add ZUNIONSTORE command #1550

Closed

Conversation

adarovadya
Copy link
Collaborator

Issue #, if available:

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.

@adarovadya adarovadya requested a review from a team as a code owner June 10, 2024 20:37
@adarovadya adarovadya changed the title Zunionstore node command Node: Add ZUNIONSTORE command Jun 10, 2024
Copy link
Collaborator

@Yury-Fridlyand Yury-Fridlyand left a comment

Choose a reason for hiding this comment

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

Please add cross slot test

node/src/Commands.ts Outdated Show resolved Hide resolved
node/tests/SharedTests.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@avifenesh avifenesh left a comment

Choose a reason for hiding this comment

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

See comments.

* @param destination - The key of the destination sorted set.
* @param keys - The keys of the sorted sets with possible formats:
* string[] - for keys only.
* KeyWeight[] - for weighted keys with score multipliers.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does weighted is clear to the user? I don't know what its mean so i would like to have an explantation in the docs, but if it's normally known to the user it is not necessary.

Copy link
Collaborator

Choose a reason for hiding this comment

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

On Java, we linked to the documentation for WeightedKeys object. Is it easy to jump to KeyWeight object on PyCharm?

* await client.zadd("key1", {"member1": 10.5, "member2": 8.2})
* await client.zadd("key2", {"member1": 9.5})
* await client.zunionStore("my_sorted_set", ["key1", "key2"]) // Output: 2 - Indicates that the sorted set "my_sorted_set" contains two elements.
* await client.zrangeWithScores("my_sorted_set", RangeByIndex(0, -1)) // Output: {'member1': 20, 'member2': 8.2} - "member1" is now stored in "my_sorted_set" with score of 20 and "member2" with score of 8.2.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add an example of using weighted?

* await client.zrangeWithScores("my_sorted_set", RangeByIndex(0, -1)) // Output: {'member1': 10.5, 'member2': 8.2} - "member1" is now stored in "my_sorted_set" with score of 10.5 and "member2" with score of 8.2.
* ```
*/
public zunionStore(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be in lowercase

Suggested change
public zunionStore(
public zunionstore(

Please update examples too

Copy link
Collaborator

Choose a reason for hiding this comment

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

we're not too consistent with the *store naming

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is a single word command name, so in user API we do the same.
In internal API it is in camel case

* @param aggregationType - Specifies the aggregation strategy to apply when combining the scores of elements. See `AggregationType`.
* Command Response - The number of elements in the resulting sorted set stored at `destination`.
*/
public zunionStore(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
public zunionStore(
public zunionstore(

* await client.zrangeWithScores("my_sorted_set", RangeByIndex(0, -1)) // Output: {'member1': 10.5, 'member2': 8.2} - "member1" is now stored in "my_sorted_set" with score of 10.5 and "member2" with score of 8.2.
* ```
*/
public zunionStore(
Copy link
Collaborator

Choose a reason for hiding this comment

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

we're not too consistent with the *store naming

*
* When in cluster mode, `destination` and all keys in `keys` must map to the same hash slot.
*
* See https://valkey.io/commands/zunionstore/ for more details.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* See https://valkey.io/commands/zunionstore/ for more details.
* @see {@link https://valkey.io/commands/zunionstore/|valkey.io} for details.

* When in cluster mode, `destination` and all keys in `keys` must map to the same hash slot.
*
* See https://valkey.io/commands/zunionstore/ for more details.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change

* If `destination` already exists, it is overwritten. Otherwise, a new sorted set will be created.
* To get the result directly, see `zunion_withscores`.
*
* See https://valkey.io/commands/zunionstore/ for more details.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* See https://valkey.io/commands/zunionstore/ for more details.
* @see {@link https://valkey.io/commands/zunionstore/|valkey.io} for details.

* To get the result directly, see `zunion_withscores`.
*
* See https://valkey.io/commands/zunionstore/ for more details.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change

@cyip10 cyip10 mentioned this pull request Aug 15, 2024
@GumpacG
Copy link
Collaborator

GumpacG commented Aug 20, 2024

Closing as #2145 took its place.

@GumpacG GumpacG closed this Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants