It seems that in both approaches the vertex is stored and can be retrieved properly later.
Common configuration:
DseCluster dseCluster = DseCluster.builder()
.addContactPoint("192.168.1.43")
.build();
DseSession dseSession = dseCluster.connect();
GraphTraversalSource g = DseGraph.traversal(
dseSession, new GraphOptions().setGraphName("graph")
);
Approach 1:
Vertex v = g.addV("User").property("uuid","testuuid231").next();
Approach 2:
GraphStatement graphStatement = DseGraph.statementFromTraversal(
g.addV("User").property("uuid","testuuid231")
);
GraphResultSet grs = dseSession.executeGraph(graphStatement.setGraphName("graph"));
Vertex v = grs.one().asVertex() // as(Vertex.class) is not allowed after 1.1
It looks like you are using
java-dse-graph
, is that right? This is a relatively new API (still in beta) which allows you to make Gremlin Traversals w/ Apache Tinkerpop using the DataStax Enterprise Java driver under the covers.The benefits of approach 1 is that you can be sure that you are forming valid traversals for one, although you also get this via
statementFromTraversal
(you can also pass aString
orGraphStatement
intoexecuteGraph
at which point you can't be sure you are executing a valid traversal). Additionally, you can write code that is more vendor agnostic, since you are using the Tinkerpop API and not the datastax driver. Well, you are still using it, but not directly once you've got aGraphTraversalSource
from aDseSession
.Approach 2 has a few benefits that aren't available in approach 1 (yet):
ResultSet
,Statement
, etc.).java-dse-graph
(haven't tried it yet). UsingstatementFromTraversal
, you can pass the generatedGraphStatement
intoDseSession.executeAsync
to do async.java-dse-graph
. Until then you would have to useexecuteGraph(String|GraphStatement)
.I expect that
java-dse-graph
(approach 1) will become the more idiomatic way to interact with DSE Graph in the future.statementFromTraversal
offers a nice way to get the best of both worlds (the benefit of Apache TinkerPop + an interface to the DataStax java driver).