Skip to content
40 changes: 37 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",
"DEFAULT", "hugegraph")
.configTimeout(20) // 默认 20s 超时
.configUser("**", "**") // 默认未开启用户权限
.build();
Expand Down Expand Up @@ -455,6 +456,39 @@ Edge knows1 = marko.addEdge("knows", vadas, "city", "Beijing");

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

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

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

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

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

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

| category | interface | description |
|----------|------------------------|------------------------------------------|
| 查询 | listGraphSpace() | 获取所有 GraphSpace 列表 |
| | getGraphSpace(String name) | 获取指定 GraphSpace |
| | space.getName() | 获取 GraphSpace 名称 |
| 更新 | space.setDescription(String description) | 修改 GraphSpace 描述信息 |
| | space.setMaxGraphNumber(int maxNumber) | 设置 GraphSpace 最大图数量 |
| | space.setMaxRoleNumber(int maxRoleNumber) | 设置 GraphSpace 最大图数量 |
| | updateGraphSpace(String name, GraphSpace space) | 更新 GraphSpace 配置 |
| 删除 | removeGraphSpace(String name) | 删除指定 GraphSpace |


### 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();

Copy link
Member

Choose a reason for hiding this comment

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

⚠️ 代码风格问题:缩进不一致

这里的缩进与上下文不一致,建议使用相同的缩进风格:

```suggestion
.configUser("username", "password")
// 这是示例,生产环境需要使用安全的凭证
.build();
```

应保持一致的缩进,使用空格对齐。

SchemaManager schema = hugeClient.schema();

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

### 4.4 运行 Example
#### 4.4 运行 Example

运行 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)

7 changes: 4 additions & 3 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 | 图数据库空间 |
| `-s` 或 `--schema` | | Y | schema 文件路径 | |
| `-h` 或 `--host` | localhost | | HugeGraphServer 的地址 |
| `-g` 或 `--graph` | | Y | 图名称 |
| `-gs` 或 `--graphspace` | DEFAULT | | 图空间 |
| `-s` 或 `--schema` | | Y | schema 文件路径 |
| `-h` 或 `--host` 或 `-i` | localhost | | HugeGraphServer 的地址 |
| `-p` 或 `--port` | 8080 | | HugeGraphServer 的端口号 |
| `--username` | null | | 当 HugeGraphServer 开启了权限认证时,当前图的 username |
| `--token` | null | | 当 HugeGraphServer 开启了权限认证时,当前图的 token |
Expand Down
38 changes: 37 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,42 @@ 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);
```

#### 4.2 GraphSpace Interface Summary

| Category | Interface | Description |
|----------|-----------|-------------|
| Query | listGraphSpace() | 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| space.setDescription(String description) | Modify GraphSpace description |
| | space.setMaxGraphNumber(int maxNumber) | Set maximum number of graphs in GraphSpace |
| | space.setMaxRoleNumber(int maxRoleNumber) | Set maximum role number in GraphSpace |
| | updateGraphSpace(String name, GraphSpace space) | Update GraphSpace configuration |
| Delete | removeGraphSpace(String name) | Delete the specified GraphSpace |
| | removeGraphSpace(String name, boolean force) | Force delete GraphSpace (including all graph data) |

### 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