You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hugegraph.apache.org by "Thespica (via GitHub)" <gi...@apache.org> on 2025/03/09 09:56:41 UTC

[PR] [WIP]fix(client): Patch up missing classes and methods for hubble [incubator-hugegraph-toolchain]

Thespica opened a new pull request, #657:
URL: https://github.com/apache/incubator-hugegraph-toolchain/pull/657

   <!-- 
     Thank you very much for contributing to Apache HugeGraph, we are happy that you want to help us improve it!
   
     Here are some tips for you:
       1. If this is your first time, please read the [contributing guidelines](https://github.com/apache/hugegraph/blob/master/CONTRIBUTING.md)
   
       2. If a PR fix/close an issue, type the message "close xxx" (xxx is the link of related 
   issue) in the content, GitHub will auto link it (Required)
   
       3. Name the PR title in "Google Commit Format", start with "feat | fix | perf | refactor | doc | chore", 
         such like: "feat(core): support the PageRank algorithm" or "fix: wrong break in the compute loop" (module is optional)
         skip it if you are unsure about which is the best component.
   
       4. One PR address one issue, better not to mix up multiple issues.
   
       5. Put an `x` in the `[ ]` to mark the item as CHECKED. `[x]` (or click it directly after 
   published)
   -->
   
   ## Purpose of the PR
   
   - close #xxx  <!-- or use "fix #xxx", "xxx" is the ID-link of related issue, e.g: close #1024 -->
   
   <!--
   Please explain more context in this section, clarify why the changes are needed. 
   e.g:
   - If you propose a new API, clarify the use case for a new API.
   - If you fix a bug, you can clarify why it is a bug, and should be associated with an issue.
   -->
   
   ## Main Changes
   
   <!-- Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. These change logs are helpful for better ant faster reviews.)
   
   For example:
   
   - If you introduce a new feature, please show detailed design here or add the link of design documentation.
   - If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
   - If there is a discussion in the mailing list, please add the link. -->
   
   ## Verifying these changes
   
   <!-- Please pick the proper options below -->
   
   - [ ] Trivial rework / code cleanup without any test coverage. (No Need)
   - [ ] Already covered by existing tests, such as *(please modify tests here)*.
   - [ ] Need tests and can be verified as follows:
       - xxx
   
   ## Does this PR potentially affect the following parts?
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ]  Nope
   - [ ]  Dependencies (add/update license info) <!-- Don't forget to add/update the info in "LICENSE" & "NOTICE" files (both in root & dist module) -->
   - [ ]  Modify configurations
   - [ ]  The public API
   - [ ]  Other affects (typed here)
   
   ## Documentation Status
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ]  `Doc - TODO` <!-- Your PR changes impact docs and you will update later -->
   - [ ]  `Doc - Done` <!-- Related docs have been already added or updated -->
   - [ ]  `Doc - No Need` <!-- Your PR changes don't impact/need docs -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] fix(client): Patch up missing classes and methods for hubble [incubator-hugegraph-toolchain]

Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #657:
URL: https://github.com/apache/incubator-hugegraph-toolchain/pull/657#discussion_r2083521489


##########
hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java:
##########
@@ -83,17 +96,102 @@ public List<String> list() {
         return result.readList(this.type(), String.class);
     }
 
+    public List<Map<String, Object>> listProfile(String prefix) {
+        String profilePath = joinPath(this.path(), "profile");
+        Map<String, Object> params = new LinkedHashMap<>();
+        params.put("prefix", prefix);
+        RestResult result = this.client.get(profilePath, params);
+        List<Map> results = result.readList(Map.class);
+        List<Map<String, Object>> profiles = new ArrayList<>();
+        for (Object entry: results) {
+            profiles.add(JsonUtil.fromJson(JsonUtil.toJson(entry), Map.class));
+        }
+        return profiles;
+    }
+
+    public Map<String, String> setDefault(String name) {
+        String defaultPath = joinPath(this.path(), name, "default");
+        RestResult result = this.client.get(defaultPath);
+        return result.readObject(Map.class);
+    }
+
+    public Map<String, String> unSetDefault(String name) {
+        String unDefaultPath = joinPath(this.path(), name, "undefault");
+        RestResult result = this.client.get(unDefaultPath);
+        return result.readObject(Map.class);
+    }
+
+    public Map<String, String> getDefault () {
+        String defaultPath = joinPath(this.path(), "default");
+        RestResult result = this.client.get(defaultPath);
+        return result.readObject(Map.class);
+    }
+
+    // TODO(@Thespcia): in inner version, called by clear(String name) or
+    //  clear(String name, boolean clearSchema)
     public void clear(String graph, String message) {
         this.client.delete(joinPath(this.path(), graph, CLEAR),
                            ImmutableMap.of(CONFIRM_MESSAGE, message));
     }
 
+    public Map<String, String> update(String name, String nickname) {
+        Map<String, String> actionMap = new HashMap<>();
+        actionMap.put("name", name);
+        actionMap.put("nickname", nickname);
+        RestResult result = this.client.put(this.path(),
+                                            name,
+                                            ImmutableMap.of("action", "update",
+                                                            "update",
+                                                            actionMap));
+        Map<String, String> response = result.readObject(Map.class);
+
+        E.checkState(response.size() == 1 && response.containsKey(name),
+                     "Response must be formatted to {\"%s\" : status}, " +
+                     "but got %s", name, response);
+        String status = response.get(name);
+        E.checkState(UPDATED.equals(status),
+                     "Server status must be %s, but got '%s'", status);
+        return response;
+    }
+
+    // TODO(@Thespcia): in inner version, this method called delete, and doesn't need confirm

Review Comment:
   keep both of them for now?
   
   delete(without msg) & drop(with msg)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] fix(client): Patch up missing classes and methods for hubble [incubator-hugegraph-toolchain]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #657:
URL: https://github.com/apache/incubator-hugegraph-toolchain/pull/657#issuecomment-2869971404

   ## [Codecov](https://app.codecov.io/gh/apache/incubator-hugegraph-toolchain/pull/657?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   All modified and coverable lines are covered by tests :white_check_mark:
   > Project coverage is 62.03%. Comparing base [(`b066b80`)](https://app.codecov.io/gh/apache/incubator-hugegraph-toolchain/commit/b066b805630ca591809cfee2da2aae1395fc6b42?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`cbe0e1f`)](https://app.codecov.io/gh/apache/incubator-hugegraph-toolchain/commit/cbe0e1f6064c03b203d7dbc14b2928173a261a68?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   > Report is 52 commits behind head on master.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master     #657      +/-   ##
   ============================================
   - Coverage     62.49%   62.03%   -0.47%     
   + Complexity     1903      936     -967     
   ============================================
     Files           262       93     -169     
     Lines          9541     4565    -4976     
     Branches        886      530     -356     
   ============================================
   - Hits           5963     2832    -3131     
   + Misses         3190     1520    -1670     
   + Partials        388      213     -175     
   ```
   
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/incubator-hugegraph-toolchain/pull/657?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] [WIP]fix(client): Patch up missing classes and methods for hubble [incubator-hugegraph-toolchain]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #657:
URL: https://github.com/apache/incubator-hugegraph-toolchain/pull/657#discussion_r2020135997


##########
hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CountAPI.java:
##########
@@ -22,28 +22,40 @@
 import org.apache.hugegraph.client.RestClient;
 import org.apache.hugegraph.rest.RestResult;
 import org.apache.hugegraph.structure.traverser.CountRequest;
+import org.apache.hugegraph.structure.traverser.CountResponse;
 import org.apache.hugegraph.util.E;
 
 public class CountAPI extends TraversersAPI {
 
     private static final String COUNT = "count";
 
-    public CountAPI(RestClient client, String graph) {
-        super(client, graph);
+    public CountAPI(RestClient client,  String graphSpace, String graph) {
+        super(client, graphSpace, graph);
     }
 
     @Override
     protected String type() {
         return "count";
     }
 
-    public long post(CountRequest request) {
+    public CountResponse post(CountRequest request) {
         this.client.checkApiVersion("0.55", "count");
         RestResult result = this.client.post(this.path(), request);
-        @SuppressWarnings("unchecked")
-        Map<String, Number> countMap = result.readObject(Map.class);
-        E.checkState(countMap.containsKey(COUNT),
-                     "The result doesn't have key '%s'", COUNT);
-        return countMap.get(COUNT).longValue();
+        // TODO: temp implementation
+        if (!result.content().contains("countMap")) {
+            @SuppressWarnings("unchecked")
+            Map<String, Number> countMap = result.readObject(Map.class);

Review Comment:
   The conditional check on the response content may be brittle; consider a more robust approach for distinguishing between response formats in the temporary implementation.
   ```suggestion
           Object responseObject = result.readObject(Object.class);
           if (responseObject instanceof Map) {
               @SuppressWarnings("unchecked")
               Map<String, Number> countMap = (Map<String, Number>) responseObject;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] fix(client): Patch up missing classes and methods for hubble [incubator-hugegraph-toolchain]

Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #657:
URL: https://github.com/apache/incubator-hugegraph-toolchain/pull/657#discussion_r2083521489


##########
hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java:
##########
@@ -83,17 +96,102 @@ public List<String> list() {
         return result.readList(this.type(), String.class);
     }
 
+    public List<Map<String, Object>> listProfile(String prefix) {
+        String profilePath = joinPath(this.path(), "profile");
+        Map<String, Object> params = new LinkedHashMap<>();
+        params.put("prefix", prefix);
+        RestResult result = this.client.get(profilePath, params);
+        List<Map> results = result.readList(Map.class);
+        List<Map<String, Object>> profiles = new ArrayList<>();
+        for (Object entry: results) {
+            profiles.add(JsonUtil.fromJson(JsonUtil.toJson(entry), Map.class));
+        }
+        return profiles;
+    }
+
+    public Map<String, String> setDefault(String name) {
+        String defaultPath = joinPath(this.path(), name, "default");
+        RestResult result = this.client.get(defaultPath);
+        return result.readObject(Map.class);
+    }
+
+    public Map<String, String> unSetDefault(String name) {
+        String unDefaultPath = joinPath(this.path(), name, "undefault");
+        RestResult result = this.client.get(unDefaultPath);
+        return result.readObject(Map.class);
+    }
+
+    public Map<String, String> getDefault () {
+        String defaultPath = joinPath(this.path(), "default");
+        RestResult result = this.client.get(defaultPath);
+        return result.readObject(Map.class);
+    }
+
+    // TODO(@Thespcia): in inner version, called by clear(String name) or
+    //  clear(String name, boolean clearSchema)
     public void clear(String graph, String message) {
         this.client.delete(joinPath(this.path(), graph, CLEAR),
                            ImmutableMap.of(CONFIRM_MESSAGE, message));
     }
 
+    public Map<String, String> update(String name, String nickname) {
+        Map<String, String> actionMap = new HashMap<>();
+        actionMap.put("name", name);
+        actionMap.put("nickname", nickname);
+        RestResult result = this.client.put(this.path(),
+                                            name,
+                                            ImmutableMap.of("action", "update",
+                                                            "update",
+                                                            actionMap));
+        Map<String, String> response = result.readObject(Map.class);
+
+        E.checkState(response.size() == 1 && response.containsKey(name),
+                     "Response must be formatted to {\"%s\" : status}, " +
+                     "but got %s", name, response);
+        String status = response.get(name);
+        E.checkState(UPDATED.equals(status),
+                     "Server status must be %s, but got '%s'", status);
+        return response;
+    }
+
+    // TODO(@Thespcia): in inner version, this method called delete, and doesn't need confirm

Review Comment:
   keep both of them for now?
   
   delete(without msg) & drop(with msg), call the same function from server (just like a syntax sugar)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] fix(client): Patch up missing classes and methods for hubble [incubator-hugegraph-toolchain]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #657:
URL: https://github.com/apache/incubator-hugegraph-toolchain/pull/657#discussion_r2083520692


##########
hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java:
##########
@@ -83,17 +96,102 @@ public List<String> list() {
         return result.readList(this.type(), String.class);
     }
 
+    public List<Map<String, Object>> listProfile(String prefix) {
+        String profilePath = joinPath(this.path(), "profile");
+        Map<String, Object> params = new LinkedHashMap<>();
+        params.put("prefix", prefix);
+        RestResult result = this.client.get(profilePath, params);
+        List<Map> results = result.readList(Map.class);
+        List<Map<String, Object>> profiles = new ArrayList<>();
+        for (Object entry: results) {
+            profiles.add(JsonUtil.fromJson(JsonUtil.toJson(entry), Map.class));
+        }
+        return profiles;
+    }
+
+    public Map<String, String> setDefault(String name) {
+        String defaultPath = joinPath(this.path(), name, "default");
+        RestResult result = this.client.get(defaultPath);
+        return result.readObject(Map.class);
+    }
+
+    public Map<String, String> unSetDefault(String name) {
+        String unDefaultPath = joinPath(this.path(), name, "undefault");
+        RestResult result = this.client.get(unDefaultPath);
+        return result.readObject(Map.class);
+    }
+
+    public Map<String, String> getDefault () {
+        String defaultPath = joinPath(this.path(), "default");
+        RestResult result = this.client.get(defaultPath);
+        return result.readObject(Map.class);
+    }
+
+    // TODO(@Thespcia): in inner version, called by clear(String name) or
+    //  clear(String name, boolean clearSchema)
     public void clear(String graph, String message) {
         this.client.delete(joinPath(this.path(), graph, CLEAR),
                            ImmutableMap.of(CONFIRM_MESSAGE, message));
     }
 
+    public Map<String, String> update(String name, String nickname) {
+        Map<String, String> actionMap = new HashMap<>();
+        actionMap.put("name", name);
+        actionMap.put("nickname", nickname);
+        RestResult result = this.client.put(this.path(),
+                                            name,
+                                            ImmutableMap.of("action", "update",
+                                                            "update",
+                                                            actionMap));
+        Map<String, String> response = result.readObject(Map.class);
+
+        E.checkState(response.size() == 1 && response.containsKey(name),
+                     "Response must be formatted to {\"%s\" : status}, " +
+                     "but got %s", name, response);
+        String status = response.get(name);
+        E.checkState(UPDATED.equals(status),
+                     "Server status must be %s, but got '%s'", status);
+        return response;
+    }
+
+    // TODO(@Thespcia): in inner version, this method called delete, and doesn't need confirm
+    //  message.
+    // community version server don't support now(3/11/2025), so we still need to keep this format.
     public void drop(String graph, String message) {
         this.client.checkApiVersion("0.67", "dynamic graph delete");
         this.client.delete(joinPath(this.path(), graph),
                            ImmutableMap.of(CONFIRM_MESSAGE, message));
     }
 
+    public Map<String, String> reload(String name) {

Review Comment:
   Similarly, in the reload method, the error message formatting in the E.checkState call is missing a parameter for one of the placeholders. Please update the error message to supply all expected parameters such as the graph name, the expected status (RELOADED) and the actual status.



##########
hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java:
##########
@@ -83,17 +96,102 @@ public List<String> list() {
         return result.readList(this.type(), String.class);
     }
 
+    public List<Map<String, Object>> listProfile(String prefix) {
+        String profilePath = joinPath(this.path(), "profile");
+        Map<String, Object> params = new LinkedHashMap<>();
+        params.put("prefix", prefix);
+        RestResult result = this.client.get(profilePath, params);
+        List<Map> results = result.readList(Map.class);
+        List<Map<String, Object>> profiles = new ArrayList<>();
+        for (Object entry: results) {
+            profiles.add(JsonUtil.fromJson(JsonUtil.toJson(entry), Map.class));
+        }
+        return profiles;
+    }
+
+    public Map<String, String> setDefault(String name) {
+        String defaultPath = joinPath(this.path(), name, "default");
+        RestResult result = this.client.get(defaultPath);
+        return result.readObject(Map.class);
+    }
+
+    public Map<String, String> unSetDefault(String name) {
+        String unDefaultPath = joinPath(this.path(), name, "undefault");
+        RestResult result = this.client.get(unDefaultPath);
+        return result.readObject(Map.class);
+    }
+
+    public Map<String, String> getDefault () {
+        String defaultPath = joinPath(this.path(), "default");
+        RestResult result = this.client.get(defaultPath);
+        return result.readObject(Map.class);
+    }
+
+    // TODO(@Thespcia): in inner version, called by clear(String name) or
+    //  clear(String name, boolean clearSchema)
     public void clear(String graph, String message) {
         this.client.delete(joinPath(this.path(), graph, CLEAR),
                            ImmutableMap.of(CONFIRM_MESSAGE, message));
     }
 
+    public Map<String, String> update(String name, String nickname) {

Review Comment:
   In the update method, the error message formatting in the E.checkState calls is incorrect; the placeholders in the string expect more arguments than provided. Please adjust the format arguments so that the constants (e.g. UPDATED) and the obtained status are passed in the expected order.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] fix(client): Patch up missing classes and methods for hubble [incubator-hugegraph-toolchain]

Posted by "VGalaxies (via GitHub)" <gi...@apache.org>.
VGalaxies merged PR #657:
URL: https://github.com/apache/incubator-hugegraph-toolchain/pull/657


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org