You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+141-6Lines changed: 141 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -117,7 +117,7 @@ Do above for all entities and their attributes in the schema. GraMi will ensure
117
117
118
118
For each relation in your schema, define a processor object that specifies
119
119
- each relation attribute, its value type, and whether it is required
120
-
- each relation player entity type, role, identifying attribute in the data file and its value type, as well as whether the player is required
120
+
- each relation player of type entity, its role, identifying attribute in the data file and value type, as well as whether the player is required
121
121
122
122
For example, given the following relation in your schema:
123
123
@@ -126,7 +126,8 @@ call sub relation,
126
126
relatescaller,
127
127
relatescallee,
128
128
hasstarted-at,
129
-
hasduration;
129
+
hasduration,
130
+
playspast-call;
130
131
```
131
132
132
133
Add the following processor object:
@@ -143,8 +144,7 @@ Add the following processor object:
143
144
"uniquePlayerId": "phone-number", // using attribute phone-number as unique identifier for type person
144
145
"idValueType": "string", // of value type string
145
146
"roleType": "caller", // inserts person as player the role caller
146
-
"required": true // which is a required role for each data record
147
-
147
+
"required": true // which is a required role for each data record
148
148
},
149
149
"callee": { // ID of player generator
150
150
"playerType": "person", // matches entity of type person
@@ -172,6 +172,64 @@ Add the following processor object:
172
172
173
173
Do above for all relations and their players and attributes in the schema. GraMi will ensure that all values in your data files adhere to the value type specified or try to cast them. GraMi will also ensure that no data records enter grakn that are incomplete (missing required attributes/players).
174
174
175
+
##### Relation-Of-Relation Processors
176
+
177
+
Grakn comes with the powerful feature of using relations as players in other relations.
178
+
179
+
For each relation-of-relation in your schema, define a processor object that specifies
180
+
- each relation attribute, its value type, and whether it is required
181
+
- each relation player of type entity, its role, identifying attribute in the data file and its value type, as well as whether the player is required
182
+
- each relation player of type relation, its role, identifying attribute in the data file and its value type, as well as whether the player is required
183
+
184
+
For example, given the following relation in your schema:
185
+
186
+
```GraphQL
187
+
personsubentity,
188
+
...,
189
+
playspeer;
190
+
191
+
callsubrelation,
192
+
relatescaller,
193
+
relatescallee,
194
+
hasstarted-at,
195
+
hasduration,
196
+
playspast-call;
197
+
198
+
communication-channelsubrelation,
199
+
relatespeer,
200
+
relatespast-call;
201
+
```
202
+
203
+
Add the following processor object:
204
+
205
+
```
206
+
{
207
+
"processor": "communication-channel", // the ID of your processor
208
+
"processorType": "relation-of-relation", // creates a relation
209
+
"schemaType": "communication-channel", // of type communication-channel
210
+
"conceptGenerators": {
211
+
"players": { // with the following players according to schema
212
+
"peer": { // ID of player generator
213
+
"playerType": "person", // matches entity of type person
214
+
"uniquePlayerId": "phone-number", // using attribute phone-number as unique identifier for type person
215
+
"idValueType": "string", // of value type string
216
+
"roleType": "peer", // inserts person as player the role caller
217
+
"required": true // which is a required role for each data record
218
+
}
219
+
"past-call": { // ID of player generator
220
+
"playerType": "call", // matches entity of type person
221
+
"uniquePlayerId": "started-at", // using attribute phone-number as unique identifier for type person
222
+
"idValueType": "date", // of value type string
223
+
"roleType": "past-call", // inserts person as player the role callee
224
+
"required": true // which is a required role for each data record
225
+
},
226
+
}
227
+
}
228
+
}
229
+
```
230
+
231
+
Just remember that these relations of relation must be added AFTER the relations that will act as players in the relation have been migrated. GraMi will migrate all relation-of-relations after having migrated entities and relations - but keep this in mind as you are building your graph - relations are only inserted as expected when all its players are already present.
232
+
175
233
See the [full configuration file for phone-calls here](https://github.com/bayer-science-for-a-better-life/grami/tree/master/src/test/resources/phone-calls/processorConfig.json).
176
234
177
235
#### Data Configuration
@@ -257,7 +315,7 @@ The data config entry would be:
257
315
"players": [ // player columns present in the data file
258
316
{
259
317
"columnName": "caller_id", // column name in data file
260
-
"generator": "caller" // player generator in processor call to be used for the column
318
+
"generator": "caller" // player generator in processor call to be used for the column
261
319
},
262
320
{
263
321
"columnName": "callee_id", // column name in data file
@@ -267,7 +325,7 @@ The data config entry would be:
267
325
"attributes": [ // attribute columns present in the data file
268
326
{
269
327
"columnName": "started_at", // column name in data file
270
-
"generator": "started-at" // attribute generator in processor call to be used for the column
328
+
"generator": "started-at" // attribute generator in processor call to be used for the column
271
329
},
272
330
{
273
331
"columnName": "duration", // column name in data file
@@ -279,6 +337,83 @@ The data config entry would be:
279
337
280
338
Do above for all data files that need to be migrated.
281
339
340
+
Please note that you can also add a listSeparator for players that are in a list in a column:
For troubleshooting, it might be worth setting the troublesome data configuration entry to a single thread, as the log messages for error from grakn are more verbose and specific that way...
371
+
372
+
##### Relation-of-Relation Data Config Entries
373
+
374
+
Given the data file [communication-channel.csv](https://github.com/bayer-science-for-a-better-life/grami/tree/master/src/test/resources/phone-calls/communication-channel.csv):
"dataPath": "/your/absolute/path/to/communication-channel.csv", // the absolute path to your data file
393
+
"separator": ",", // the separation character used in your data file (alternatives: "\t", ";", etc...)
394
+
"processor": "communication-channel", // processor from processor config file
395
+
"batchSize": 100, // batchSize to be used for this data file
396
+
"threads": 4, // # of threads to be used for this data file
397
+
"players": [ // player columns present in the data file
398
+
{
399
+
"columnName": "peer_1", // column name in data file
400
+
"generator": "peer" // player generator in processor call to be used for the column
401
+
},
402
+
{
403
+
"columnName": "peer_2", // column name in data file
404
+
"generator": "peer" // player generator in processor call to be used for the column
405
+
},
406
+
{
407
+
"columnName": "call_started_at", // column name in data file
408
+
"generator": "past-call", // player generator in processor call to be used for the column
409
+
"listSeparator": "###"
410
+
}
411
+
]
412
+
}
413
+
```
414
+
415
+
Do above for all data files that need to be migrated.
416
+
282
417
For troubleshooting, it might be worth setting the troublesome data configuration entry to a single thread, as the log messages for error from grakn are more verbose and specific that way...
283
418
284
419
See the [full configuration file for phone-calls here](https://github.com/bayer-science-for-a-better-life/grami/tree/master/src/test/resources/phone-calls/dataConfig.json).
appLogger.error("The column header in your dataconfig mapping to the uniquePlayerId [" + playerGenerator.getUniquePlayerId() + "] cannot be found in the file you specified.");
0 commit comments