cassandragremlindatastax-enterprisedatastax-java-drivertinkerpop

DSE Graph with Java Driver, how to build a graph using Tinkerpop/Gremlin APIs like in Titan?


I have an application which currently relies on tinkerpop & titan. I would like to assess Graph features provided by DSE 5.0 but I did not find any way to instantiate a tinkerpop Graph using DSE Graph java API.

For titan, I used the tinkerpop GraphFactory class:

Is there any equivalent in DSE Graph API?


Solution

  • April 28th 2017 update

    Now the graph fluent API functionality can be used through this dependency:

    <dependency>
        <groupId>com.datastax.dse</groupId>
        <artifactId>dse-java-driver-graph</artifactId>
        <version>1.2.3</version>
    </dependency> 
    

    October 28th 2016 update

    The first implementation of Gremlin fluent API is available even though it is still in beta (https://datastax-oss.atlassian.net/browse/JAVA-1250?focusedCommentId=35907&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-35907):

    <dependency>
        <groupId>com.datastax.cassandra</groupId>
        <artifactId>dse-driver</artifactId>
        <version>1.1.1-beta1</version>
    </dependency>
    <dependency>
        <groupId>com.datastax.cassandra</groupId>
        <artifactId>java-dse-graph</artifactId>
        <version>1.0.0-beta1</version>
    </dependency>
    

    This is how it works today with a small example:

            DseCluster dseCluster = DseCluster.builder()
                    .addContactPoint(HOST_IP)
                    .build();
            DseSession dseSession = dseCluster.connect();
            GraphTraversalSource g = DseGraph.traversal(dseSession, new GraphOptions().setGraphName(GRAPH_NAME));
    
            GraphTraversal<Vertex,Vertex> gT = g.addV("User").property("uuid","testuuid");
    
            GraphStatement graphStatement =  DseGraph.statementFromTraversal(gT);
            GraphResultSet grs = dseSession.executeGraph(graphStatement.setGraphName(GRAPH_NAME));
            System.out.println(grs.one().asVertex());
    

    Original Post

    I was trying to migrate code from Titan to Datastax DSE..I was seeking the same APIs as you were so, I filed an issue in the github repository of java dse driver: https://github.com/datastax/java-driver-dse/issues/42

    It is currently into works as a lot of coordination among different language platforms and optimization is going on.

    We do have plans for a more fluent api. Just as some background, most of the TinkerPop/gremlin drivers out there do a String based approach - that is, send the traversal String to the server, the server then optimizes the traversal and executes it. The result is sent back to the client and is deserialized.

    For Titan, what people commonly use is remote server mode which gives access to a Graph object. This is great from a development perspective because it offers a fluent api which is compile time checked and can be code completed. From a practical perspective, it's actually less efficient because it's a remote server that has to make lots of round trips to the underlying data store to execute the traversal. So the current String based method is actually more efficient.

    We do see great value in a fluent api though. We're working on a solution for that right now. It will likely take the form of RemoteGraph so you'll have a graph object that is similar for traversals. We're also working in the community on TINKERPOP-1278 to make traversals much more idiomatic across languages. So the reason why it's taking a bit of time to get this better experience is that we're trying to make sure it's 1) done efficiently and 2) that it's done correctly from the TinkerPop foundation up through DSE Graph.

    In conjunction with the RemoteGraph interface for traversals, we'll have a fluent api to do updates.

    You can have a look at the complete discussion and track the issue here: https://github.com/datastax/java-driver-dse/issues/42 (moved to Jira)

    https://datastax-oss.atlassian.net/browse/JAVA-1250

    Unfortunately you either need to stick with gremlin qraph queries for everything as a String or keep using Titan till Datastax DSE APIs are ready.