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

Java: JSON.ARRINSERT and JSON.ARRLEN #2476

Merged
merged 8 commits into from
Oct 19, 2024
Merged

Conversation

Yury-Fridlyand
Copy link
Collaborator

Issue link

#2430

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one issue.
  • Commit message has a detailed description of what changed and why.
  • Tests are added or updated.
  • CHANGELOG.md and documentation files are updated.
  • Destination branch is correct - main or release
  • Commits will be squashed upon merging.

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
@Yury-Fridlyand Yury-Fridlyand added the java issues and fixes related to the java client label Oct 18, 2024
@Yury-Fridlyand Yury-Fridlyand requested a review from a team as a code owner October 18, 2024 21:35
@Yury-Fridlyand Yury-Fridlyand changed the title JSON.ARRINSERT and JSON.ARRLEN Java: JSON.ARRINSERT and JSON.ARRLEN Oct 18, 2024
@Yury-Fridlyand Yury-Fridlyand mentioned this pull request Oct 18, 2024
22 tasks
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
…alkey-442

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
};
var res = Json.arrinsert(client, key, "$..a", 0, values).get();

doc = Json.get(client, key).get();
Copy link
Contributor

Choose a reason for hiding this comment

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

why are you re-using doc?

Copy link
Collaborator Author

@Yury-Fridlyand Yury-Fridlyand Oct 18, 2024

Choose a reason for hiding this comment

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

Why not? I reuse res as well

@@ -11,6 +11,7 @@ dependencies {
implementation project(':client')

implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.13.0'
implementation 'com.google.code.gson:gson:2.10.1'
Copy link
Contributor

Choose a reason for hiding this comment

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

is the license ok?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Apache-2
Anyway it is used for tests only.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll align with you to use this google library instead of org.skyscreamer.jsonassert for JSON equality test in my next PR then. We don't need 2 different lib for the same purpose.

*
* @param client The client to execute the command.
* @param key The key of the JSON document.
* @return The array length stored at the root of the document. If document root is not an array,
Copy link
Contributor

Choose a reason for hiding this comment

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

@jamesx-improving are we including this signature? It doesn't seem useful to include a API signature that won't get used.
We should consider removing this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Which signature?

Copy link
Collaborator

Choose a reason for hiding this comment

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

For this command, path is indeed optional on all versions of documentations, hence it's hard to justify the removal of this signature (and the GlideString variant of it down below)

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
@@ -19,9 +19,11 @@
/** Module for JSON commands. */
public class Json {

public static final String JSON_PREFIX = "JSON.";
private static final String JSON_PREFIX = "JSON.";
public static final String JSON_SET = JSON_PREFIX + "SET";
public static final String JSON_GET = JSON_PREFIX + "GET";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Change both GET and SET to private too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is used somewhere in UT.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't worry about it, I'll get it sort out in my next PR. But you do have a point, these don't need to be public.

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
@@ -19,9 +19,11 @@
/** Module for JSON commands. */
public class Json {

public static final String JSON_PREFIX = "JSON.";
private static final String JSON_PREFIX = "JSON.";
public static final String JSON_SET = JSON_PREFIX + "SET";
public static final String JSON_GET = JSON_PREFIX + "GET";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't worry about it, I'll get it sort out in my next PR. But you do have a point, these don't need to be public.

@@ -11,6 +11,7 @@ dependencies {
implementation project(':client')

implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.13.0'
implementation 'com.google.code.gson:gson:2.10.1'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll align with you to use this google library instead of org.skyscreamer.jsonassert for JSON equality test in my next PR then. We don't need 2 different lib for the same purpose.

*
* @param client The client to execute the command.
* @param key The key of the JSON document.
* @return The array length stored at the root of the document. If document root is not an array,
Copy link
Collaborator

Choose a reason for hiding this comment

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

For this command, path is indeed optional on all versions of documentations, hence it's hard to justify the removal of this signature (and the GlideString variant of it down below)

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
@Yury-Fridlyand Yury-Fridlyand merged commit 56b4401 into release-1.2 Oct 19, 2024
8 checks passed
@Yury-Fridlyand Yury-Fridlyand deleted the java/yuryf-valkey-442 branch October 19, 2024 02:23
avifenesh pushed a commit to avifenesh/valkey-glide that referenced this pull request Oct 21, 2024
* `JSON.ARRINSERT` and `JSON.ARRLEN`

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
avifenesh pushed a commit to avifenesh/valkey-glide that referenced this pull request Oct 21, 2024
* `JSON.ARRINSERT` and `JSON.ARRLEN`

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Muhammad-awawdi-amazon pushed a commit to Muhammad-awawdi-amazon/valkey-glide that referenced this pull request Oct 22, 2024
* `JSON.ARRINSERT` and `JSON.ARRLEN`

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
cyip10 pushed a commit that referenced this pull request Oct 23, 2024
* `JSON.ARRINSERT` and `JSON.ARRLEN`

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants