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

Add NOSCORES option to ZSCAN & NOVALUES option to HSCAN #2174

Merged
merged 3 commits into from
Sep 5, 2024

Conversation

shohamazon
Copy link
Collaborator

No description provided.

@shohamazon shohamazon requested a review from a team as a code owner August 20, 2024 19:18
@shohamazon shohamazon added python Python wrapper node Node.js wrapper java issues and fixes related to the java client labels Aug 20, 2024
Comment on lines 699 to 703
* at even indices and the value is at odd indices. If options.noValues is set to <code>true
* </code>, the second element will only contain the fields without the values.
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
* at even indices and the value is at odd indices. If options.noValues is set to <code>true
* </code>, the second element will only contain the fields without the values.
* at even indices and the value is at odd indices. If <code>options.noValues</code> is set to <code>true</code>, the second element will only contain the fields without the values.

and rerun spotless

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

using andrews suggestion

@@ -732,7 +733,8 @@ public interface HashBaseCommands {
* </code> returned on the last iteration of the result. The second element is always an
* <code>Array</code> of the subset of the hash held in <code>key</code>. The array in the
* second element is always a flattened series of <code>String</code> pairs, where the key is
* at even indices and the value is at odd indices.
* at even indices and the value is at odd indices. If options.noValues is set to <code>true
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

@@ -2790,7 +2790,8 @@ CompletableFuture<Map<GlideString, Double>> zinterWithScores(
* <code>
* Array</code> of the subset of the sorted set held in <code>key</code>. The array in the
* second element is always a flattened series of <code>String</code> pairs, where the value
* is at even indices and the score is at odd indices.
* is at even indices and the score is at odd indices. If options.noScores is to <code>true
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

@@ -2827,7 +2828,8 @@ CompletableFuture<Map<GlideString, Double>> zinterWithScores(
* <code>
* Array</code> of the subset of the sorted set held in <code>key</code>. The array in the
* second element is always a flattened series of <code>String</code> pairs, where the value
* is at even indices and the score is at odd indices.
* is at even indices and the score is at odd indices. If options.noScores is to <code>true
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

@@ -7052,7 +7052,9 @@ public <ArgType> T zscan(@NonNull ArgType key, @NonNull ArgType cursor) {
* the <code>cursor</code> returned on the last iteration of the sorted set. The second
* element is always an <code>Array</code> of the subset of the sorted set held in <code>key
* </code>. The array in the second element is always a flattened series of <code>String
* </code> pairs, where the value is at even indices and the score is at odd indices.
* </code> pairs, where the value is at even indices and the score is at odd indices. If
* options.noScores is to <code>true</code>, the second element will only contain the members
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

@@ -729,6 +729,24 @@ export async function transactionTest(
responseData.push(["hset(key4, { [field]: value })", 1]);
baseTransaction.hscan(key4, "0");
responseData.push(['hscan(key4, "0")', ["0", [field, value]]]);

if (gte(version, "7.9.0")) {
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 (gte(version, "7.9.0")) {
if (gte(version, "8.0.0")) {

@@ -972,6 +990,25 @@ export async function transactionTest(
responseData.push(["zadd(key12, { one: 1, two: 2 })", 2]);
baseTransaction.zscan(key12, "0");
responseData.push(['zscan(key12, "0")', ["0", ["one", "1", "two", "2"]]]);

if (gte(version, "7.9.0")) {
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 (gte(version, "7.9.0")) {
if (gte(version, "8.0.0")) {

@@ -10020,6 +10020,16 @@ async def test_zscan(self, glide_client: GlideClusterClient):
assert result[result_cursor_index] != b"0"
assert len(result[result_collection_index]) >= 0

# Test no_scores option
if not await check_if_server_version_lt(glide_client, "7.9.0"):
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 not await check_if_server_version_lt(glide_client, "7.9.0"):
if not await check_if_server_version_lt(glide_client, "8.0.0"):

Same here - need to find a way to make this check pass with RC

@@ -10137,6 +10147,16 @@ async def test_hscan(self, glide_client: GlideClusterClient):
assert result[result_cursor_index] != b"0"
assert len(result[result_collection_index]) >= 0

# Test no_values option
if not await check_if_server_version_lt(glide_client, "7.9.0"):
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

@@ -306,6 +306,9 @@ async def transaction_test(
args.append([b"0", [key3.encode(), b"10.5"]])
transaction.hscan(key4, "0", match="*", count=10)
args.append([b"0", [key3.encode(), b"10.5"]])
if not await check_if_server_version_lt(glide_client, "7.9.0"):
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

@@ -696,7 +696,8 @@ public interface HashBaseCommands {
* </code> returned on the last iteration of the result. The second element is always an
* <code>Array</code> of the subset of the hash held in <code>key</code>. The array in the
* second element is always a flattened series of <code>String</code> pairs, where the key is
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
* second element is always a flattened series of <code>String</code> pairs, where the key is
* second element is a flattened series of <code>String</code> pairs, where the key is

@@ -732,7 +733,8 @@ public interface HashBaseCommands {
* </code> returned on the last iteration of the result. The second element is always an
* <code>Array</code> of the subset of the hash held in <code>key</code>. The array in the
* second element is always a flattened series of <code>String</code> pairs, where the key is
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
* second element is always a flattened series of <code>String</code> pairs, where the key is
* second element is a flattened series of <code>String</code> pairs, where the key is

@@ -696,7 +696,8 @@ public interface HashBaseCommands {
* </code> returned on the last iteration of the result. The second element is always an
* <code>Array</code> of the subset of the hash held in <code>key</code>. The array in the
* second element is always a flattened series of <code>String</code> pairs, where the key is
* at even indices and the value is at odd indices.
* at even indices and the value is at odd indices. If options.noValues is set to <code>true
Copy link
Collaborator

Choose a reason for hiding this comment

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

You will need to add import glide.api.models.commands.scan.HScanOptions.HScanOptionsBuilder;

Suggested change
* at even indices and the value is at odd indices. If options.noValues is set to <code>true
* at even indices and the value is at odd indices. If {@link HScanOptionsBuilder#noValues} is set to <code>true

@@ -732,7 +733,8 @@ public interface HashBaseCommands {
* </code> returned on the last iteration of the result. The second element is always an
* <code>Array</code> of the subset of the hash held in <code>key</code>. The array in the
* second element is always a flattened series of <code>String</code> pairs, where the key is
* at even indices and the value is at odd indices.
* at even indices and the value is at odd indices. If options.noValues is set to <code>true
Copy link
Collaborator

Choose a reason for hiding this comment

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

You will need to add import glide.api.models.commands.scan.HScanOptions.HScanOptionsBuilder;

Suggested change
* at even indices and the value is at odd indices. If options.noValues is set to <code>true
* at even indices and the value is at odd indices. If {@link HScanOptionsBuilder#noValues} is set to <code>true

@@ -2790,7 +2790,8 @@ CompletableFuture<Map<GlideString, Double>> zinterWithScores(
* <code>
* Array</code> of the subset of the sorted set held in <code>key</code>. The array in the
* second element is always a flattened series of <code>String</code> pairs, where the value
* is at even indices and the score is at odd indices.
* is at even indices and the score is at odd indices. If options.noScores is to <code>true
Copy link
Collaborator

Choose a reason for hiding this comment

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

You will need to add import glide.api.models.commands.scan.ZScanOptions.ZScanOptionsBuilder;

Suggested change
* is at even indices and the score is at odd indices. If options.noScores is to <code>true
* is at even indices and the score is at odd indices. If {@link ZScanOptionsBuilder#noScores} is to <code>true

* Command Response - An `Array` of the `cursor` and the subset of the sorted set held by `key`.
* The first element is always the `cursor` for the next iteration of results. `0` will be the `cursor`
* returned on the last iteration of the sorted set. The second element is always an `Array` of the subset
* of the sorted set held in `key`. The `Array` in the second element is always a flattened series of
* `String` pairs, where the value is at even indices and the score is at odd indices.
* If options.noScores is to `true`, the second element will only contain the members without scores.
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 options.noScores is to `true`, the second element will only contain the members without scores.
* If `options.noScores` is to `true`, the second element will only contain the members without scores.

`String` pairs, where the value is at even indices and the score is at odd indices.
The first element is always the `cursor` for the next iteration of results. `0` will be the `cursor`
returned on the last iteration of the sorted set. The second element is always an `Array` of the subset
of the sorted set held in `key`. The `Array` in the second element is always a flattened series of
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
of the sorted set held in `key`. The `Array` in the second element is always a flattened series of
of the sorted set held in `key`. The `Array` in the second element is a flattened series of

@@ -6196,13 +6219,15 @@ async def hscan(
count (Optional[int]): `COUNT` is a just a hint for the command for how many elements to fetch from the hash.
`COUNT` could be ignored until the hash is large enough for the `SCAN` commands to represent the results
as compact single-allocation packed encoding.
no_values (bool): If `True`, the command will not return values the fields in the hash. Since Valkey "8.0.0".

Returns:
List[Union[bytes, List[bytes]]]: An `Array` of the `cursor` and the subset of the hash held by `key`.
The first element is always the `cursor` for the next iteration of results. `0` will be the `cursor`
returned on the last iteration of the hash. The second element is always an `Array` of the subset of the
hash held in `key`. The `Array` in the second element is always a flattened series of `String` pairs,
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
hash held in `key`. The `Array` in the second element is always a flattened series of `String` pairs,
hash held in `key`. The `Array` in the second element is a flattened series of `String` pairs,

`String` pairs, where the value is at even indices and the score is at odd indices.
The first element is always the `cursor` for the next iteration of results. `0` will be the `cursor`
returned on the last iteration of the sorted set. The second element is always an `Array` of the subset
of the sorted set held in `key`. The `Array` in the second element is always a flattened series of
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
of the sorted set held in `key`. The `Array` in the second element is always a flattened series of
of the sorted set held in `key`. The `Array` in the second element is a flattened series of

subset of the hash then there could be a case where the result is empty although there are items that
match the pattern specified. This is due to the default `COUNT` being `10` which indicates that it will
only fetch and match `10` items from the list.
count (Optional[int]): `COUNT` is a just a hint for the command for how many elements to fetch from the hash.
`COUNT` could be ignored until the hash is large enough for the `SCAN` commands to represent the results
as compact single-allocation packed encoding.
no_values (bool): If `True`, the command will not return values the fields in the hash. Since Valkey "8.0.0".

Returns:
List[Union[bytes, List[bytes]]]: An `Array` of the `cursor` and the subset of the hash held by `key`.
The first element is always the `cursor` for the next iteration of results. `0` will be the `cursor`
returned on the last iteration of the hash. The second element is always an `Array` of the subset of the
hash held in `key`. The `Array` in the second element is always a flattened series of `String` pairs,
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
hash held in `key`. The `Array` in the second element is always a flattened series of `String` pairs,
hash held in `key`. The `Array` in the second element is a flattened series of `String` pairs,

@asafpamzn asafpamzn mentioned this pull request Aug 25, 2024
7 tasks
Signed-off-by: Shoham Elias <[email protected]>
@shohamazon shohamazon merged commit b2c0575 into valkey-io:main Sep 5, 2024
23 checks passed
@shohamazon shohamazon deleted the scan-8 branch September 5, 2024 14:15
prateek-kumar-improving pushed a commit to Bit-Quill/valkey-glide that referenced this pull request Sep 5, 2024
janhavigupta007 pushed a commit to janhavigupta007/glide-for-redis that referenced this pull request Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
java issues and fixes related to the java client node Node.js wrapper python Python wrapper
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants