imbajin commented on code in PR #464: URL: https://github.com/apache/hugegraph-doc/pull/464#discussion_r4000530159
########## content/cn/docs/quickstart/toolchain/hugegraph-seatunnel-connector.md: ########## @@ -0,0 +1,439 @@ +--- +title: "HugeGraph-SeaTunnel Connector Quick Start" +linkTitle: "使用 SeaTunnel Connector 同步数据" +weight: 5 +--- + +<!-- + TODO(apache/hugegraph-doc#464):本文 SeaTunnel 官方文档链接暂指向 latest(无版本号)页面。 + HugeGraph Source Connector 尚未随正式版本发布,官网 latest 无对应页面, + 故 Source 文档链接暂指向 GitHub dev 分支文件。 + 待 Source 随正式版本发布后,将链接切换为官网版本化地址, + 例如 https://seatunnel.apache.org/docs/2.3.14/connectors/source/HugeGraph/ +--> + +### 1 版本与兼容性 + +| 组件 | 版本要求 | 说明 | +|------|---------|------| +| Java | 11+ | HugeGraph Client 1.5.0+ 运行环境要求 | +| Apache SeaTunnel | 2.3.13+ | Sink 自 2.3.12 合入;2.3.13 起内置 HugeGraph Client 1.5.0 | +| HugeGraph Server | 1.5.0+ | 需与 Connector 内置 Client 版本匹配 | + +> Source Connector 目前只在 SeaTunnel next(dev)分支,正式版还没带。要用就从源码编译,或等下一个 Release;next 分支内置的 HugeGraph Client 已升到 1.7.0,需搭配对应版本的 Server。 + +### 2 概述 + +[Apache SeaTunnel](https://seatunnel.apache.org/) 是开源数据集成平台,批处理、流式同步都支持,自带 100+ 连接器。HugeGraph 的 Connector-V2 已合入:Sink 负责写入(顶点/边的批量写入、更新、删除),Source 负责读取(批量读取、整图迁移)。 + + + +### 3 选型:SeaTunnel 还是 Loader + +可以把 SeaTunnel 理解为 [Loader](/cn/docs/quickstart/toolchain/hugegraph-loader) + [Tools](/cn/docs/quickstart/toolchain/hugegraph-tools) 的合集。两者不冲突:Loader 只管 HugeGraph,开箱即用;SeaTunnel 面向所有数据系统。按场景选: + +| 你的场景 | 推荐 | 理由 | +|---------|------|------| +| 一次性 / 定时把本地文件、HDFS、MySQL 等导入 HugeGraph | Loader | 免部署,映射文件即写即用 | +| 数据已在(或必须经过)Flink、Spark、Kafka 等大数据管道 | SeaTunnel | 复用现有管道,不引入第二套导入工具 | +| 实时流式导入、CDC 增量同步 | SeaTunnel | 原生流式作业 + checkpoint 断点恢复 | +| 导入时自动创建 Schema(PropertyKey / VertexLabel / EdgeLabel) | SeaTunnel | Sink 默认 `CREATE_SCHEMA_WHEN_NOT_EXIST` | +| 只维护 HugeGraph 一张图,规模可控、追求简单 | Loader | 工具链内闭环,无额外集群 | + +选 SeaTunnel 要接受两点:部署一套 SeaTunnel 集群(或复用现有的),作业用通用 HOCON 配置,而不是 HugeGraph 映射文件。 + +### 4 快速开始 + +前置条件:HugeGraph Server 1.5.0+([部署指南](/cn/docs/quickstart/hugegraph/hugegraph-server))。 + +#### 4.1 部署 SeaTunnel + +**Docker(推荐)**。拉取镜像,把作业配置所在目录挂载进容器提交,宿主机不用装 Java 环境: + +```bash +docker pull apache/seatunnel:2.3.13 + +docker run --rm -it \ + -v /path/to/job:/config \ + apache/seatunnel:2.3.13 \ + ./bin/seatunnel.sh -e local -c /config/hugegraph-sync.conf +``` + +更多用法见官方 [Docker 部署文档](https://seatunnel.apache.org/docs/getting-started/docker/docker/)。 + +**Kubernetes**:生产集群用 Helm 部署,见官方 [K8s(Helm)部署文档](https://seatunnel.apache.org/docs/getting-started/kubernetes/helm/)。 + +**二进制包(参考)**:从 [下载页](https://seatunnel.apache.org/download/) 取安装包,解压后装插件、跑脚本。JVM 脚本方式仅作本地调试参考,生产优先 Docker / K8s: + +```bash +sh bin/install-plugin.sh 2.3.13 +sh bin/seatunnel.sh --config ./config/hugegraph-sync.conf -e local +``` + +部署细节以官方 [本地部署文档](https://seatunnel.apache.org/docs/getting-started/locally/deployment/) 为准。 + +#### 4.2 最小示例:CSV 文件 → person 顶点 + +准备一个无表头的 CSV(列顺序与 `schema.fields` 声明顺序一致),内容如下: + +```csv +marko,29 +vadas,27 +josh,32 +``` + +```hocon +env { + job.mode = "BATCH" +} + +source { + LocalFile { + path = "/data/person.csv" + file_format_type = "csv" + schema = { + fields = { + name = "string" + age = "int" + } + } + } +} + +sink { + HugeGraph { + host = "127.0.0.1" + port = 8080 + graph_name = "hugegraph" + graph_space = "DEFAULT" + # 以下为可选参数,默认值见第 6 节;认证开启时再填 username/password + # protocol = "http" + # username = "admin" + # password = "admin" + # schema_save_mode = CREATE_SCHEMA_WHEN_NOT_EXIST + mappings = [ Review Comment: Fixed: the whole guide now targets SeaTunnel 3.0+ dev, pinned to 35b2716cde7d4c91a24fc618a8d9cae90e213db3 (3.0.0-SNAPSHOT). All five jobs use mappings. The opening warning and version table explicitly state that 2.3.13 only has Sink and uses schema_config. Updated in 1cde03e0fba7cc5a3e76d7a326759eefa874467f. ########## content/cn/docs/quickstart/toolchain/hugegraph-seatunnel-connector.md: ########## @@ -0,0 +1,439 @@ +--- +title: "HugeGraph-SeaTunnel Connector Quick Start" +linkTitle: "使用 SeaTunnel Connector 同步数据" +weight: 5 +--- + +<!-- + TODO(apache/hugegraph-doc#464):本文 SeaTunnel 官方文档链接暂指向 latest(无版本号)页面。 + HugeGraph Source Connector 尚未随正式版本发布,官网 latest 无对应页面, + 故 Source 文档链接暂指向 GitHub dev 分支文件。 + 待 Source 随正式版本发布后,将链接切换为官网版本化地址, + 例如 https://seatunnel.apache.org/docs/2.3.14/connectors/source/HugeGraph/ +--> + +### 1 版本与兼容性 + +| 组件 | 版本要求 | 说明 | +|------|---------|------| +| Java | 11+ | HugeGraph Client 1.5.0+ 运行环境要求 | +| Apache SeaTunnel | 2.3.13+ | Sink 自 2.3.12 合入;2.3.13 起内置 HugeGraph Client 1.5.0 | +| HugeGraph Server | 1.5.0+ | 需与 Connector 内置 Client 版本匹配 | + +> Source Connector 目前只在 SeaTunnel next(dev)分支,正式版还没带。要用就从源码编译,或等下一个 Release;next 分支内置的 HugeGraph Client 已升到 1.7.0,需搭配对应版本的 Server。 + +### 2 概述 + +[Apache SeaTunnel](https://seatunnel.apache.org/) 是开源数据集成平台,批处理、流式同步都支持,自带 100+ 连接器。HugeGraph 的 Connector-V2 已合入:Sink 负责写入(顶点/边的批量写入、更新、删除),Source 负责读取(批量读取、整图迁移)。 + + + +### 3 选型:SeaTunnel 还是 Loader + +可以把 SeaTunnel 理解为 [Loader](/cn/docs/quickstart/toolchain/hugegraph-loader) + [Tools](/cn/docs/quickstart/toolchain/hugegraph-tools) 的合集。两者不冲突:Loader 只管 HugeGraph,开箱即用;SeaTunnel 面向所有数据系统。按场景选: + +| 你的场景 | 推荐 | 理由 | +|---------|------|------| +| 一次性 / 定时把本地文件、HDFS、MySQL 等导入 HugeGraph | Loader | 免部署,映射文件即写即用 | +| 数据已在(或必须经过)Flink、Spark、Kafka 等大数据管道 | SeaTunnel | 复用现有管道,不引入第二套导入工具 | +| 实时流式导入、CDC 增量同步 | SeaTunnel | 原生流式作业 + checkpoint 断点恢复 | +| 导入时自动创建 Schema(PropertyKey / VertexLabel / EdgeLabel) | SeaTunnel | Sink 默认 `CREATE_SCHEMA_WHEN_NOT_EXIST` | +| 只维护 HugeGraph 一张图,规模可控、追求简单 | Loader | 工具链内闭环,无额外集群 | + +选 SeaTunnel 要接受两点:部署一套 SeaTunnel 集群(或复用现有的),作业用通用 HOCON 配置,而不是 HugeGraph 映射文件。 + +### 4 快速开始 + +前置条件:HugeGraph Server 1.5.0+([部署指南](/cn/docs/quickstart/hugegraph/hugegraph-server))。 + +#### 4.1 部署 SeaTunnel + +**Docker(推荐)**。拉取镜像,把作业配置所在目录挂载进容器提交,宿主机不用装 Java 环境: + +```bash +docker pull apache/seatunnel:2.3.13 Review Comment: Fixed by removing the incompatible 2.3.13 Docker path. Setup now uses a pinned dev source build with JDK 11, matching engine/connector artifacts, and the MySQL driver location for Zeta. No ready-to-run Docker image is claimed. Updated in 1cde03e0fba7cc5a3e76d7a326759eefa874467f. ########## content/cn/docs/quickstart/toolchain/hugegraph-seatunnel-connector.md: ########## @@ -0,0 +1,439 @@ +--- +title: "HugeGraph-SeaTunnel Connector Quick Start" +linkTitle: "使用 SeaTunnel Connector 同步数据" +weight: 5 +--- + +<!-- + TODO(apache/hugegraph-doc#464):本文 SeaTunnel 官方文档链接暂指向 latest(无版本号)页面。 + HugeGraph Source Connector 尚未随正式版本发布,官网 latest 无对应页面, + 故 Source 文档链接暂指向 GitHub dev 分支文件。 + 待 Source 随正式版本发布后,将链接切换为官网版本化地址, + 例如 https://seatunnel.apache.org/docs/2.3.14/connectors/source/HugeGraph/ +--> + +### 1 版本与兼容性 + +| 组件 | 版本要求 | 说明 | +|------|---------|------| +| Java | 11+ | HugeGraph Client 1.5.0+ 运行环境要求 | +| Apache SeaTunnel | 2.3.13+ | Sink 自 2.3.12 合入;2.3.13 起内置 HugeGraph Client 1.5.0 | +| HugeGraph Server | 1.5.0+ | 需与 Connector 内置 Client 版本匹配 | + +> Source Connector 目前只在 SeaTunnel next(dev)分支,正式版还没带。要用就从源码编译,或等下一个 Release;next 分支内置的 HugeGraph Client 已升到 1.7.0,需搭配对应版本的 Server。 + +### 2 概述 + +[Apache SeaTunnel](https://seatunnel.apache.org/) 是开源数据集成平台,批处理、流式同步都支持,自带 100+ 连接器。HugeGraph 的 Connector-V2 已合入:Sink 负责写入(顶点/边的批量写入、更新、删除),Source 负责读取(批量读取、整图迁移)。 + + + +### 3 选型:SeaTunnel 还是 Loader + +可以把 SeaTunnel 理解为 [Loader](/cn/docs/quickstart/toolchain/hugegraph-loader) + [Tools](/cn/docs/quickstart/toolchain/hugegraph-tools) 的合集。两者不冲突:Loader 只管 HugeGraph,开箱即用;SeaTunnel 面向所有数据系统。按场景选: + +| 你的场景 | 推荐 | 理由 | +|---------|------|------| +| 一次性 / 定时把本地文件、HDFS、MySQL 等导入 HugeGraph | Loader | 免部署,映射文件即写即用 | +| 数据已在(或必须经过)Flink、Spark、Kafka 等大数据管道 | SeaTunnel | 复用现有管道,不引入第二套导入工具 | +| 实时流式导入、CDC 增量同步 | SeaTunnel | 原生流式作业 + checkpoint 断点恢复 | +| 导入时自动创建 Schema(PropertyKey / VertexLabel / EdgeLabel) | SeaTunnel | Sink 默认 `CREATE_SCHEMA_WHEN_NOT_EXIST` | +| 只维护 HugeGraph 一张图,规模可控、追求简单 | Loader | 工具链内闭环,无额外集群 | + +选 SeaTunnel 要接受两点:部署一套 SeaTunnel 集群(或复用现有的),作业用通用 HOCON 配置,而不是 HugeGraph 映射文件。 + +### 4 快速开始 + +前置条件:HugeGraph Server 1.5.0+([部署指南](/cn/docs/quickstart/hugegraph/hugegraph-server))。 + +#### 4.1 部署 SeaTunnel + +**Docker(推荐)**。拉取镜像,把作业配置所在目录挂载进容器提交,宿主机不用装 Java 环境: + +```bash +docker pull apache/seatunnel:2.3.13 + +docker run --rm -it \ + -v /path/to/job:/config \ + apache/seatunnel:2.3.13 \ + ./bin/seatunnel.sh -e local -c /config/hugegraph-sync.conf +``` + +更多用法见官方 [Docker 部署文档](https://seatunnel.apache.org/docs/getting-started/docker/docker/)。 + +**Kubernetes**:生产集群用 Helm 部署,见官方 [K8s(Helm)部署文档](https://seatunnel.apache.org/docs/getting-started/kubernetes/helm/)。 + +**二进制包(参考)**:从 [下载页](https://seatunnel.apache.org/download/) 取安装包,解压后装插件、跑脚本。JVM 脚本方式仅作本地调试参考,生产优先 Docker / K8s: + +```bash +sh bin/install-plugin.sh 2.3.13 +sh bin/seatunnel.sh --config ./config/hugegraph-sync.conf -e local +``` + +部署细节以官方 [本地部署文档](https://seatunnel.apache.org/docs/getting-started/locally/deployment/) 为准。 + +#### 4.2 最小示例:CSV 文件 → person 顶点 + +准备一个无表头的 CSV(列顺序与 `schema.fields` 声明顺序一致),内容如下: + +```csv +marko,29 +vadas,27 +josh,32 +``` + +```hocon +env { + job.mode = "BATCH" +} + +source { + LocalFile { + path = "/data/person.csv" + file_format_type = "csv" + schema = { + fields = { + name = "string" + age = "int" + } + } + } +} + +sink { + HugeGraph { + host = "127.0.0.1" Review Comment: Fixed: all jobs use separate service hostnames and ports, and the setup section explains reachable addresses and container loopback. Readers must replace the placeholder hosts for their environment. Updated in 1cde03e0fba7cc5a3e76d7a326759eefa874467f. ########## content/cn/docs/quickstart/toolchain/hugegraph-seatunnel-connector.md: ########## @@ -0,0 +1,439 @@ +--- +title: "HugeGraph-SeaTunnel Connector Quick Start" +linkTitle: "使用 SeaTunnel Connector 同步数据" +weight: 5 +--- + +<!-- + TODO(apache/hugegraph-doc#464):本文 SeaTunnel 官方文档链接暂指向 latest(无版本号)页面。 + HugeGraph Source Connector 尚未随正式版本发布,官网 latest 无对应页面, + 故 Source 文档链接暂指向 GitHub dev 分支文件。 + 待 Source 随正式版本发布后,将链接切换为官网版本化地址, + 例如 https://seatunnel.apache.org/docs/2.3.14/connectors/source/HugeGraph/ +--> + +### 1 版本与兼容性 + +| 组件 | 版本要求 | 说明 | +|------|---------|------| +| Java | 11+ | HugeGraph Client 1.5.0+ 运行环境要求 | +| Apache SeaTunnel | 2.3.13+ | Sink 自 2.3.12 合入;2.3.13 起内置 HugeGraph Client 1.5.0 | +| HugeGraph Server | 1.5.0+ | 需与 Connector 内置 Client 版本匹配 | + +> Source Connector 目前只在 SeaTunnel next(dev)分支,正式版还没带。要用就从源码编译,或等下一个 Release;next 分支内置的 HugeGraph Client 已升到 1.7.0,需搭配对应版本的 Server。 + +### 2 概述 + +[Apache SeaTunnel](https://seatunnel.apache.org/) 是开源数据集成平台,批处理、流式同步都支持,自带 100+ 连接器。HugeGraph 的 Connector-V2 已合入:Sink 负责写入(顶点/边的批量写入、更新、删除),Source 负责读取(批量读取、整图迁移)。 + + + +### 3 选型:SeaTunnel 还是 Loader + +可以把 SeaTunnel 理解为 [Loader](/cn/docs/quickstart/toolchain/hugegraph-loader) + [Tools](/cn/docs/quickstart/toolchain/hugegraph-tools) 的合集。两者不冲突:Loader 只管 HugeGraph,开箱即用;SeaTunnel 面向所有数据系统。按场景选: + +| 你的场景 | 推荐 | 理由 | +|---------|------|------| +| 一次性 / 定时把本地文件、HDFS、MySQL 等导入 HugeGraph | Loader | 免部署,映射文件即写即用 | +| 数据已在(或必须经过)Flink、Spark、Kafka 等大数据管道 | SeaTunnel | 复用现有管道,不引入第二套导入工具 | +| 实时流式导入、CDC 增量同步 | SeaTunnel | 原生流式作业 + checkpoint 断点恢复 | +| 导入时自动创建 Schema(PropertyKey / VertexLabel / EdgeLabel) | SeaTunnel | Sink 默认 `CREATE_SCHEMA_WHEN_NOT_EXIST` | +| 只维护 HugeGraph 一张图,规模可控、追求简单 | Loader | 工具链内闭环,无额外集群 | + +选 SeaTunnel 要接受两点:部署一套 SeaTunnel 集群(或复用现有的),作业用通用 HOCON 配置,而不是 HugeGraph 映射文件。 + +### 4 快速开始 + +前置条件:HugeGraph Server 1.5.0+([部署指南](/cn/docs/quickstart/hugegraph/hugegraph-server))。 + +#### 4.1 部署 SeaTunnel + +**Docker(推荐)**。拉取镜像,把作业配置所在目录挂载进容器提交,宿主机不用装 Java 环境: + +```bash +docker pull apache/seatunnel:2.3.13 + +docker run --rm -it \ + -v /path/to/job:/config \ + apache/seatunnel:2.3.13 \ + ./bin/seatunnel.sh -e local -c /config/hugegraph-sync.conf +``` + +更多用法见官方 [Docker 部署文档](https://seatunnel.apache.org/docs/getting-started/docker/docker/)。 + +**Kubernetes**:生产集群用 Helm 部署,见官方 [K8s(Helm)部署文档](https://seatunnel.apache.org/docs/getting-started/kubernetes/helm/)。 + +**二进制包(参考)**:从 [下载页](https://seatunnel.apache.org/download/) 取安装包,解压后装插件、跑脚本。JVM 脚本方式仅作本地调试参考,生产优先 Docker / K8s: + +```bash +sh bin/install-plugin.sh 2.3.13 +sh bin/seatunnel.sh --config ./config/hugegraph-sync.conf -e local +``` + +部署细节以官方 [本地部署文档](https://seatunnel.apache.org/docs/getting-started/locally/deployment/) 为准。 + +#### 4.2 最小示例:CSV 文件 → person 顶点 + +准备一个无表头的 CSV(列顺序与 `schema.fields` 声明顺序一致),内容如下: + +```csv +marko,29 +vadas,27 +josh,32 +``` + +```hocon +env { + job.mode = "BATCH" +} + +source { + LocalFile { + path = "/data/person.csv" + file_format_type = "csv" + schema = { + fields = { + name = "string" + age = "int" + } + } + } +} + +sink { + HugeGraph { + host = "127.0.0.1" + port = 8080 + graph_name = "hugegraph" + graph_space = "DEFAULT" + # 以下为可选参数,默认值见第 6 节;认证开启时再填 username/password + # protocol = "http" + # username = "admin" + # password = "admin" + # schema_save_mode = CREATE_SCHEMA_WHEN_NOT_EXIST + mappings = [ + { + type = "VERTEX" + label = "person" + idStrategy = "PRIMARY_KEY" + idFields = ["name"] + properties = ["name", "age"] + } + ] + } +} +``` + +一行 CSV 到图顶点的映射过程: + +```text +┌───────────────── 输入行 (SeaTunnel Row) ─────────────────┐ +│ name = "marko" age = 29 │ +└──────────────────────────┬───────────────────────────────┘ + │ mappings: + │ type = VERTEX, label = person + │ idStrategy = PRIMARY_KEY, idFields = [name] + ▼ + ┌───────────────────────────────┐ + │ HugeGraph 顶点 │ + │ id = person:marko │ + │ label = person │ + │ props = { age: 29 } │ Review Comment: Fixed: the misleading result diagram was removed. The model and vertex mappings include both name and age, and the result query checks both properties. Actual dev mapper tests confirm PRIMARY_KEY fields remain properties. Updated in 1cde03e0fba7cc5a3e76d7a326759eefa874467f. ########## content/cn/docs/quickstart/toolchain/hugegraph-seatunnel-connector.md: ########## @@ -0,0 +1,439 @@ +--- +title: "HugeGraph-SeaTunnel Connector Quick Start" +linkTitle: "使用 SeaTunnel Connector 同步数据" +weight: 5 +--- + +<!-- + TODO(apache/hugegraph-doc#464):本文 SeaTunnel 官方文档链接暂指向 latest(无版本号)页面。 + HugeGraph Source Connector 尚未随正式版本发布,官网 latest 无对应页面, + 故 Source 文档链接暂指向 GitHub dev 分支文件。 + 待 Source 随正式版本发布后,将链接切换为官网版本化地址, + 例如 https://seatunnel.apache.org/docs/2.3.14/connectors/source/HugeGraph/ +--> + +### 1 版本与兼容性 + +| 组件 | 版本要求 | 说明 | +|------|---------|------| +| Java | 11+ | HugeGraph Client 1.5.0+ 运行环境要求 | +| Apache SeaTunnel | 2.3.13+ | Sink 自 2.3.12 合入;2.3.13 起内置 HugeGraph Client 1.5.0 | +| HugeGraph Server | 1.5.0+ | 需与 Connector 内置 Client 版本匹配 | + +> Source Connector 目前只在 SeaTunnel next(dev)分支,正式版还没带。要用就从源码编译,或等下一个 Release;next 分支内置的 HugeGraph Client 已升到 1.7.0,需搭配对应版本的 Server。 + +### 2 概述 + +[Apache SeaTunnel](https://seatunnel.apache.org/) 是开源数据集成平台,批处理、流式同步都支持,自带 100+ 连接器。HugeGraph 的 Connector-V2 已合入:Sink 负责写入(顶点/边的批量写入、更新、删除),Source 负责读取(批量读取、整图迁移)。 + + + +### 3 选型:SeaTunnel 还是 Loader + +可以把 SeaTunnel 理解为 [Loader](/cn/docs/quickstart/toolchain/hugegraph-loader) + [Tools](/cn/docs/quickstart/toolchain/hugegraph-tools) 的合集。两者不冲突:Loader 只管 HugeGraph,开箱即用;SeaTunnel 面向所有数据系统。按场景选: + +| 你的场景 | 推荐 | 理由 | +|---------|------|------| +| 一次性 / 定时把本地文件、HDFS、MySQL 等导入 HugeGraph | Loader | 免部署,映射文件即写即用 | +| 数据已在(或必须经过)Flink、Spark、Kafka 等大数据管道 | SeaTunnel | 复用现有管道,不引入第二套导入工具 | +| 实时流式导入、CDC 增量同步 | SeaTunnel | 原生流式作业 + checkpoint 断点恢复 | +| 导入时自动创建 Schema(PropertyKey / VertexLabel / EdgeLabel) | SeaTunnel | Sink 默认 `CREATE_SCHEMA_WHEN_NOT_EXIST` | +| 只维护 HugeGraph 一张图,规模可控、追求简单 | Loader | 工具链内闭环,无额外集群 | + +选 SeaTunnel 要接受两点:部署一套 SeaTunnel 集群(或复用现有的),作业用通用 HOCON 配置,而不是 HugeGraph 映射文件。 + +### 4 快速开始 + +前置条件:HugeGraph Server 1.5.0+([部署指南](/cn/docs/quickstart/hugegraph/hugegraph-server))。 + +#### 4.1 部署 SeaTunnel + +**Docker(推荐)**。拉取镜像,把作业配置所在目录挂载进容器提交,宿主机不用装 Java 环境: + +```bash +docker pull apache/seatunnel:2.3.13 + +docker run --rm -it \ + -v /path/to/job:/config \ + apache/seatunnel:2.3.13 \ + ./bin/seatunnel.sh -e local -c /config/hugegraph-sync.conf +``` + +更多用法见官方 [Docker 部署文档](https://seatunnel.apache.org/docs/getting-started/docker/docker/)。 + +**Kubernetes**:生产集群用 Helm 部署,见官方 [K8s(Helm)部署文档](https://seatunnel.apache.org/docs/getting-started/kubernetes/helm/)。 + +**二进制包(参考)**:从 [下载页](https://seatunnel.apache.org/download/) 取安装包,解压后装插件、跑脚本。JVM 脚本方式仅作本地调试参考,生产优先 Docker / K8s: + +```bash +sh bin/install-plugin.sh 2.3.13 +sh bin/seatunnel.sh --config ./config/hugegraph-sync.conf -e local +``` + +部署细节以官方 [本地部署文档](https://seatunnel.apache.org/docs/getting-started/locally/deployment/) 为准。 + +#### 4.2 最小示例:CSV 文件 → person 顶点 + +准备一个无表头的 CSV(列顺序与 `schema.fields` 声明顺序一致),内容如下: + +```csv +marko,29 +vadas,27 +josh,32 +``` + +```hocon +env { + job.mode = "BATCH" +} + +source { + LocalFile { + path = "/data/person.csv" + file_format_type = "csv" + schema = { + fields = { + name = "string" + age = "int" + } + } + } +} + +sink { + HugeGraph { + host = "127.0.0.1" + port = 8080 + graph_name = "hugegraph" + graph_space = "DEFAULT" + # 以下为可选参数,默认值见第 6 节;认证开启时再填 username/password + # protocol = "http" + # username = "admin" + # password = "admin" + # schema_save_mode = CREATE_SCHEMA_WHEN_NOT_EXIST + mappings = [ + { + type = "VERTEX" + label = "person" + idStrategy = "PRIMARY_KEY" + idFields = ["name"] + properties = ["name", "age"] + } + ] + } +} +``` + +一行 CSV 到图顶点的映射过程: + +```text +┌───────────────── 输入行 (SeaTunnel Row) ─────────────────┐ +│ name = "marko" age = 29 │ +└──────────────────────────┬───────────────────────────────┘ + │ mappings: + │ type = VERTEX, label = person + │ idStrategy = PRIMARY_KEY, idFields = [name] + ▼ + ┌───────────────────────────────┐ + │ HugeGraph 顶点 │ + │ id = person:marko │ + │ label = person │ + │ props = { age: 29 } │ + └───────────────────────────────┘ +``` + +#### 4.3 运行与验证 + +```bash +# 配置和 CSV 分别挂载进容器;路径换成你机器上的实际目录 +docker run --rm -it \ + -v /path/to/job:/config \ + -v /path/to/data:/data \ + apache/seatunnel:2.3.13 \ + ./bin/seatunnel.sh -e local -c /config/hugegraph-sync.conf +``` + +运行后,在 Hubble 或 REST API 里执行这条 Gremlin 验证: + +```groovy +g.V().hasLabel('person').valueMap() +``` + +> **Schema 说明**:`mappings` 模式下默认 `schema_save_mode = CREATE_SCHEMA_WHEN_NOT_EXIST`,写入前自动补建缺失的 PropertyKey / VertexLabel / EdgeLabel。要严格管控就自己先建 Schema,并设 `ERROR_WHEN_SCHEMA_NOT_EXIST`。 + +#### 4.4 写入边 + +关系行到边的映射同样通过 `mappings` 完成,用 `sourceConfig` / `targetConfig` 还原边的两个端点。 + +<details> +<summary>展开查看:关系 CSV → knows 边 完整配置</summary> + +CSV(无表头): + +```csv +marko,vadas,2020 +marko,josh,2021 +``` + +```hocon +env { + job.mode = "BATCH" +} + +source { + LocalFile { + path = "/data/knows.csv" + file_format_type = "csv" + schema = { + fields = { + person1_name = "string" + person2_name = "string" + since = "int" + } + } + } +} + +sink { + HugeGraph { + host = "127.0.0.1" + port = 8080 + graph_name = "hugegraph" + graph_space = "DEFAULT" + mappings = [ + { + type = "EDGE" + label = "knows" + sourceConfig = { + label = "person" + idFields = ["person1_name"] + } + targetConfig = { + label = "person" + idFields = ["person2_name"] + } + properties = ["since"] + fieldMapping = { + person1_name = "name" + person2_name = "name" + } + } + ] + } +} +``` + +</details> + +```text +person1_name = "marko" person2_name = "vadas" since = 2020 + │ │ + ▼ ▼ + sourceConfig targetConfig + label = person label = person + idFields = [person1_name] idFields = [person2_name] + └───────────┬────────────┘ + ▼ + edge: person:marko -[knows]-> person:vadas + properties = { since: 2020 } +``` + +> 边的端点 ID 策略从服务端已有的 VertexLabel 读取,`sourceConfig.idFields` / `targetConfig.idFields` 必须能拼出端点 ID。默认 `check_vertex = false`,顶点和边允许乱序写入,跑完图最终一致;设成 `true` 则服务端直接拒绝端点不存在的边。 Review Comment: Fixed: both edge jobs load vertices first, set check_vertex=true, and disable batch_failure_fallback so rejected writes fail the job. The guide explicitly warns that the default does not guarantee eventual consistency and can leave orphan edges. Updated in 1cde03e0fba7cc5a3e76d7a326759eefa874467f. -- 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]
