When using the following Gremlin statement to query AWS Neptune, the completableFuture is not returning the desired result. As i tried the following:
graphTraversal.promise(Traversal::hasNext());
Scenario 1:
It works for single vertex g.V('id-1').promise(Traversal::hasNext())
returns true
But, when i use g.V('id-1','id-2').promise(Traversal::hasNext())
it still returns true rather than false since id-2
is not available in db
Scenario 2:
when creating list of edges as follows, how to make the query return false if any of the edges is not created.
CompletableFuture<Boolean> method1() {
List<Edge> edgeList = new ArrayList();
edgeList.add(edge1);// vertex2 -> vertex3`
edgeList.add(edge2);// vertex1(not present) -> vertex2
edgeList.add(edge3);// vertex3 -> vertex4
GraphTraversal g = null;
loop(edgeList: e) {
g = graphTraversalQueryMethod(g, e);
}
return g.promise(Traversal::hasNext);
}
GraphTraversal graphTraversalQueryMethod(GraphTraversal g, Edge e) {
g.V(e.sourceVertexId).addE("EDGE_LABEL").property(e.propKey, e.propValue).to(e.destVertexId);
}
Its returning false but, the useCase: (suppose the source / destination vertices of the edge is not present)
- edge1 is getting created
- edge2 not created since source vertex1 is missing
- edge3 also not created even if it has both source and destination vertices available in the db
- so result is returned as false with creating 1 (edge1) valid edge out of 2 (edge1, edge3)
Is there any option to rollback the whole transaction using gremlin in neptune? to get this query executed after the missing vertex1 got created by some other way.
Or any idea to handle / capture the missing transaction. Please correct me if i need to change the query formation.
Note: At-least i need to capture the edges / any of the transaction is not succeeded on query execution. This is using Java.
Would be helpful, if got suggestion for any best practices to achieve this!