Using TitanFactory.open instead of gremlin driver.

75 views
Skip to first unread message

Alex

unread,
Jul 22, 2016, 2:37:58 AM7/22/16
to Aurelius
I am working on a project using Titan (with cassandra as the backend). Most of the other team's modules are written in python, so they connect to gremlin-server via websockets.

Now, our team is using Java, and so far we've been using gremlin-driver for querying the database. I am wondering if instead we can do the following in our Java code:

Graph graph = TitanFactory.open("cassandra:localhost");
GraphTraversalSource g = graph.traversal();


That way we actually have a g object we can use to query, rather than submitting queries as strings to be interpreted by the gremlin-server and returned back to the driver. 

Is there a drawback of using the titan API given that my team is not the only one accessing the data?


Thanks.

Jason Plurad

unread,
Jul 22, 2016, 8:42:57 AM7/22/16
to Aurelius
Hi Alex,

Yes, that would work fine. If you are coding in a JVM language, you don't need to go through the Gremlin Server.

One thing you'll have to consider is the lifecycle of your Java app, especially since opening/closing the graph (and traversal source) can be an expensive operation. With the Gremlin Server, it loads the graph on startup and keeps it running until the server is shut down. As far as multiple open instances to the same graph, it would work fine.

-- Jason

Stephen Mallette

unread,
Jul 22, 2016, 9:03:52 AM7/22/16
to Aurelius
If you have single Titan database with mixed language access then I would say that a drawback of using the Titan API directly could be that you are not getting the most reuse out of your code as possible. In other words, if your java module and your python module are both doing the same kinds of things with their gremlin, you'll find the same code in two places. If you decide to embed Titan with the Java API then I would consider migrating reusable traversals from Python to java and then exposing them in Gremlin Server in some way to then be used by Python.  I suppose that none of this matters if the two modules are completely different. 

As an aside, I wonder what an environment like this will mean for GLVs. If I write my Gremlin in pure python how would i share that logic with a Gremlin written in pure js? i guess one would still have to centralize reusable bits on the server side to access them with yet to be fully determined GLV DSL patterns.  thinky thinky

--
You received this message because you are subscribed to the Google Groups "Aurelius" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aureliusgraph...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/aureliusgraphs/c0b5a265-448e-4e89-bbed-bdc70fe79ceb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages