imbajin commented on code in PR #685:
URL:
https://github.com/apache/incubator-hugegraph-toolchain/pull/685#discussion_r2467769857
##########
hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java:
##########
@@ -136,8 +136,17 @@ public void clear(String graph, boolean clearSchema) {
}
public void clear(String graph, String message) {
- this.client.delete(joinPath(this.path(), graph, CLEAR),
- ImmutableMap.of(CONFIRM_MESSAGE, message));
+ clear(null, graph, message);
+ }
+
+ public void clear(String graphSpace, String graph, String message) {
Review Comment:
⚠️ **Important**: [3J[H[2J 方法的逻辑可以简化
当前代码在 和 两个分支中重复了相似逻辑:
```java
public void clear(String graphSpace, String graph, String message) {
if (graphSpace == null) {
this.client.delete(joinPath(this.path(), graph, CLEAR),
ImmutableMap.of(CONFIRM_MESSAGE, message));
} else {
this.client.delete(joinPath(this.path(), graphSpace, graph, CLEAR),
ImmutableMap.of(CONFIRM_MESSAGE, message));
}
}
```
可以简化为:
```java
public void clear(String graphSpace, String graph, String message) {
String path = (graphSpace == null)
? joinPath(this.path(), graph, CLEAR)
: joinPath(this.path(), graphSpace, graph, CLEAR);
this.client.delete(path, ImmutableMap.of(CONFIRM_MESSAGE, message));
}
```
这样代码更简洁,和 方法的风格也保持一致。
##########
hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java:
##########
@@ -173,18 +178,10 @@ private void checkServerApiVersion() {
// 0.81 equals to the {latest_api_version} +10
VersionUtil.check(apiVersion, "0.38", "0.81", "hugegraph-api in
server");
this.client.apiVersion(apiVersion);
- boolean supportGs = VersionUtil.gte(this.version.getCoreVersion(),
"2.0");
+ boolean supportGs = VersionUtil.gte(this.version.getCoreVersion(),
"1.7.0");
Review Comment:
⚠️ **Important**: 版本号字符串 "1.7.0" 应该定义为常量
在 中硬编码了版本号:
```java
boolean supportGs = VersionUtil.gte(this.version.getCoreVersion(), "1.7.0");
```
建议:
1. 在类中定义版本常量: `private static final String MIN_VERSION_SUPPORT_GS = "1.7.0";`
2. 或者在 或单独的常量类中定义,以便在整个项目中复用
3. 这样修改版本号时只需要改一处,降低维护成本
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]