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
{{ message }}
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.
Hi,
Currently, the utils project doesn't support updates to a vertex.
I was wondering if we could create a new set of classes that can be called VertexUpdaterWorker (or something like that..) that tries to fetch the vertex that already exists in the graph DB and then have the v.property(propName, convertedValue); update the vertex?
For example, with the current code, I can ingest the following data using the DataLoader.loadVertex() utility.
input.csv contains:
cust_id, is_active
1347, TRUE
1348, FALSE
In order to update the above nodes, I propose we have a couple of new fields in the datamapper.json that signify which field should be searched for in the graph DB and what field it maps to on the input CSV.
For example:
{
"vertexMap": {
"update.csv": {
"[VertexLabel]": "customer",<===== this signifies the vertex type that should be updated
"[SearchGraph]": "node_id", <==== this signifies which vertex should be updated
"[SearchCsv]": "cust_id", <======= this signifies node_id is mapped to cust_id in the CSV
"is_active": "is_active" <========= this is same as before
}
},
"edgeMap": {}
}
where update.csv contains: cust_id, is_active 1347, FALSE 1348, TRUE
We can then create a new acceptRecord that does the below:
` JanusGraphVertex v;
// Find the vertex to be updated
try {
v = (JanusGraphVertex) graphTransaction.traversal().V().hasLabel(vertexLabel).has(searchGraphLabel, record.get(searchCsvLabel)).next();
} catch (Exception e) {
return;
}
try {
// set the properties of the vertex
for (String column : record.keySet()) {
// Find the value, property to be updated
String value = record.get(column);
// If value="" or it is a vertex label then skip it
if (value == null || value.length() == 0 || column.equals(vertexLabelFieldName))
continue;
String propName = (String) getPropertiesMap().get(column);
if (propName == null) {
continue;
}
// Update the value from String to property's datayype, ex. date & time
Object convertedValue = BatchHelper.convertPropertyValue(value,
graphTransaction.getPropertyKey(propName).dataType());
// Write property and value to vertex
v.property(propName, convertedValue);
}
} catch (Exception e) {
return;
}
`
The text was updated successfully, but these errors were encountered:
Originally, when we introduce the importer, the main purpose is for bulk loading data in csv format into Janusgraph. Your proposal is trying to use the utility to update the graph db in batch? I think it's a good idea. Are you willing to implement this?
Hi,
Currently, the utils project doesn't support updates to a vertex.
I was wondering if we could create a new set of classes that can be called VertexUpdaterWorker (or something like that..) that tries to fetch the vertex that already exists in the graph DB and then have the v.property(propName, convertedValue); update the vertex?
For example, with the current code, I can ingest the following data using the DataLoader.loadVertex() utility.
input.csv contains:
cust_id, is_active
1347, TRUE
1348, FALSE
The datamapper.json contains:
"vertexMap": {
"input.csv": {
"[VertexLabel]": "customer",
"is_active": "is_active"
"cust_id": "node_id"
}
},
"edgeMap": {}
}
In order to update the above nodes, I propose we have a couple of new fields in the datamapper.json that signify which field should be searched for in the graph DB and what field it maps to on the input CSV.
For example:
{
"vertexMap": {
"update.csv": {
"[VertexLabel]": "customer",<===== this signifies the vertex type that should be updated
"[SearchGraph]": "node_id", <==== this signifies which vertex should be updated
"[SearchCsv]": "cust_id", <======= this signifies node_id is mapped to cust_id in the CSV
"is_active": "is_active" <========= this is same as before
}
},
"edgeMap": {}
}
where update.csv contains:
cust_id, is_active 1347, FALSE 1348, TRUE
We can then create a new acceptRecord that does the below:
` JanusGraphVertex v;
// Find the vertex to be updated
try {
v = (JanusGraphVertex) graphTransaction.traversal().V().hasLabel(vertexLabel).has(searchGraphLabel, record.get(searchCsvLabel)).next();
`
The text was updated successfully, but these errors were encountered: