GitHub user wangzhewwzz added a comment to the discussion: 关于电网拓扑数据导入
您好 我刚发了两个邮件,前面那个有三个附件麻烦您查看一下
原始邮件
发件人:dosubot[bot] ***@***.***>
发件时间:2025年12月9日 12:01
收件人:apache/incubator-hugegraph ***@***.***>
抄送:wangzhewwzz ***@***.***>, Mention ***@***.***>
主题:Re: [apache/incubator-hugegraph] 关于电网拓扑数据导入 (Discussion #2917)
你的理解基本正确,但有两个关键点需要注意,否则会导致关系不全:
value_mapping 的作用
value_mapping 只是把 CSV 某一列的值(如 label/source_label/target_label)映射为你
schema.groovy 里定义的 edgeLabel 或属性值。它本身不会过滤行,只是把值替换后再尝试导入。如果 CSV 里没有
source_label/target_label 字段,或者内容不对,edgeLabel 还是会尝试导入所有行,但只有源/目标顶点 label 和
schema 里的 sourceLabel/targetLabel 完全匹配时才会真正导入成功,否则会被静默跳过(不会报错,但关系缺失)参考。
CSV 必须有 source_label/target_label 字段且内容正确
你写 "source_label": { "LineSegment": "LineSegment" }, "target_label": {
"LineSegment": "LineSegment" },前提是 edge_connected_to.csv 里有
source_label/target_label 两列,且 from/to 对应的顶点类型已经写进去了。例如:
id,from,to,label,source_label,target_label
edge_1,XLD-3445,HWX-3087,CONNECTED_TO,LineSegment,StationHouse
edge_2,HWX-3087,XLD-3258,CONNECTED_TO,StationHouse,LineSegment ...
这样 struct.json 里每个 edgeLabel 的 value_mapping 才能精确筛选属于自己的那部分边,否则会被跳过。
每种类型的边都要写一段 edgeLabel 配置
比如
LineSegment2LineSegment、LineSegment2StationHouse、StationHouse2LineSegment、LineSegment2LineSwitch、LineSwitch2LineSegment、Substation2LineSegment、LineSegment2Substation
等,每种都要写一段,且 value_mapping 里的 label/source_label/target_label 都要和 schema.groovy
里的 edgeLabel、sourceLabel、targetLabel 完全一致。
典型配置示例:
{ "label": "LineSegment2StationHouse", "source": ["from"],
"target": ["to"], "input": { "type": "file", "path":
"/loader/power_data/edge_connected_to.csv", "format": "CSV", "header": ["id",
"from", "to", "label", "source_label", "target_label"] },
"field_mapping": { "from": "id", "to": "id" }, "value_mapping": {
"label": { "CONNECTED_TO": "LineSegment2StationHouse" },
"source_label": { "LineSegment": "LineSegment" },
"target_label": { "StationHouse": "StationHouse" } } }
每种类型的边都要写一段,path 可以都指向同一个 CSV 文件。
建议:
检查 edge_connected_to.csv 是否有 source_label/target_label 字段,且内容和顶点 label 一致。
检查 struct.json 里每个 edgeLabel 的 value_mapping 是否和 schema.groovy 完全一致。
导入后用 REST API 查询各类边的数量和类型,验证关系是否齐全。
如还有问题,可以贴出一小段 edge_connected_to.csv 和 struct.json 的完整 edge 配置,我可以帮你逐条检查。
详细机制见源码说明。
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose |
Hallucination | Report 🐛 | Other
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
GitHub link:
https://github.com/apache/incubator-hugegraph/discussions/2917#discussioncomment-15204370
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]