Skip to content
This repository was archived by the owner on Dec 28, 2025. It is now read-only.
64 changes: 61 additions & 3 deletions content/cn/docs/clients/hugegraph-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ HugeGraph-Client 是操作 graph 的总入口,用户必须先创建出 HugeGra
```java
// HugeGraphServer 地址:"http://localhost:8080"
// 图的名称:"hugegraph"
HugeClient hugeClient = HugeClient.builder("http://localhost:8080", "hugegraph")
HugeClient hugeClient = HugeClient.builder("http://localhost:8080",
Copy link

Choose a reason for hiding this comment

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

‼️ Critical: 参数顺序变更缺少迁移说明

HugeClient.builder() 中新增了 GraphSpace 参数,从:

builder(host, graph)

变更为:

builder(host, space, graph)

问题:

  • 这是一个破坏性的 API 变更,会导致现有代码编译失败
  • PR 描述中提到"兼容:不指定 GraphSpace 时,默认使用 DEFAULT 空间",但实际上 API 签名已经改变,并不向后兼容
  • 缺少迁移指南帮助用户升级

建议:

  • 在文档中添加明确的版本迁移章节,说明从 1.5.0 升级到 1.7.0 的代码变更要点
  • 如果有重载方法保持向后兼容,应该在文档中说明
  • 建议在 PR 描述或 CHANGELOG 中明确标注这是 breaking change

"DEFAULT", "hugegraph")
.configTimeout(20) // 默认 20s 超时
.configUser("**", "**") // 默认未开启用户权限
.build();
Expand Down Expand Up @@ -455,6 +456,63 @@ Edge knows1 = marko.addEdge("knows", vadas, "city", "Beijing");

**注意:当 frequency 为 multiple 时必须要设置 sortKeys 对应属性类型的值。**

### 4 简单示例
### 4 图空间(GraphSpace)
client支持一个物理部署中多个 GraphSpace,每个 GraphSpace 下可以含多个图(graph)。
- 兼容:不指定 GraphSpace 时,默认使用 "DEFAULT" 空间

简单示例见[HugeGraph-Client](/cn/docs/quickstart/client/hugegraph-client)
#### 4.1 创建GraphSpace

```java
GraphSpaceManager spaceManager = hugeClient.graphSpace();

Copy link

Choose a reason for hiding this comment

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

⚠️ Important: 代码示例缺少必要的错误处理

创建 GraphSpace 的示例代码过于简化:

GraphSpaceManager spaceManager = hugeClient.graphSpace();
GraphSpace graphSpace = new GraphSpace();
graphSpace.setName("myGraphSpace");
spaceManager.createGraphSpace(graphSpace);

问题:

  • 没有展示如何处理 GraphSpace 已存在的情况
  • 没有展示参数验证(如名称格式、最大数量限制)
  • 实际使用中需要判断创建是否成功

建议补充完整示例:

try {
    GraphSpaceManager spaceManager = hugeClient.graphSpace();
    
    // 检查是否已存在
    if (spaceManager.getGraphSpace("myGraphSpace") != null) {
        System.out.println("GraphSpace already exists");
        return;
    }
    
    GraphSpace graphSpace = new GraphSpace();
    graphSpace.setName("myGraphSpace");
    graphSpace.setDescription("Business data graph space");
    graphSpace.setMaxGraphNumber(10);
    graphSpace.setMaxRoleNumber(100);
    
    spaceManager.createGraphSpace(graphSpace);
    System.out.println("GraphSpace created successfully");
} catch (Exception e) {
    System.err.println("Failed to create GraphSpace: " + e.getMessage());
}

Copy link
Collaborator Author

@sadwitdastreetz sadwitdastreetz Oct 22, 2025

Choose a reason for hiding this comment

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

这部分有些冗余了,没有必要吧

// 定义 GraphSpace 配置
GraphSpace graphSpace = new GraphSpace();
graphSpace.setName("myGraphSpace");
graphSpace.setDescription("Business data graph space");
graphSpace.setMaxGraphNumber(10); // 最大图数量
graphSpace.setMaxRoleNumber(100); // 最大角色数量

// 创建 GraphSpace
spaceManager.createGraphSpace(graphSpace);
```
**GraphSpace 接口汇总**

| category | interface | description |
|----------|------------------------|------------------------------------------|
| 查询 | listGraphSpaces() | 获取所有 GraphSpace 列表 |
| | getGraphSpace(String name) | 获取指定 GraphSpace |
| | space.getName() | 获取 GraphSpace 名称 |
| | space.getDescription() | 获取 GraphSpace 描述信息 |
| | space.getGraphNumber() | 获取 GraphSpace 下图的数量 |
| 更新 | getGraphSpace(String name) | 获取指定 GraphSpace |
| | space.setDescription(String description) | 修改 GraphSpace 描述信息 |
| | space.setMaxGraphNumber(int maxNumbe) | 设置 GraphSpace 最大图数量 |
| | updateGraphSpace(String name, GraphSpace space) | 更新 GraphSpace 配置 |
| 删除 | removeGraphSpace(String name) | 删除指定 GraphSpace |
| | removeGraphSpace(String name, boolean forc) | 强制删除 GraphSpace(包含所有图数据) |

#### 4.2 GraphSpace 中的图管理

在 GraphSpace 中,可以管理多个图:

```java
// 在指定的 GraphSpace 中创建图
GraphsManager graphsManager = hugeClient.graphs();
Graph graph = new Graph();
graph.setName("businessGraph");
graph.setDescription("Business relationship graph");
graphsManager.createGraph("myGraphSpace", graph);

// 获取 GraphSpace 中的所有图
List<Graph> graphs = graphsManager.listGraphs("myGraphSpace");

Comment on lines +482 to +491
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

接口表方法名不一致且表格不完整

第 481 行显示 listGraphSpace()(单数),但根据之前的审查记录(commit 86ab30f),该方法名应为 listGraphSpaces()(复数)。此外,表格在第 490 行处截断,缺少以下方法:

  • removeGraphSpace(String name, boolean force)
  • setMaxRoleNumber(int maxRoleNumber)(此方法在示例代码中使用过但未列出)

另外,为提高表格清晰度,建议在 GraphSpace 对象方法行中补全 getter 方法列表,并确保所有在示例中出现过的方法都被文档化。

建议修正为:

-| Manager - 查询 | listGraphSpace() | 获取所有 GraphSpace 列表 |
+| Manager - 查询 | listGraphSpaces() | 获取所有 GraphSpace 列表 |
 | | getGraphSpace(String name) | 获取指定 GraphSpace |
 | Manager - 创建/更新 | createGraphSpace(GraphSpace) | 创建 GraphSpace |
 | | updateGraphSpace(String, GraphSpace) | 更新配置 |
 | Manager - 删除 | removeGraphSpace(String) | 删除指定 GraphSpace |
+| | removeGraphSpace(String name, boolean force) | 强制删除 GraphSpace(包含所有图数据) |
 | GraphSpace - 属性 | getName() / getDescription() | 获取名称/描述 |
 | | getGraphNumber() | 获取图数量 |
+| | getMaxGraphNumber() / getMaxRoleNumber() | 获取最大图/角色数量 |
 | GraphSpace - 配置 | setDescription(String) | 设置描述 |
 | | setMaxGraphNumber(int) | 设置最大图数量 |
+| | setMaxRoleNumber(int) | 设置最大角色数量 |

// 获取指定图
Graph businessGraph = graphsManager.getGraph("myGraphSpace", "businessGraph");

// 删除图
graphsManager.removeGraph("myGraphSpace", "businessGraph");
```

### 5 简单示例

简单示例见[HugeGraph-Client](/cn/docs/quickstart/client/hugegraph-client)
13 changes: 7 additions & 6 deletions content/cn/docs/quickstart/client/hugegraph-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ weight: 1
<groupId>org.apache.hugegraph</groupId>
<artifactId>hugegraph-client</artifactId>
<!-- Update to the latest release version -->
<version>1.5.0</version>
<version>1.7.0</version>
</dependency>
</dependencies>
```
Expand Down Expand Up @@ -78,7 +78,8 @@ public class SingleExample {

public static void main(String[] args) throws IOException {
// If connect failed will throw a exception.
HugeClient hugeClient = HugeClient.builder("http://localhost:8080",
HugeClient hugeClient = HugeClient.builder("http://127.0.0.1:8080",
"DEFAULT",
"hugegraph")
.build();

Expand Down Expand Up @@ -224,8 +225,8 @@ public class BatchExample {
public static void main(String[] args) {
// If connect failed will throw a exception.
HugeClient hugeClient = HugeClient.builder("http://localhost:8080",
"hugegraph")
.build();
"DEFAULT",
"hugegraph").build();

SchemaManager schema = hugeClient.schema();

Expand Down Expand Up @@ -348,12 +349,12 @@ public class BatchExample {
}
```

### 4.4 运行 Example
#### 4.4 运行 Example
Copy link

Choose a reason for hiding this comment

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

🧹 Minor: 标题层级调整不一致

在 quickstart 文档中:

  • ### 4.4 运行 Example### 4.5 详细 API 说明 改为 #### 4.4#### 4.5
  • 但父级章节仍是 ### 4,而不是新增的 #### 4.x

问题:
这种改动表明原本的章节编号体系需要调整,但 PR 中没有说明为何要降级这两个小节的标题。

建议:

  • 如果是为了在「4」下新增子章节,应该重新规划章节编号
  • 或者保持原有的三级标题,在前面插入新的三级标题
  • 统一检查中英文文档的标题层级是否一致

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

为了和之前小节的等级保持一致


运行 Example 之前需要启动 Server,
启动过程见[HugeGraph-Server Quick Start](/cn/docs/quickstart/hugegraph-server)

### 4.5 详细 API 说明
#### 4.5 详细 API 说明

示例说明见[HugeGraph-Client 基本 API 介绍](/cn/docs/clients/hugegraph-client)

5 changes: 3 additions & 2 deletions content/cn/docs/quickstart/toolchain/hugegraph-loader.md
Original file line number Diff line number Diff line change
Expand Up @@ -790,9 +790,10 @@ schema: 必填
| 参数 | 默认值 | 是否必传 | 描述信息 |
|---------------------------|-----------|------|-------------------------------------------------------------------|
| `-f` 或 `--file` | | Y | 配置脚本的路径 |
| `-g` 或 `--graph` | | Y | 图数据库空间 |
| `-g` 或 `--graph` | | Y | 图数据库h |
| `-gs` 或 `--graphspace` | DEFAULT | | 图空间 |
| `-s` 或 `--schema` | | Y | schema 文件路径 | |
| `-h` 或 `--host` | localhost | | HugeGraphServer 的地址 |
| `-h` 或 `--host` 或 `-i` | localhost | | HugeGraphServer 的地址 |
| `-p` 或 `--port` | 8080 | | HugeGraphServer 的端口号 |
| `--username` | null | | 当 HugeGraphServer 开启了权限认证时,当前图的 username |
| `--token` | null | | 当 HugeGraphServer 开启了权限认证时,当前图的 token |
Expand Down
60 changes: 59 additions & 1 deletion content/en/docs/clients/hugegraph-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,64 @@ Edge knows1 = marko.addEdge("knows", vadas, "city", "Beijing");

**Note: When frequency is multiple, the value of the property type corresponding to sortKeys must be set.**

### 4 Examples
### 4 GraphSpace
The client supports multiple GraphSpaces in one physical deployment, and each GraphSpace can contain multiple graphs.
- Compatibility: When no GraphSpace is specified, the "DEFAULT" space is used by default.

#### 4.1 Create GraphSpace

```java
GraphSpaceManager spaceManager = hugeClient.graphSpace();

// Define GraphSpace configuration
GraphSpace graphSpace = new GraphSpace();
graphSpace.setName("myGraphSpace");
graphSpace.setDescription("Business data graph space");
graphSpace.setMaxGraphNumber(10); // Maximum number of graphs
graphSpace.setMaxRoleNumber(100); // Maximum number of roles

// Create GraphSpace
spaceManager.createGraphSpace(graphSpace);
```

**GraphSpace Interface Summary**

| Category | Interface | Description |
|----------|-----------|-------------|
| Query | listGraphSpaces() | Get all GraphSpace lists |
| | getGraphSpace(String name) | Get the specified GraphSpace |
| | space.getName() | Get GraphSpace name |
| | space.getDescription() | Get GraphSpace description |
| | space.getGraphNumber() | Get the number of graphs under GraphSpace |
| Update | getGraphSpace(String name) | Get the specified GraphSpace |
| | space.setDescription(String description) | Modify GraphSpace description |
| | space.setMaxGraphNumber(int maxNumbe) | Set maximum number of graphs in GraphSpace |
| | updateGraphSpace(String name, GraphSpace space) | Update GraphSpace configuration |
| Delete | removeGraphSpace(String name) | Delete the specified GraphSpace |
| | removeGraphSpace(String name, boolean forc) | Force delete GraphSpace (including all graph data) |

#### 4.2 Graph Management in GraphSpace

You can manage multiple graphs in a GraphSpace:

```java
// Create a graph in the specified GraphSpace
GraphsManager graphsManager = hugeClient.graphs();
Graph graph = new Graph();
graph.setName("businessGraph");
graph.setDescription("Business relationship graph");
graphsManager.createGraph("myGraphSpace", graph);

// Get all graphs in GraphSpace
List<Graph> graphs = graphsManager.listGraphs("myGraphSpace");

// Get the specified graph
Graph businessGraph = graphsManager.getGraph("myGraphSpace", "businessGraph");

// Delete graph
graphsManager.removeGraph("myGraphSpace", "businessGraph");
```

### 5 Simple Example

Simple examples can reference [HugeGraph-Client](/docs/quickstart/client/hugegraph-client)
16 changes: 8 additions & 8 deletions content/en/docs/quickstart/client/hugegraph-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Using IDEA or Eclipse to create the project:
<groupId>org.apache.hugegraph</groupId>
<artifactId>hugegraph-client</artifactId>
<!-- Update to the latest release version -->
<version>1.5.0</version>
<version>1.7.0</version>
</dependency>
</dependencies>
```
Expand Down Expand Up @@ -73,9 +73,10 @@ import org.apache.hugegraph.structure.gremlin.ResultSet;
public class SingleExample {

public static void main(String[] args) throws IOException {
// If connect failed will throw a exception.
HugeClient hugeClient = HugeClient.builder("http://localhost:8080",
HugeClient hugeClient = HugeClient.builder("http://127.0.0.1:8080",
"DEFAULT",
"hugegraph")
.configUser("admin", "admin")
.build();

SchemaManager schema = hugeClient.schema();
Expand Down Expand Up @@ -218,10 +219,9 @@ import org.apache.hugegraph.structure.graph.Vertex;
public class BatchExample {

public static void main(String[] args) {
// If connect failed will throw a exception.
HugeClient hugeClient = HugeClient.builder("http://localhost:8080",
"hugegraph")
.build();
"DEFAULT",
"hugegraph").build();

SchemaManager schema = hugeClient.schema();

Expand Down Expand Up @@ -344,11 +344,11 @@ public class BatchExample {
}
```

### 4.4 Run The Example
#### 4.4 Run The Example

Before running Example, you need to start the Server. For the startup process, see[HugeGraph-Server Quick Start](/docs/quickstart/hugegraph/hugegraph-server).

### 4.5 More Information About Client-API
#### 4.5 More Information About Client-API

See[Introduce basic API of HugeGraph-Client](/docs/clients/hugegraph-client).

5 changes: 3 additions & 2 deletions content/en/docs/quickstart/toolchain/hugegraph-loader.md
Original file line number Diff line number Diff line change
Expand Up @@ -779,9 +779,10 @@ The import process is controlled by commands submitted by the user, and the user
| Parameter | Default value | Required or not | Description |
|---------------------------|---------------|-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `-f` or `--file` | | Y | path to configure script |
| `-g` or `--graph` | | Y | graph space name |
| `-g` or `--graph` | | Y | graph name |
| `-gs` or `--graphspace` | DEFAULT | | graph space name |
| `-s` or `--schema` | | Y | schema file path |
| `-h` or `--host` | localhost | | address of HugeGraphServer |
| `-h` or `--host` or `i` | localhost | | address of HugeGraphServer |
| `-p` or `--port` | 8080 | | port number of HugeGraphServer |
| `--username` | null | | When HugeGraphServer enables permission authentication, the username of the current graph |
| `--token` | null | | When HugeGraphServer has enabled authorization authentication, the token of the current graph |
Expand Down