GitHub user wangzhewwzz added a comment to the discussion: 关于电网拓扑数据导入
power_edges_to.csv :
id,from,to,label,source_label,target_label
edge_1,BDZ-3002,XLD-3445,CONNECTED_TO,Substation,LineSegment
edge_2,XLD-3445,BDZ-3002,CONNECTED_TO,LineSegment,Substation
edge_3,XLD-3445,HWX-3087,CONNECTED_TO,LineSegment,StationHouse
edge_4,HWX-3087,XLD-3445,CONNECTED_TO,StationHouse,LineSegment
edge_5,HWX-3087,XLD-3258,CONNECTED_TO,StationHouse,LineSegment
edge_6,HWX-3087,XLD-3455,CONNECTED_TO,StationHouse,LineSegment
edge_7,XLD-3258,HWX-3087,CONNECTED_TO,LineSegment,StationHouse
edge_8,XLD-3258,HWX-3109,CONNECTED_TO,LineSegment,StationHouse
edge_9,XLD-3455,HWX-3087,CONNECTED_TO,LineSegment,StationHouse
edge_10,XLD-3455,XLKG-3019,CONNECTED_TO,LineSegment,LineSwitch
edge_11,HWX-3109,XLD-3258,CONNECTED_TO,StationHouse,LineSegment
edge_12,HWX-3109,XLD-3673,CONNECTED_TO,StationHouse,LineSegment
edge_13,HWX-3109,XLD-3699,CONNECTED_TO,StationHouse,LineSegment
edge_14,HWX-3109,XLD-3505,CONNECTED_TO,StationHouse,LineSegment
edge_15,XLKG-3019,XLD-3455,CONNECTED_TO,LineSwitch,LineSegment
edge_16,XLKG-3019,XLD-3724,CONNECTED_TO,LineSwitch,LineSegment
edge_17,XLD-3673,HWX-3109,CONNECTED_TO,LineSegment,StationHouse
edge_18,XLD-3673,XB-3047,CONNECTED_TO,LineSegment,StationHouse
edge_19,XLD-3699,HWX-3109,CONNECTED_TO,LineSegment,StationHouse
edge_20,XLD-3699,HWX-3112,CONNECTED_TO,LineSegment,StationHouse
edge_21,XLD-3505,HWX-3109,CONNECTED_TO,LineSegment,StationHouse
edge_22,XLD-3505,XB-3091,CONNECTED_TO,LineSegment,StationHouse
edge_23,XLD-3724,XLKG-3019,CONNECTED_TO,LineSegment,LineSwitch
edge_24,XLD-3724,XLD-3721,CONNECTED_TO,LineSegment,LineSegment
edge_25,XLD-3724,XLD-3722,CONNECTED_TO,LineSegment,LineSegment
edge_26,XLD-3724,XLD-3726,CONNECTED_TO,LineSegment,LineSegment
edge_27,XB-3047,XLD-3673,CONNECTED_TO,StationHouse,LineSegment
edge_28,HWX-3112,XLD-3699,CONNECTED_TO,StationHouse,LineSegment
edge_29,HWX-3112,XLD-3437,CONNECTED_TO,StationHouse,LineSegment
edge_30,HWX-3112,XLD-3666,CONNECTED_TO,StationHouse,LineSegment
edge_31,XB-3091,XLD-3505,CONNECTED_TO,StationHouse,LineSegment
edge_32,XLD-3721,XLD-3724,CONNECTED_TO,LineSegment,LineSegment
edge_33,XLD-3721,ZSB-3017,CONNECTED_TO,LineSegment,StationHouse
edge_34,XLD-3722,XLD-3724,CONNECTED_TO,LineSegment,LineSegment
edge_35,XLD-3726,XLD-3724,CONNECTED_TO,LineSegment,LineSegment
edge_36,XLD-3726,ZSB-3016,CONNECTED_TO,LineSegment,StationHouse
.groovy:
// 属性定义
schema.propertyKey("id").asText().ifNotExist().create();
schema.propertyKey("name").asText().ifNotExist().create();
schema.propertyKey("objectType").asText().ifNotExist().create();
schema.propertyKey("objectHandle").asText().ifNotExist().create();
schema.propertyKey("deviceType").asText().ifNotExist().create();
schema.propertyKey("internalEndpointNo").asInt().ifNotExist().create();
schema.propertyKey("terminalNo").asInt().ifNotExist().create();
schema.propertyKey("usage").asText().ifNotExist().create();
schema.propertyKey("powerFlowDirection").asInt().ifNotExist().create();
schema.propertyKey("belongSubstation").asText().ifNotExist().create();
schema.propertyKey("belongFeeder").asText().ifNotExist().create();
schema.propertyKey("source_label").asText().ifNotExist().create();
schema.propertyKey("target_label").asText().ifNotExist().create();
// 顶点标签
schema.vertexLabel("Substation").properties("id", "name", "objectType",
"objectHandle", "deviceType", "internalEndpointNo", "terminalNo", "usage",
"powerFlowDirection", "belongSubstation",
"belongFeeder").primaryKeys("id").ifNotExist().create();
schema.vertexLabel("LineSegment").properties("id", "name", "objectType",
"objectHandle", "deviceType", "internalEndpointNo", "terminalNo", "usage",
"powerFlowDirection", "belongSubstation",
"belongFeeder").primaryKeys("id").ifNotExist().create();
schema.vertexLabel("LineSwitch").properties("id", "name", "objectType",
"objectHandle", "deviceType", "internalEndpointNo", "terminalNo", "usage",
"powerFlowDirection", "belongSubstation",
"belongFeeder").primaryKeys("id").ifNotExist().create();
schema.vertexLabel("StationHouse").properties("id", "name", "objectType",
"objectHandle", "deviceType", "internalEndpointNo", "terminalNo", "usage",
"powerFlowDirection", "belongSubstation",
"belongFeeder").primaryKeys("id").ifNotExist().create();
// 边标签(每种类型对每种类型都定义一条边,便于扩展和双向连接)
schema.edgeLabel("Substation2LineSegment").sourceLabel("Substation").targetLabel("LineSegment").properties().ifNotExist().create();
schema.edgeLabel("LineSegment2StationHouse").sourceLabel("LineSegment").targetLabel("StationHouse").properties().ifNotExist().create();
schema.edgeLabel("LineSegment2LineSegment").sourceLabel("LineSegment").targetLabel("LineSegment").properties().ifNotExist().create();
schema.edgeLabel("StationHouse2LineSwitch").sourceLabel("StationHouse").targetLabel("LineSwitch").properties().ifNotExist().create();
schema.edgeLabel("LineSegment2LineSwitch").sourceLabel("LineSegment").targetLabel("LineSwitch").properties().ifNotExist().create();
// ...根据实际需要继续补充
// 反向边(如需双向,定义反向边标签)
schema.edgeLabel("LineSegment2Substation").sourceLabel("LineSegment").targetLabel("Substation").properties().ifNotExist().create();
schema.edgeLabel("StationHouse2LineSegment").sourceLabel("StationHouse").targetLabel("LineSegment").properties().ifNotExist().create();
//schema.edgeLabel("LineSegment2LineSegment").sourceLabel("LineSegment").targetLabel("LineSegment").properties().ifNotExist().create();
schema.edgeLabel("LineSwitch2StationHouse").sourceLabel("LineSwitch").targetLabel("StationHouse").properties().ifNotExist().create();
schema.edgeLabel("LineSwitch2LineSegment").sourceLabel("LineSwitch").targetLabel("LineSegment").properties().ifNotExist().create();
// ...以此类推
strcut.json
{
"vertices": [
{
"label": "Substation",
"input": {
"type": "file",
"path":
"/loader/power_data/vertex_substation-1.csv",
"format": "CSV",
"header": ["id", "name", "objectType",
"objectHandle", "deviceType", "internalEndpointNo", "terminalNo", "usage",
"powerFlowDirection", "belongSubstation", "belongFeeder"],
"charset": "UTF-8"
},
"null_values": ["NULL", "null", ""]
},
{
"label": "LineSegment",
"input": {
"type": "file",
"path":
"/loader/power_data/vertex_linesegment-1.csv",
"format": "CSV",
"header": ["id", "name", "objectType",
"objectHandle", "deviceType", "internalEndpointNo", "terminalNo", "usage",
"powerFlowDirection", "belongSubstation", "belongFeeder"],
"charset": "UTF-8"
},
"null_values": ["NULL", "null", ""]
},
{
"label": "LineSwitch",
"input": {
"type": "file",
"path":
"/loader/power_data/vertex_lineswitch-1.csv",
"format": "CSV",
"header": ["id", "name", "objectType",
"objectHandle", "deviceType", "internalEndpointNo", "terminalNo", "usage",
"powerFlowDirection", "belongSubstation", "belongFeeder"],
"charset": "UTF-8"
},
"null_values": ["NULL", "null", ""]
},
{
"label": "StationHouse",
"input": {
"type": "file",
"path":
"/loader/power_data/vertex_stationhouse-1.csv",
"format": "CSV",
"header": ["id", "name", "objectType",
"objectHandle", "deviceType", "internalEndpointNo", "terminalNo", "usage",
"powerFlowDirection", "belongSubstation", "belongFeeder"],
"charset": "UTF-8"
},
"null_values": ["NULL", "null", ""]
}
],
"edges": [
{
"label": "Substation2LineSegment",
"source": ["from"],
"target": ["to"],
"input": {
"type": "file",
"path": "/loader/power_data/power_edges_to.csv",
"format": "CSV",
"header": ["id", "from", "to", "label",
"source_label", "target_label"]
},
"field_mapping": { "from": "from", "to": "to" }
},
{
"label": "LineSegment2Substation",
"source": ["from"],
"target": ["to"],
"input": {
"type": "file",
"path": "/loader/power_data/power_edges_to.csv",
"format": "CSV",
"header": ["id", "from", "to", "label",
"source_label", "target_label"]
},
"field_mapping": { "from": "from", "to": "to" }
},
{
"label": "LineSegment2StationHouse",
"source": ["from"],
"target": ["to"],
"input": {
"type": "file",
"path": "/loader/power_data/power_edges_to.csv",
"format": "CSV",
"header": ["id", "from", "to", "label",
"source_label", "target_label"]
},
"field_mapping": { "from": "from", "to": "to" }
},
{
"label": "StationHouse2LineSegment",
"source": ["from"],
"target": ["to"],
"input": {
"type": "file",
"path": "/loader/power_data/power_edges_to.csv",
"format": "CSV",
"header": ["id", "from", "to", "label",
"source_label", "target_label"]
},
"field_mapping": { "from": "from", "to": "to" }
},
{
"label": "StationHouse2LineSwitch",
"source": ["from"],
"target": ["to"],
"input": {
"type": "file",
"path": "/loader/power_data/power_edges_to.csv",
"format": "CSV",
"header": ["id", "from", "to", "label",
"source_label", "target_label"]
},
"field_mapping": { "from": "from", "to": "to" }
},
{
"label": "LineSwitch2StationHouse",
"source": ["from"],
"target": ["to"],
"input": {
"type": "file",
"path": "/loader/power_data/power_edges_to.csv",
"format": "CSV",
"header": ["id", "from", "to", "label",
"source_label", "target_label"]
},
"field_mapping": { "from": "from", "to": "to" }
},
{
"label": "LineSegment2LineSegment",
"source": ["from"],
"target": ["to"],
"input": {
"type": "file",
"path": "/loader/power_data/power_edges_to.csv",
"format": "CSV",
"header": ["id", "from", "to", "label",
"source_label", "target_label"]
},
"field_mapping": { "from": "from", "to": "to" }
},
{
"label": "LineSegment2LineSwitch",
"source": ["from"],
"target": ["to"],
"input": {
"type": "file",
"path": "/loader/power_data/power_edges_to.csv",
"format": "CSV",
"header": ["id", "from", "to", "label",
"source_label", "target_label"]
},
"field_mapping": { "from": "from", "to": "to" }
},
{
"label": "LineSwitch2LineSegment",
"source": ["from"],
"target": ["to"],
"input": {
"type": "file",
"path": "/loader/power_data/power_edges_to.csv",
"format": "CSV",
"header": ["id", "from", "to", "label",
"source_label", "target_label"]
},
"field_mapping": { "from": "from", "to": "to" }
}
]
}
导入输出
>> HugeGraphLoader worked in NORMAL MODE
vertices/edges loaded this time : 06:44:15.342 [loader] ERROR
org.apache.hugegraph.loader.task.ParseTaskBuilder - Parse EDGE error
org.apache.hugegraph.loader.exception.ParseException: Make sure the primary key
fields [id] are not empty, or check whether the headers or field_mapping are
configured correctly
at
org.apache.hugegraph.loader.task.ParseTaskBuilder.lambda$buildTask$0(ParseTaskBuilder.java:124)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.task.ParseTaskBuilder$ParseTask.get(ParseTaskBuilder.java:163)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.HugeGraphLoader.executeParseTask(HugeGraphLoader.java:816)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.HugeGraphLoader.loadStruct(HugeGraphLoader.java:789)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.HugeGraphLoader.lambda$asyncLoadStruct$14(HugeGraphLoader.java:734)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
java.util.concurrent.CompletableFuture$AsyncRun.run(Unknown Source) ~[?:?]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[?:?]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[?:?]
at java.lang.Thread.run(Unknown Source) ~[?:?]
Caused by: java.lang.IllegalArgumentException: Make sure the primary key fields
[id] are not empty, or check whether the headers or field_mapping are
configured correctly
at
com.google.common.base.Preconditions.checkArgument(Preconditions.java:164)
~[guava-30.0-jre.jar:?]
at
org.apache.hugegraph.util.E.checkArgument(E.java:52)
~[hugegraph-common-1.5.0.jar:1.5.0]
at
org.apache.hugegraph.loader.builder.ElementBuilder$VertexPkKVPairs.extractFromEdge(ElementBuilder.java:682)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.builder.EdgeBuilder.build(EdgeBuilder.java:88)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.task.ParseTaskBuilder.lambda$buildTask$0(ParseTaskBuilder.java:103)
~[hugegraph-loader-1.7.0.jar:1.7.0]
... 8 more
06:44:15.359 [loader] ERROR org.apache.hugegraph.loader.task.ParseTaskBuilder -
Parse EDGE error
org.apache.hugegraph.loader.exception.ParseException: Make sure the primary key
fields [id] are not empty, or check whether the headers or field_mapping are
configured correctly
at
org.apache.hugegraph.loader.task.ParseTaskBuilder.lambda$buildTask$0(ParseTaskBuilder.java:124)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.task.ParseTaskBuilder$ParseTask.get(ParseTaskBuilder.java:163)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.HugeGraphLoader.executeParseTask(HugeGraphLoader.java:816)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.HugeGraphLoader.loadStruct(HugeGraphLoader.java:789)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.HugeGraphLoader.lambda$asyncLoadStruct$14(HugeGraphLoader.java:734)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
java.util.concurrent.CompletableFuture$AsyncRun.run(Unknown Source) ~[?:?]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[?:?]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[?:?]
at java.lang.Thread.run(Unknown Source) ~[?:?]
Caused by: java.lang.IllegalArgumentException: Make sure the primary key fields
[id] are not empty, or check whether the headers or field_mapping are
configured correctly
at
com.google.common.base.Preconditions.checkArgument(Preconditions.java:164)
~[guava-30.0-jre.jar:?]
at
org.apache.hugegraph.util.E.checkArgument(E.java:52)
~[hugegraph-common-1.5.0.jar:1.5.0]
at
org.apache.hugegraph.loader.builder.ElementBuilder$VertexPkKVPairs.extractFromEdge(ElementBuilder.java:682)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.builder.EdgeBuilder.build(EdgeBuilder.java:88)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.task.ParseTaskBuilder.lambda$buildTask$0(ParseTaskBuilder.java:103)
~[hugegraph-loader-1.7.0.jar:1.7.0]
... 8 more
06:44:15.361 [loader] ERROR org.apache.hugegraph.loader.task.ParseTaskBuilder -
Parse EDGE error
org.apache.hugegraph.loader.exception.ParseException: Make sure the primary key
fields [id] are not empty, or check whether the headers or field_mapping are
configured correctly
at
org.apache.hugegraph.loader.task.ParseTaskBuilder.lambda$buildTask$0(ParseTaskBuilder.java:124)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.task.ParseTaskBuilder$ParseTask.get(ParseTaskBuilder.java:163)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.HugeGraphLoader.executeParseTask(HugeGraphLoader.java:816)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.HugeGraphLoader.loadStruct(HugeGraphLoader.java:789)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.HugeGraphLoader.lambda$asyncLoadStruct$14(HugeGraphLoader.java:734)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
java.util.concurrent.CompletableFuture$AsyncRun.run(Unknown Source) ~[?:?]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[?:?]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[?:?]
at java.lang.Thread.run(Unknown Source) ~[?:?]
Caused by: java.lang.IllegalArgumentException: Make sure the primary key fields
[id] are not empty, or check whether the headers or field_mapping are
configured correctly
at
com.google.common.base.Preconditions.checkArgument(Preconditions.java:164)
~[guava-30.0-jre.jar:?]
at
org.apache.hugegraph.util.E.checkArgument(E.java:52)
~[hugegraph-common-1.5.0.jar:1.5.0]
at
org.apache.hugegraph.loader.builder.ElementBuilder$VertexPkKVPairs.extractFromEdge(ElementBuilder.java:682)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.builder.EdgeBuilder.build(EdgeBuilder.java:88)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.task.ParseTaskBuilder.lambda$buildTask$0(ParseTaskBuilder.java:103)
~[hugegraph-loader-1.7.0.jar:1.7.0]
... 8 more
06:44:15.362 [loader] ERROR org.apache.hugegraph.loader.task.ParseTaskBuilder -
Parse EDGE error
org.apache.hugegraph.loader.exception.ParseException: Make sure the primary key
fields [id] are not empty, or check whether the headers or field_mapping are
configured correctly
at
org.apache.hugegraph.loader.task.ParseTaskBuilder.lambda$buildTask$0(ParseTaskBuilder.java:124)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.task.ParseTaskBuilder$ParseTask.get(ParseTaskBuilder.java:163)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.HugeGraphLoader.executeParseTask(HugeGraphLoader.java:816)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.HugeGraphLoader.loadStruct(HugeGraphLoader.java:789)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.HugeGraphLoader.lambda$asyncLoadStruct$14(HugeGraphLoader.java:734)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
java.util.concurrent.CompletableFuture$AsyncRun.run(Unknown Source) ~[?:?]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[?:?]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[?:?]
at java.lang.Thread.run(Unknown Source) ~[?:?]
Caused by: java.lang.IllegalArgumentException: Make sure the primary key fields
[id] are not empty, or check whether the headers or field_mapping are
configured correctly
at
com.google.common.base.Preconditions.checkArgument(Preconditions.java:164)
~[guava-30.0-jre.jar:?]
at
org.apache.hugegraph.util.E.checkArgument(E.java:52)
~[hugegraph-common-1.5.0.jar:1.5.0]
at
org.apache.hugegraph.loader.builder.ElementBuilder$VertexPkKVPairs.extractFromEdge(ElementBuilder.java:682)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.builder.EdgeBuilder.build(EdgeBuilder.java:88)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.task.ParseTaskBuilder.lambda$buildTask$0(ParseTaskBuilder.java:103)
~[hugegraph-loader-1.7.0.jar:1.7.0]
... 8 more
06:44:15.363 [loader] ERROR org.apache.hugegraph.loader.task.ParseTaskBuilder -
Parse EDGE error
org.apache.hugegraph.loader.exception.ParseException: Make sure the primary key
fields [id] are not empty, or check whether the headers or field_mapping are
configured correctly
at
org.apache.hugegraph.loader.task.ParseTaskBuilder.lambda$buildTask$0(ParseTaskBuilder.java:124)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.task.ParseTaskBuilder$ParseTask.get(ParseTaskBuilder.java:163)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.HugeGraphLoader.executeParseTask(HugeGraphLoader.java:816)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.HugeGraphLoader.loadStruct(HugeGraphLoader.java:789)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.HugeGraphLoader.lambda$asyncLoadStruct$14(HugeGraphLoader.java:734)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
java.util.concurrent.CompletableFuture$AsyncRun.run(Unknown Source) ~[?:?]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[?:?]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[?:?]
at java.lang.Thread.run(Unknown Source) ~[?:?]
Caused by: java.lang.IllegalArgumentException: Make sure the primary key fields
[id] are not empty, or check whether the headers or field_mapping are
configured correctly
at
com.google.common.base.Preconditions.checkArgument(Preconditions.java:164)
~[guava-30.0-jre.jar:?]
at
org.apache.hugegraph.util.E.checkArgument(E.java:52)
~[hugegraph-common-1.5.0.jar:1.5.0]
at
org.apache.hugegraph.loader.builder.ElementBuilder$VertexPkKVPairs.extractFromEdge(ElementBuilder.java:682)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.builder.EdgeBuilder.build(EdgeBuilder.java:88)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.task.ParseTaskBuilder.lambda$buildTask$0(ParseTaskBuilder.java:103)
~[hugegraph-loader-1.7.0.jar:1.7.0]
... 8 more
06:44:15.364 [loader] ERROR org.apache.hugegraph.loader.task.ParseTaskBuilder -
Parse EDGE error
org.apache.hugegraph.loader.exception.ParseException: Make sure the primary key
fields [id] are not empty, or check whether the headers or field_mapping are
configured correctly
at
org.apache.hugegraph.loader.task.ParseTaskBuilder.lambda$buildTask$0(ParseTaskBuilder.java:124)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.task.ParseTaskBuilder$ParseTask.get(ParseTaskBuilder.java:163)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.HugeGraphLoader.executeParseTask(HugeGraphLoader.java:816)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.HugeGraphLoader.loadStruct(HugeGraphLoader.java:789)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.HugeGraphLoader.lambda$asyncLoadStruct$14(HugeGraphLoader.java:734)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
java.util.concurrent.CompletableFuture$AsyncRun.run(Unknown Source) ~[?:?]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[?:?]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[?:?]
at java.lang.Thread.run(Unknown Source) ~[?:?]
Caused by: java.lang.IllegalArgumentException: Make sure the primary key fields
[id] are not empty, or check whether the headers or field_mapping are
configured correctly
at
com.google.common.base.Preconditions.checkArgument(Preconditions.java:164)
~[guava-30.0-jre.jar:?]
at
org.apache.hugegraph.util.E.checkArgument(E.java:52)
~[hugegraph-common-1.5.0.jar:1.5.0]
at
org.apache.hugegraph.loader.builder.ElementBuilder$VertexPkKVPairs.extractFromEdge(ElementBuilder.java:682)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.builder.EdgeBuilder.build(EdgeBuilder.java:88)
~[hugegraph-loader-1.7.0.jar:1.7.0]
at
org.apache.hugegraph.loader.task.ParseTaskBuilder.lambda$buildTask$0(ParseTaskBuilder.java:103)
~[hugegraph-loader-1.7.0.jar:1.7.0]
... 8 more
06:44:15.849 [loader] ERROR org.apache.hugegraph.loader.util.Printer - More
than 1 parse error, stop parsing and waiting all insert tasks stopped
More than 1 parse error, stop parsing and waiting all insert tasks stopped
81/0
--------------------------------------------------
count metrics
input read success : 274
input read failure : 0
vertex parse success : 81
vertex parse failure : 0
vertex insert success : 81
vertex insert failure : 0
edge parse success : 0
edge parse failure : 1737
edge insert success : 0
edge insert failure : 0
--------------------------------------------------
meter metrics
total time
: 0.705s
read time
: 0.102s
load time
: 0.603s
vertex load time
: 0.091s
vertex load rate(vertices/s) : 890
edge load time
: 0.512s
edge load rate(edges/s) : 0
原始邮件
发件人:dosubot[bot] ***@***.***>
发件时间:2025年12月10日 09:30
收件人:apache/incubator-hugegraph ***@***.***>
抄送:wangzhewwzz ***@***.***>, Mention ***@***.***>
主题:Re: [apache/incubator-hugegraph] 关于电网拓扑数据导入 (Discussion #2917)
你的配置现在只差一个关键点就能导入成功:
你 struct.json 的 edges 里 field_mapping 必须写成:
"field_mapping": { "from": "from", "to": "to" }
不能写成 { "from": "id", "to": "id" },否则 loader 会把 edge_connected_to.csv 的 id
列当作边属性导入,但 schema.groovy 的 edgeLabel 没有声明 id 属性,导致 “Invalid property 'id' for
edge label” 或 “主键字段 [id] 为空” 的报错。官方文档说明
逐条检查你的配置:
edge_connected_to.csv 的 header 必须是 id,from,to,label,source_label,target_label,且
from/to 必须和顶点 CSV 的 id 完全一致(无空格、无大小写问题、无空行)。
struct.json 的 edges 里 field_mapping 只写 from/to,不要写 id。
edgeLabel 的 .properties() 只包含 "source_label", "target_label",不要加 "id"。
value_mapping 是平铺结构没问题。
null_values 建议只保留 ["NULL", "null"],不要加 "",否则空字符串会被判定为 null。
你只需要把 struct.json 里所有 edges 的 field_mapping 全部改成:
"field_mapping": { "from": "from", "to": "to" }
其他配置不用动,edge_connected_to.csv 的 id 列可以保留但 loader 不会导入它为边属性。
这样配置后,边就能正常导入且无报错,所有关系都能导入。详细机制见官方FAQ
如果还有报错,请贴出 edge_connected_to.csv 的 header 和前几行原始数据,以及 struct.json 某个 edges
配置的完整内容,我可以帮你定位具体是哪一行或哪一列有问题。
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-15215945
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]