@@ -19,7 +19,7 @@ pub struct ConnectionSpec {
1919}
2020
2121#[ derive( Debug , Deserialize ) ]
22- pub struct FieldMapping {
22+ pub struct GraphFieldMappingSpec {
2323 field_name : FieldName ,
2424
2525 /// Field name for the node in the Knowledge Graph.
@@ -28,48 +28,48 @@ pub struct FieldMapping {
2828 node_field_name : Option < FieldName > ,
2929}
3030
31- impl FieldMapping {
31+ impl GraphFieldMappingSpec {
3232 fn get_node_field_name ( & self ) -> & FieldName {
3333 self . node_field_name . as_ref ( ) . unwrap_or ( & self . field_name )
3434 }
3535}
3636
3737#[ derive( Debug , Deserialize ) ]
38- pub struct RelationshipEndSpec {
38+ pub struct GraphRelationshipEndSpec {
3939 label : String ,
40- fields : Vec < FieldMapping > ,
40+ fields : Vec < GraphFieldMappingSpec > ,
4141}
4242
4343#[ derive( Debug , Deserialize ) ]
44- pub struct RelationshipNodeSpec {
44+ pub struct GraphRelationshipNodeSpec {
4545 #[ serde( flatten) ]
4646 index_options : spec:: IndexOptions ,
4747}
4848
4949#[ derive( Debug , Deserialize ) ]
50- pub struct NodeSpec {
50+ pub struct GraphNodeSpec {
5151 label : String ,
5252}
5353
5454#[ derive( Debug , Deserialize ) ]
55- pub struct RelationshipSpec {
55+ pub struct GraphRelationshipSpec {
5656 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 > > ,
6060}
6161
6262#[ derive( Debug , Deserialize ) ]
6363#[ serde( tag = "kind" ) ]
64- pub enum RowMappingSpec {
65- Relationship ( RelationshipSpec ) ,
66- Node ( NodeSpec ) ,
64+ pub enum GraphMappingSpec {
65+ Relationship ( GraphRelationshipSpec ) ,
66+ Node ( GraphNodeSpec ) ,
6767}
6868
6969#[ derive( Debug , Deserialize ) ]
7070pub struct Spec {
7171 connection : AuthEntryReference ,
72- mapping : RowMappingSpec ,
72+ mapping : GraphMappingSpec ,
7373}
7474
7575#[ derive( Debug , Clone , Serialize , Deserialize , PartialEq , Eq , Hash ) ]
@@ -101,10 +101,12 @@ impl ElementType {
101101 }
102102 }
103103
104- fn from_mapping_spec ( spec : & RowMappingSpec ) -> Self {
104+ fn from_mapping_spec ( spec : & GraphMappingSpec ) -> Self {
105105 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 ( ) ) ,
108110 }
109111 }
110112
@@ -393,7 +395,7 @@ impl ExportContext {
393395 key_fields. iter ( ) . map ( |f| & f. name ) ,
394396 ) ;
395397 let result = match spec. mapping {
396- RowMappingSpec :: Node ( node_spec) => {
398+ GraphMappingSpec :: Node ( node_spec) => {
397399 let delete_cypher = formatdoc ! { "
398400 OPTIONAL MATCH (old_node:{label} {key_fields_literal})
399401 WITH old_node
@@ -433,7 +435,7 @@ impl ExportContext {
433435 tgt_fields : None ,
434436 }
435437 }
436- RowMappingSpec :: Relationship ( rel_spec) => {
438+ GraphMappingSpec :: Relationship ( rel_spec) => {
437439 let delete_cypher = formatdoc ! { "
438440 OPTIONAL MATCH (old_src)-[old_rel:{rel_type} {key_fields_literal}]->(old_tgt)
439441
@@ -687,8 +689,8 @@ impl RelationshipSetupState {
687689 }
688690 let mut dependent_node_labels = vec ! [ ] ;
689691 match & spec. mapping {
690- RowMappingSpec :: Node ( _) => { }
691- RowMappingSpec :: Relationship ( rel_spec) => {
692+ GraphMappingSpec :: Node ( _) => { }
693+ GraphMappingSpec :: Relationship ( rel_spec) => {
692694 let ( src_label_info, tgt_label_info) = end_nodes_label_info. ok_or_else ( || {
693695 anyhow ! (
694696 "Expect `end_nodes_label_info` existing for relationship `{}`" ,
@@ -1079,12 +1081,15 @@ impl Factory {
10791081struct DependentNodeLabelAnalyzer < ' a > {
10801082 label_name : & ' a str ,
10811083 fields : IndexMap < & ' a str , AnalyzedGraphFieldMapping > ,
1082- remaining_fields : HashMap < & ' a str , & ' a FieldMapping > ,
1084+ remaining_fields : HashMap < & ' a str , & ' a GraphFieldMappingSpec > ,
10831085 index_options : Option < & ' a IndexOptions > ,
10841086}
10851087
10861088impl < ' 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 > {
10881093 Ok ( Self {
10891094 label_name : rel_end_spec. label . as_str ( ) ,
10901095 fields : IndexMap :: new ( ) ,
@@ -1181,7 +1186,7 @@ impl StorageFactoryBase for Factory {
11811186 let setup_key = GraphElement :: from_spec ( & spec) ;
11821187
11831188 let ( value_fields_info, rel_end_label_info) = match & spec. mapping {
1184- RowMappingSpec :: Node ( _) => (
1189+ GraphMappingSpec :: Node ( _) => (
11851190 value_fields_schema
11861191 . into_iter ( )
11871192 . enumerate ( )
@@ -1193,7 +1198,7 @@ impl StorageFactoryBase for Factory {
11931198 . collect ( ) ,
11941199 None ,
11951200 ) ,
1196- RowMappingSpec :: Relationship ( rel_spec) => {
1201+ GraphMappingSpec :: Relationship ( rel_spec) => {
11971202 let mut src_label_analyzer =
11981203 DependentNodeLabelAnalyzer :: new ( & rel_spec, & rel_spec. source ) ?;
11991204 let mut tgt_label_analyzer =
0 commit comments