Skip to content
This repository was archived by the owner on Dec 28, 2025. It is now read-only.

Commit d533820

Browse files
sadwitdastreetzChoHee15
authored andcommitted
docs: refactor docs of loader & client for new version(1.7.0) (apache#415)
* fixed mvn version to 1.7.0 added graphspace part for docs of client changed client examples to NEWER version fixed parameters in loader docs
1 parent b55fe2b commit d533820

File tree

6 files changed

+168
-39
lines changed

6 files changed

+168
-39
lines changed

content/cn/docs/clients/hugegraph-client.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ weight: 2
1313

1414
HugeGraph-Client 是操作 graph 的总入口,用户必须先创建出 HugeGraph-Client 对象,与 HugeGraph-Server 建立连接(伪连接)后,才能获取到 schema、graph 以及 gremlin 的操作入口对象。
1515

16-
目前 HugeGraph-Client 只允许连接服务端已存在的图,无法自定义图进行创建。其创建方法如下:
16+
目前 HugeGraph-Client 只允许连接服务端已存在的图,无法自定义图进行创建。1.7.0 版本后,client 支持 graphSpace 设置,默认为DEFAULT。其创建方法如下:
1717

1818
```java
1919
// HugeGraphServer 地址:"http://localhost:8080"
2020
// 图的名称:"hugegraph"
2121
HugeClient hugeClient = HugeClient.builder("http://localhost:8080", "hugegraph")
22+
//.builder("http://localhost:8080", "graphSpaceName", "hugegraph")
2223
.configTimeout(20) // 默认 20s 超时
2324
.configUser("**", "**") // 默认未开启用户权限
2425
.build();
@@ -455,6 +456,40 @@ Edge knows1 = marko.addEdge("knows", vadas, "city", "Beijing");
455456

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

458-
### 4 简单示例
459+
### 4 图管理
460+
client支持一个物理部署中多个 GraphSpace,每个 GraphSpace 下可以含多个图(graph)。
461+
- 兼容:不指定 GraphSpace 时,默认使用 "DEFAULT" 空间
462+
463+
#### 4.1 创建GraphSpace
464+
465+
```java
466+
GraphSpaceManager spaceManager = hugeClient.graphSpace();
467+
468+
// 定义 GraphSpace 配置
469+
GraphSpace graphSpace = new GraphSpace();
470+
graphSpace.setName("myGraphSpace");
471+
graphSpace.setDescription("Business data graph space");
472+
graphSpace.setMaxGraphNumber(10); // 最大图数量
473+
graphSpace.setMaxRoleNumber(100); // 最大角色数量
474+
475+
// 创建 GraphSpace
476+
spaceManager.createGraphSpace(graphSpace);
477+
```
478+
#### 4.2 GraphSpace 接口汇总
479+
480+
| 类别 | 接口 | 描述 |
481+
|------|------|------|
482+
| Manager - 查询 | listGraphSpace() | 获取所有 GraphSpace 列表 |
483+
| | getGraphSpace(String name) | 获取指定 GraphSpace |
484+
| Manager - 创建/更新 | createGraphSpace(GraphSpace) | 创建 GraphSpace |
485+
| | updateGraphSpace(String, GraphSpace) | 更新配置 |
486+
| Manager - 删除 | removeGraphSpace(String) | 删除指定 GraphSpace |
487+
| GraphSpace - 属性 | getName() / getDescription() | 获取名称/描述 |
488+
| | getGraphNumber() | 获取图数量 |
489+
| GraphSpace - 配置 | setDescription(String) | 设置描述 |
490+
| | setMaxGraphNumber(int) | 设置最大图数量 |
491+
492+
493+
### 5 简单示例
459494

460495
简单示例见[HugeGraph-Client](/cn/docs/quickstart/client/hugegraph-client)

content/cn/docs/quickstart/client/hugegraph-client.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ weight: 1
4848
<groupId>org.apache.hugegraph</groupId>
4949
<artifactId>hugegraph-client</artifactId>
5050
<!-- Update to the latest release version -->
51-
<version>1.5.0</version>
51+
<version>1.7.0</version>
5252
</dependency>
5353
</dependencies>
5454
```
@@ -79,7 +79,10 @@ public class SingleExample {
7979
public static void main(String[] args) throws IOException {
8080
// If connect failed will throw a exception.
8181
HugeClient hugeClient = HugeClient.builder("http://localhost:8080",
82+
"DEFAULT",
8283
"hugegraph")
84+
.configUser("username", "password")
85+
// 这是示例,生产环境需要使用安全的凭证
8386
.build();
8487

8588
SchemaManager schema = hugeClient.schema();
@@ -224,7 +227,10 @@ public class BatchExample {
224227
public static void main(String[] args) {
225228
// If connect failed will throw a exception.
226229
HugeClient hugeClient = HugeClient.builder("http://localhost:8080",
227-
"hugegraph")
230+
"DEFAULT",
231+
"hugegraph")
232+
.configUser("username", "password")
233+
// 这是示例,生产环境需要使用安全的凭证
228234
.build();
229235

230236
SchemaManager schema = hugeClient.schema();
@@ -348,12 +354,11 @@ public class BatchExample {
348354
}
349355
```
350356

351-
### 4.4 运行 Example
357+
#### 4.4 运行 Example
352358

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

356-
### 4.5 详细 API 说明
362+
#### 4.5 详细 API 说明
357363

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

content/cn/docs/quickstart/toolchain/hugegraph-loader.md

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ bin/mapping-convert.sh struct.json
605605

606606
##### 3.3.2 输入源
607607

608-
输入源目前分为四类:FILE、HDFS、JDBC、KAFKA,由`type`节点区分,我们称为本地文件输入源、HDFS 输入源、JDBC 输入源和 KAFKA 输入源,下面分别介绍。
608+
输入源目前分为五类:FILE、HDFS、JDBC、KAFKA 和 GRAPH,由`type`节点区分,我们称为本地文件输入源、HDFS 输入源、JDBC 输入源和 KAFKA 输入源,图数据源,下面分别介绍。
609609

610610
###### 3.3.2.1 本地文件输入源
611611

@@ -709,6 +709,22 @@ schema: 必填
709709
- skipped_line:想跳过的行,复合结构,目前只能配置要跳过的行的正则表达式,用子节点 regex 描述,默认不跳过任何行,选填;
710710
- early_stop:某次从 Kafka broker 拉取的记录为空,停止任务,默认为 false,仅用于调试,选填;
711711

712+
###### 3.3.2.5 GRAPH 输入源
713+
714+
- type:输入源类型,必须填 `graph``GRAPH`,必填;
715+
- graphspace:源图空间名称,默认为 `DEFAULT`
716+
- graph: 源图名称,必填;
717+
- username:HugeGraph 用户名;
718+
- password:HugeGraph 密码;
719+
- selected_vertices:要同步的顶点筛选规则;
720+
- ignored_vertices:要忽略的顶点筛选规则;
721+
- selected_edges:要同步的边筛选规则;
722+
- ignored_edges:要忽略的边筛选规则;
723+
- pd-peers:HugeGraph-PD 节点地址;
724+
- meta-endpoints:源集群 Meta服务端点;
725+
- cluster:源集群名称;
726+
- batch_size:批量读取源图数据的批次大小,默认为500;
727+
712728
##### 3.3.3 顶点和边映射
713729

714730
顶点和边映射的节点(JSON 文件中的一个 key)有很多相同的部分,下面先介绍相同部分,再分别介绍`顶点映射``边映射`的特有节点。
@@ -794,20 +810,29 @@ schema: 必填
794810
| 参数 | 默认值 | 是否必传 | 描述信息 |
795811
|---------------------------|-----------|------|-------------------------------------------------------------------|
796812
| `-f``--file` | | Y | 配置脚本的路径 |
797-
| `-g``--graph` | | Y | 图数据库空间 |
798-
| `-s``--schema` | | Y | schema 文件路径 | |
799-
| `-h``--host` | localhost | | HugeGraphServer 的地址 |
813+
| `-g``--graph` | | Y | 图名称 |
814+
| `-gs``--graphspace` | DEFAULT | | 图空间 |
815+
| `-s``--schema` | | Y | schema 文件路径 |
816+
| `-h``--host``-i` | localhost | | HugeGraphServer 的地址 |
800817
| `-p``--port` | 8080 | | HugeGraphServer 的端口号 |
801818
| `--username` | null | | 当 HugeGraphServer 开启了权限认证时,当前图的 username |
819+
| `--password` | null | | 当 HugeGraphServer 开启了权限认证时,当前图的 password |
820+
| `--create-graph` | false | | 是否在图不存在时自动创建 |
802821
| `--token` | null | | 当 HugeGraphServer 开启了权限认证时,当前图的 token |
803822
| `--protocol` | http | | 向服务端发请求的协议,可选 http 或 https |
823+
| `--pd-peers` | | | PD 服务节点地址 |
824+
| `--pd-token` | | | 访问 PD 服务的 token |
825+
| `--meta-endpoints` | | | 元信息存储服务地址 |
826+
| `--direct` | false | | 是否直连 HugeGraph-Store |
827+
| `--route-type` | NODE_PORT | | 路由选择方式(可选值:NODE_PORT / DDS / BOTH) |
828+
| `--cluster` | hg | | 集群名 |
804829
| `--trust-store-file` | | | 请求协议为 https 时,客户端的证书文件路径 |
805830
| `--trust-store-password` | | | 请求协议为 https 时,客户端证书密码 |
806831
| `--clear-all-data` | false | | 导入数据前是否清除服务端的原有数据 |
807832
| `--clear-timeout` | 240 | | 导入数据前清除服务端的原有数据的超时时间 |
808-
| `--incremental-mode` | false | | 是否使用断点续导模式,仅输入源为 FILE 和 HDFS 支持该模式,启用该模式能从上一次导入停止的地方开始导 |
833+
| `--incremental-mode` | false | | 是否使用断点续导模式,仅输入源为 FILE 和 HDFS 支持该模式,启用该模式能从上一次导入停止的地方开始导入 |
809834
| `--failure-mode` | false | | 失败模式为 true 时,会导入之前失败了的数据,一般来说失败数据文件需要在人工更正编辑好后,再次进行导入 |
810-
| `--batch-insert-threads` | CPUs | | 批量插入线程池大小 (CPUs 是当前 OS 可用可用**逻辑核**个数) |
835+
| `--batch-insert-threads` | CPUs | | 批量插入线程池大小 (CPUs 是当前 OS 可用**逻辑核**个数) |
811836
| `--single-insert-threads` | 8 | | 单条插入线程池的大小 |
812837
| `--max-conn` | 4 * CPUs | | HugeClient 与 HugeGraphServer 的最大 HTTP 连接数,**调整线程**的时候建议同时调整此项 |
813838
| `--max-conn-per-route` | 2 * CPUs | | HugeClient 与 HugeGraphServer 每个路由的最大 HTTP 连接数,**调整线程**的时候建议同时调整此项 |
@@ -821,7 +846,7 @@ schema: 必填
821846
| `--check-vertex` | false | | 插入边时是否检查边所连接的顶点是否存在 |
822847
| `--print-progress` | true | | 是否在控制台实时打印导入条数 |
823848
| `--dry-run` | false | | 打开该模式,只解析不导入,通常用于测试 |
824-
| `--help` | false | | 打印帮助信息 |
849+
| `--help` | false | | 打印帮助信息 |
825850

826851
##### 3.4.2 断点续导模式
827852

content/en/docs/clients/hugegraph-client.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ The `gremlin(groovy)` written by the user in `HugeGraph-Studio` can refer to the
1212

1313
HugeGraph-Client is the general entry for operating graph. Users must first create a HugeGraph-Client object and establish a connection (pseudo connection) with HugeGraph-Server before they can obtain the operation entry objects of schema, graph and gremlin.
1414

15-
Currently, HugeGraph-Client only allows connections to existing graphs on the server, and cannot create custom graphs. Its creation method is as follows:
15+
Currently, HugeGraph-Client only allows connections to existing graphs on the server, and cannot create custom graphs. After version 1.7.0, client has supported setting graphSpace, the default value for graphSpace is DEFAULT. Its creation method is as follows:
1616

1717
```java
1818
// HugeGraphServer address: "http://localhost:8080"
1919
// Graph Name: "hugegraph"
2020
HugeClient hugeClient = HugeClient.builder("http://localhost:8080", "hugegraph")
21+
//.builder("http://localhost:8080", "graphSpaceName", "hugegraph")
2122
.configTimeout(20) // 20s timeout
2223
.configUser("**", "**") // enable auth
2324
.build();
@@ -444,6 +445,40 @@ Edge knows1 = marko.addEdge("knows", vadas, "city", "Beijing");
444445

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

447-
### 4 Examples
448+
### 4 GraphSpace
449+
The client supports multiple GraphSpaces in one physical deployment, and each GraphSpace can contain multiple graphs.
450+
- Compatibility: When no GraphSpace is specified, the "DEFAULT" space is used by default.
451+
452+
#### 4.1 Create GraphSpace
453+
454+
```java
455+
GraphSpaceManager spaceManager = hugeClient.graphSpace();
456+
457+
// Define GraphSpace configuration
458+
GraphSpace graphSpace = new GraphSpace();
459+
graphSpace.setName("myGraphSpace");
460+
graphSpace.setDescription("Business data graph space");
461+
graphSpace.setMaxGraphNumber(10); // Maximum number of graphs
462+
graphSpace.setMaxRoleNumber(100); // Maximum number of roles
463+
464+
// Create GraphSpace
465+
spaceManager.createGraphSpace(graphSpace);
466+
```
467+
468+
#### 4.2 GraphSpace Interface Summary
469+
470+
| Category | Interface | Description |
471+
|----------|-----------|-------------|
472+
| Manager - Query | listGraphSpace() | Get the list of all GraphSpaces |
473+
| | getGraphSpace(String name) | Get the specified GraphSpace |
474+
| Manager - Create/Update | createGraphSpace(GraphSpace) | Create a GraphSpace |
475+
| | updateGraphSpace(String, GraphSpace) | Update configuration |
476+
| Manager - Delete | removeGraphSpace(String) | Delete the specified GraphSpace |
477+
| GraphSpace - Properties | getName() / getDescription() | Get name / description |
478+
| | getGraphNumber() | Get the number of graphs |
479+
| GraphSpace - Configuration | setDescription(String) | Set description |
480+
| | setMaxGraphNumber(int) | Set the maximum number of graphs |
481+
482+
### 5 Simple Example
448483

449484
Simple examples can reference [HugeGraph-Client](/docs/quickstart/client/hugegraph-client)

content/en/docs/quickstart/client/hugegraph-client.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Using IDEA or Eclipse to create the project:
4444
<groupId>org.apache.hugegraph</groupId>
4545
<artifactId>hugegraph-client</artifactId>
4646
<!-- Update to the latest release version -->
47-
<version>1.5.0</version>
47+
<version>1.7.0</version>
4848
</dependency>
4949
</dependencies>
5050
```
@@ -75,7 +75,10 @@ public class SingleExample {
7575
public static void main(String[] args) throws IOException {
7676
// If connect failed will throw a exception.
7777
HugeClient hugeClient = HugeClient.builder("http://localhost:8080",
78+
"DEFAULT",
7879
"hugegraph")
80+
.configUser("username", "password")
81+
// This is an example. In a production environment, secure credentials should be used.
7982
.build();
8083

8184
SchemaManager schema = hugeClient.schema();
@@ -218,9 +221,11 @@ import org.apache.hugegraph.structure.graph.Vertex;
218221
public class BatchExample {
219222

220223
public static void main(String[] args) {
221-
// If connect failed will throw a exception.
222224
HugeClient hugeClient = HugeClient.builder("http://localhost:8080",
225+
"DEFAULT",
223226
"hugegraph")
227+
.configUser("username", "password")
228+
// This is an example. In a production environment, secure credentials should be used.
224229
.build();
225230

226231
SchemaManager schema = hugeClient.schema();
@@ -344,11 +349,10 @@ public class BatchExample {
344349
}
345350
```
346351

347-
### 4.4 Run The Example
352+
#### 4.4 Run The Example
348353

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

351-
### 4.5 More Information About Client-API
356+
#### 4.5 More Information About Client-API
352357

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

0 commit comments

Comments
 (0)