imbajin commented on code in PR #704:
URL:
https://github.com/apache/incubator-hugegraph-toolchain/pull/704#discussion_r2704455735
##########
hugegraph-loader/src/main/java/org/apache/hugegraph/loader/executor/LoadOptions.java:
##########
@@ -165,21 +169,31 @@ public final class LoadOptions implements Cloneable {
public int singleInsertThreads = 8;
@Parameter(names = {"--max-conn"}, arity = 1,
- description = "Max number of HTTP connections to server")
- public int maxConnections = CPUS * 4;
+ validateWith = {PositiveValidator.class},
+ description = "Max number of HTTP connections to server. " +
+ "If left as default and batch-insert-threads is "
+
+ "set, this may be auto-adjusted")
+ public int maxConnections = DEFAULT_MAX_CONNECTIONS;
@Parameter(names = {"--max-conn-per-route"}, arity = 1,
- description = "Max number of HTTP connections to each route")
- public int maxConnectionsPerRoute = CPUS * 2;
+ validateWith = {PositiveValidator.class},
+ description = "Max number of HTTP connections to each route. " +
+ "If left as default and batch-insert-threads is "
+
+ "set, this may be auto-adjusted")
+ public int maxConnectionsPerRoute = DEFAULT_MAX_CONNECTIONS_PER_ROUTE;
@Parameter(names = {"--batch-size"}, arity = 1,
validateWith = {PositiveValidator.class},
description = "The number of lines in each submit")
public int batchSize = 500;
Review Comment:
⚠️ **Important - 参数验证不一致**
新增的 `parseThreads` 使用了 `PositiveValidator.class` 验证器,但默认值计算可能返回小于 1 的值(当
CPUS=1 时,`Math.max(2, CPUS/2)` 返回 2 是安全的,但描述中说 "Must be >= 1" 而非 >= 2)。
**问题:**
1. 描述说 "Must be >= 1",但 `PositiveValidator` 通常要求 > 0
2. 默认值 `Math.max(2, CPUS/2)` 确保最小值为 2,与描述的 >= 1 不一致
3. 可能造成用户困惑:能否手动设置为 1?
**建议:**
1. 明确最小值要求:如果必须 >= 2,描述应改为 "Must be >= 2"
2. 或者允许设置为 1,将默认值改为 `Math.max(1, CPUS/2)`
```suggestion
@Parameter(names = {"--parallel-count", "--parser-threads"}, arity = 1,
validateWith = {PositiveValidator.class},
description = "(--parallel-count is deprecated, use
--parser-threads instead) " +
"The number of parallel read pipelines. " +
"Default: max(2, CPUS/2) where CPUS is the
number " +
"of available processors. Must be >= 2 for
optimal performance")
public int parseThreads = Math.max(2, CPUS / 2);
```
**需要测试:**
1. 在单核机器上验证默认值是否合理
2. 测试手动设置 `--parser-threads 1` 是否被接受或拒绝
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]