You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hugegraph.apache.org by "diaohancai (via GitHub)" <gi...@apache.org> on 2024/02/07 05:08:19 UTC
[PR] chore: json util supply method to parse json list [incubator-hugegraph-toolchain]
diaohancai opened a new pull request, #577:
URL: https://github.com/apache/incubator-hugegraph-toolchain/pull/577
## Purpose of the PR
- close #576
## Main Changes
`org.apache.hugegraph.util.JsonUtil` supply method to parse json list.
## Verifying these changes
- [ ] Trivial rework / code cleanup without any test coverage. (No Need)
- [ ] Already covered by existing tests, such as *(please modify tests here)*.
- [X] Need tests and can be verified as follows:
- `org.apache.hugegraph.unit.JsonUtilTest`
## Does this PR potentially affect the following parts?
- [X] 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
- [ ] `Doc - TODO` <!-- Your PR changes impact docs and you will update later -->
- [ ] `Doc - Done` <!-- Related docs have been already added or updated -->
- [X] `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] chore(client): json util supply method to parse json list [incubator-hugegraph-toolchain]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on PR #577:
URL: https://github.com/apache/incubator-hugegraph-toolchain/pull/577#issuecomment-1953895053
<img width="1455" alt="image" src="https://github.com/apache/incubator-hugegraph-toolchain/assets/17706099/26990c66-2a94-4a7c-8e2b-0acf5299a341">
license header (add we'll provide a **doc** to setup IDEA soon)
--
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] chore(client): json util supply method to parse json list [incubator-hugegraph-toolchain]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #577:
URL: https://github.com/apache/incubator-hugegraph-toolchain/pull/577#issuecomment-1953903686
## [Codecov](https://app.codecov.io/gh/apache/incubator-hugegraph-toolchain/pull/577?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
Attention: `2 lines` in your changes are missing coverage. Please review.
> Comparison is base [(`b066b80`)](https://app.codecov.io/gh/apache/incubator-hugegraph-toolchain/commit/b066b805630ca591809cfee2da2aae1395fc6b42?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) 62.49% compared to head [(`6cff118`)](https://app.codecov.io/gh/apache/incubator-hugegraph-toolchain/pull/577?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) 62.54%.
> Report is 19 commits behind head on master.
| [Files](https://app.codecov.io/gh/apache/incubator-hugegraph-toolchain/pull/577?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [.../main/java/org/apache/hugegraph/util/JsonUtil.java](https://app.codecov.io/gh/apache/incubator-hugegraph-toolchain/pull/577?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aHVnZWdyYXBoLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaHVnZWdyYXBoL3V0aWwvSnNvblV0aWwuamF2YQ==) | 50.00% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/incubator-hugegraph-toolchain/pull/577?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #577 +/- ##
============================================
+ Coverage 62.49% 62.54% +0.04%
- Complexity 1903 1925 +22
============================================
Files 262 267 +5
Lines 9541 9681 +140
Branches 886 888 +2
============================================
+ Hits 5963 6055 +92
- Misses 3190 3237 +47
- Partials 388 389 +1
```
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/incubator-hugegraph-toolchain/pull/577?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).
--
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] chore(client): json util supply method to parse json list [incubator-hugegraph-toolchain]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #577:
URL: https://github.com/apache/incubator-hugegraph-toolchain/pull/577#discussion_r1480967105
##########
hugegraph-client/src/main/java/org/apache/hugegraph/util/JsonUtil.java:
##########
@@ -60,4 +62,17 @@ public static <T> T convertValue(JsonNode node, Class<T> clazz) {
e, node);
}
}
+
+ public static <T> List<T> fromJson2List(String json, Class<T> clazz) {
+ try {
+ return MAPPER.readValue(json, getCollectionType(List.class, clazz));
+ } catch (IOException e) {
+ throw new SerializeException("Failed to deserialize json '%s'", e, json);
+ }
+ }
+
+ private static JavaType getCollectionType(Class<?> collectionClass,
+ Class<?>... elementClasses) {
+ return MAPPER.getTypeFactory().constructParametricType(collectionClass, elementClasses);
Review Comment:
shall we consider move the JsonUtil to `hugegraph-common` module?
--
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] chore(client): json util supply method to parse json list [incubator-hugegraph-toolchain]
Posted by "javeme (via GitHub)" <gi...@apache.org>.
javeme commented on code in PR #577:
URL: https://github.com/apache/incubator-hugegraph-toolchain/pull/577#discussion_r1501349462
##########
hugegraph-client/src/main/java/org/apache/hugegraph/util/JsonUtil.java:
##########
@@ -60,4 +62,17 @@ public static <T> T convertValue(JsonNode node, Class<T> clazz) {
e, node);
}
}
+
+ public static <T> List<T> fromJson2List(String json, Class<T> clazz) {
Review Comment:
move to line 56?
--
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] chore(client): json util supply method to parse json list [incubator-hugegraph-toolchain]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #577:
URL: https://github.com/apache/incubator-hugegraph-toolchain/pull/577#discussion_r1480967105
##########
hugegraph-client/src/main/java/org/apache/hugegraph/util/JsonUtil.java:
##########
@@ -60,4 +62,17 @@ public static <T> T convertValue(JsonNode node, Class<T> clazz) {
e, node);
}
}
+
+ public static <T> List<T> fromJson2List(String json, Class<T> clazz) {
+ try {
+ return MAPPER.readValue(json, getCollectionType(List.class, clazz));
+ } catch (IOException e) {
+ throw new SerializeException("Failed to deserialize json '%s'", e, json);
+ }
+ }
+
+ private static JavaType getCollectionType(Class<?> collectionClass,
+ Class<?>... elementClasses) {
+ return MAPPER.getTypeFactory().constructParametricType(collectionClass, elementClasses);
Review Comment:
shall we consider moving the JsonUtil to `hugegraph-common` module?
--
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] chore(client): json util supply method to parse json list [hugegraph-toolchain]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin merged PR #577:
URL: https://github.com/apache/hugegraph-toolchain/pull/577
--
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