@@ -19,7 +19,7 @@ pub struct ConnectionSpec {
19
19
}
20
20
21
21
#[ derive( Debug , Deserialize ) ]
22
- pub struct FieldMapping {
22
+ pub struct GraphFieldMappingSpec {
23
23
field_name : FieldName ,
24
24
25
25
/// Field name for the node in the Knowledge Graph.
@@ -28,48 +28,48 @@ pub struct FieldMapping {
28
28
node_field_name : Option < FieldName > ,
29
29
}
30
30
31
- impl FieldMapping {
31
+ impl GraphFieldMappingSpec {
32
32
fn get_node_field_name ( & self ) -> & FieldName {
33
33
self . node_field_name . as_ref ( ) . unwrap_or ( & self . field_name )
34
34
}
35
35
}
36
36
37
37
#[ derive( Debug , Deserialize ) ]
38
- pub struct RelationshipEndSpec {
38
+ pub struct GraphRelationshipEndSpec {
39
39
label : String ,
40
- fields : Vec < FieldMapping > ,
40
+ fields : Vec < GraphFieldMappingSpec > ,
41
41
}
42
42
43
43
#[ derive( Debug , Deserialize ) ]
44
- pub struct RelationshipNodeSpec {
44
+ pub struct GraphRelationshipNodeSpec {
45
45
#[ serde( flatten) ]
46
46
index_options : spec:: IndexOptions ,
47
47
}
48
48
49
49
#[ derive( Debug , Deserialize ) ]
50
- pub struct NodeSpec {
50
+ pub struct GraphNodeSpec {
51
51
label : String ,
52
52
}
53
53
54
54
#[ derive( Debug , Deserialize ) ]
55
- pub struct RelationshipSpec {
55
+ pub struct GraphRelationshipSpec {
56
56
rel_type : String ,
57
- source : RelationshipEndSpec ,
58
- target : RelationshipEndSpec ,
59
- nodes : Option < BTreeMap < String , RelationshipNodeSpec > > ,
57
+ source : GraphRelationshipEndSpec ,
58
+ target : GraphRelationshipEndSpec ,
59
+ nodes : Option < BTreeMap < String , GraphRelationshipNodeSpec > > ,
60
60
}
61
61
62
62
#[ derive( Debug , Deserialize ) ]
63
63
#[ serde( tag = "kind" ) ]
64
- pub enum RowMappingSpec {
65
- Relationship ( RelationshipSpec ) ,
66
- Node ( NodeSpec ) ,
64
+ pub enum GraphMappingSpec {
65
+ Relationship ( GraphRelationshipSpec ) ,
66
+ Node ( GraphNodeSpec ) ,
67
67
}
68
68
69
69
#[ derive( Debug , Deserialize ) ]
70
70
pub struct Spec {
71
71
connection : AuthEntryReference ,
72
- mapping : RowMappingSpec ,
72
+ mapping : GraphMappingSpec ,
73
73
}
74
74
75
75
#[ derive( Debug , Clone , Serialize , Deserialize , PartialEq , Eq , Hash ) ]
@@ -101,10 +101,12 @@ impl ElementType {
101
101
}
102
102
}
103
103
104
- fn from_mapping_spec ( spec : & RowMappingSpec ) -> Self {
104
+ fn from_mapping_spec ( spec : & GraphMappingSpec ) -> Self {
105
105
match spec {
106
- RowMappingSpec :: Relationship ( spec) => ElementType :: Relationship ( spec. rel_type . clone ( ) ) ,
107
- RowMappingSpec :: Node ( spec) => ElementType :: Node ( spec. label . clone ( ) ) ,
106
+ GraphMappingSpec :: Relationship ( spec) => {
107
+ ElementType :: Relationship ( spec. rel_type . clone ( ) )
108
+ }
109
+ GraphMappingSpec :: Node ( spec) => ElementType :: Node ( spec. label . clone ( ) ) ,
108
110
}
109
111
}
110
112
@@ -393,7 +395,7 @@ impl ExportContext {
393
395
key_fields. iter ( ) . map ( |f| & f. name ) ,
394
396
) ;
395
397
let result = match spec. mapping {
396
- RowMappingSpec :: Node ( node_spec) => {
398
+ GraphMappingSpec :: Node ( node_spec) => {
397
399
let delete_cypher = formatdoc ! { "
398
400
OPTIONAL MATCH (old_node:{label} {key_fields_literal})
399
401
WITH old_node
@@ -433,7 +435,7 @@ impl ExportContext {
433
435
tgt_fields : None ,
434
436
}
435
437
}
436
- RowMappingSpec :: Relationship ( rel_spec) => {
438
+ GraphMappingSpec :: Relationship ( rel_spec) => {
437
439
let delete_cypher = formatdoc ! { "
438
440
OPTIONAL MATCH (old_src)-[old_rel:{rel_type} {key_fields_literal}]->(old_tgt)
439
441
@@ -687,8 +689,8 @@ impl RelationshipSetupState {
687
689
}
688
690
let mut dependent_node_labels = vec ! [ ] ;
689
691
match & spec. mapping {
690
- RowMappingSpec :: Node ( _) => { }
691
- RowMappingSpec :: Relationship ( rel_spec) => {
692
+ GraphMappingSpec :: Node ( _) => { }
693
+ GraphMappingSpec :: Relationship ( rel_spec) => {
692
694
let ( src_label_info, tgt_label_info) = end_nodes_label_info. ok_or_else ( || {
693
695
anyhow ! (
694
696
"Expect `end_nodes_label_info` existing for relationship `{}`" ,
@@ -1079,12 +1081,15 @@ impl Factory {
1079
1081
struct DependentNodeLabelAnalyzer < ' a > {
1080
1082
label_name : & ' a str ,
1081
1083
fields : IndexMap < & ' a str , AnalyzedGraphFieldMapping > ,
1082
- remaining_fields : HashMap < & ' a str , & ' a FieldMapping > ,
1084
+ remaining_fields : HashMap < & ' a str , & ' a GraphFieldMappingSpec > ,
1083
1085
index_options : Option < & ' a IndexOptions > ,
1084
1086
}
1085
1087
1086
1088
impl < ' a > DependentNodeLabelAnalyzer < ' a > {
1087
- fn new ( rel_spec : & ' a RelationshipSpec , rel_end_spec : & ' a RelationshipEndSpec ) -> Result < Self > {
1089
+ fn new (
1090
+ rel_spec : & ' a GraphRelationshipSpec ,
1091
+ rel_end_spec : & ' a GraphRelationshipEndSpec ,
1092
+ ) -> Result < Self > {
1088
1093
Ok ( Self {
1089
1094
label_name : rel_end_spec. label . as_str ( ) ,
1090
1095
fields : IndexMap :: new ( ) ,
@@ -1181,7 +1186,7 @@ impl StorageFactoryBase for Factory {
1181
1186
let setup_key = GraphElement :: from_spec ( & spec) ;
1182
1187
1183
1188
let ( value_fields_info, rel_end_label_info) = match & spec. mapping {
1184
- RowMappingSpec :: Node ( _) => (
1189
+ GraphMappingSpec :: Node ( _) => (
1185
1190
value_fields_schema
1186
1191
. into_iter ( )
1187
1192
. enumerate ( )
@@ -1193,7 +1198,7 @@ impl StorageFactoryBase for Factory {
1193
1198
. collect ( ) ,
1194
1199
None ,
1195
1200
) ,
1196
- RowMappingSpec :: Relationship ( rel_spec) => {
1201
+ GraphMappingSpec :: Relationship ( rel_spec) => {
1197
1202
let mut src_label_analyzer =
1198
1203
DependentNodeLabelAnalyzer :: new ( & rel_spec, & rel_spec. source ) ?;
1199
1204
let mut tgt_label_analyzer =
0 commit comments