Frames Support with Titan DB 0.9.0-M2 - cassandra

I would like to use Titan 0.9.0-M2 for a feature that it offers over 0.5.4 but I am using Frames heavily and it looks like the TitanGraph class no longer implements the Tinkerpop Graph class. Without this, you cannot make a FramedGraph from a TitanGraph nor can you use MigrateGraph.
Any suggestions? Is there a reason why a Graph Database framework built on TinkerPop is no longer implementing their classes? Is there any support for using the basic Frames API with Titan or has Titan implemented some support for this elsewhere?

Figured it out. Looks like the Titan 0.9.0-M2 API is implementing the TinkerPop3 classes. The namespace has changed to org.apache.tinkerpop and there is currently not mention of Frames, only Gremlin in the 3.0.0-incubating release. Looks like I'm gonna have to make due with 0.5.4.

Related

Is there a framework available which could help me in testing DAOs

My Scala Play application uses cassandra database. I want to unit-test the DAO classes. I have created but I don't know if there is a framework which is specifically built for this. Is there one?
I can't say about DAO classes in Play framework, but usually you can use either embedded-cassandra or cassandra-unit for unit testing of applications that are working with Cassandra.

Using gremlin-python Janus for social networking application

I'm getting started with graph databases. I want to migrate a social networking application from sql to Janus Graph database. I plan to build the application using Python Django framework.
I also plan to scale the application using using IBM's ComposeForJanusGraph in the future.
Problems I face:
1) I'm following the tinkerpop documentation for gremlin_python and I face several issues with the syntax because I couldn't find any good documentation. Only documentation I found here is also very short and not that helpful of how to do a CRUD. (For example how to create a new database, how to configure the search or storage database, how to create a node, how to create an edge, how to query for a vertex with a specific edge is not documented well clearly. None of them works when I try myself.)
2) Is there anything I should know before I learn and build it?
I couldn't find any good documentation. Only documentation I found here is also very short and not that helpful
Gremlin is Gremlin is Gremlin. It doesn't matter if it's Python or Java or C# or Javascript - it's all just Gremlin. Therefore, the documentation for Gremlin using Python is "short" because it simply shows how you initiate your GraphTraversalSource that allows you to spawn Traversal instances. From there, you have access to all the standard steps that Gremlin offers:
http://tinkerpop.apache.org/docs/current/reference/#graph-traversal-steps
and therefore the remainder of the documentation basically applies to your needs. The main bit of trickery to consider is that some step names conflict with Python reserved words - in those case, the step is post-fixed with a underscore and thus, the in() step for Java becomes in_() in Python.
For example how to create a new database, how to configure the search or storage database,
You won't find this in TinkerPop documentation really. How you create/configure a TinkerPop Graph implementation is specific to the graph database that you choose. You typically won't do that in Python. You will resort to the approach provided by your graph. If your graph is JanusGraph on IBM Compose, you should consult their documentation. You will only connect to that graph once established with gremlin-python.
how to create a node, how to create an edge,
It's just Gremlin. Gremlin has steps for mutating a Graph so to add a vertex and and to add an edge so to create two vertices and an edge between them I can string together a single traversal that does that:
g.addV('person').property('name','cegprakash').as('c').
addV('question').property('title','Using gremlin-python Janus for social networking application').as('q1').
addV('question').property('title','Working of CCD algorithm for Inverse Kinematics').as('q2').
addE('asks').property('votes',0).from('c').to('q1').
addE('asks').property('votes',1).from('c').to('q2').iterate()
how to query for a vertex with a specific edge is not documented well clearly.
Again, it's just Gremlin and there are plenty of examples.
g.V().has('person','name', 'cegprakash').
out('asks').
has('votes',gt(0))
So the above, says to find a vertex with the name "cegprakash", then traverse all the outgoing edges labelled "ask" with a "vote" property that has values greater than zero.
Is there anything I should know before I learn and build it?
If you haven't worked with graphs before, just start simple. Use TinkerGraph and the Gremlin Console to get familiar with the Gremlin language and then start looking into how JanusGraph is configured and operated under Compose. At that point you'll have a good basis for digging into how your application will actually work and if necessary asking more specific questions.

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:
org.apache.tinkerpop.gremlin.structure.Graph g = GraphFactory.open(configurationFile);
The configuration file in parameter refers to the TitanFactory class which return an implementation of the tinkerpop Graph interface
(gremlin.graph=com.thinkaurelius.titan.core.TitanFactory)
Is there any equivalent in DSE Graph API?
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.

What is the best way to expose Cassandra REST API to web?

I would like to work with Cassandra from javascript web app using REST API.
REST should support basic commands working with DB - create table, select/add/update/remove items. Will be perfect to have something similar to odata protocol.
P.S. I'm looking for some library or component. Java is a most preferred.
Staash solution looks perfect for the task - https://github.com/Netflix/staash
You can use DataStax drivers. I used it via Scala but you can use Java, a Session object is a long-lived object and it should not be used in a request/response short-lived fashion but it's up to you.
ref. rules when using datastax drivers
There is no "best" language for REST APIs, it depends on what you're comfortable using. Virtually all languages will be able to do this reasonable well, depending on your skill level.
The obvious choice is probably java, because cassandra's written in java, the java driver from Datastax is well supported, and because it's probably pretty easy to find some spring REST frameworks to do what you want. Second beyond that would be python - again, good driver support and REST frameworks with things like django or flask+potion. Ruby driver isn't bad, lots of ruby REST APIs out there, too.

Cassandra Titan create own DB

I am starting with titan and i am really loosing in it. I created my own graph databse model with tables(Vertices) and relations(Edge). Well, now I want to create my DB, but I cannot find any good tutorial. How to build scripts? Do you have same example how to create own verticles and edges?
Thx.
If you are new to graphs and new to Titan, start here:
http://s3.thinkaurelius.com/docs/titan/0.5.4/getting-started.html
If you don't follow that then recognize that Titan implements the Blueprints interfaces (i.e. TinkerPop) and thus is accessible via the Gremlin graph traversal language:
https://github.com/tinkerpop/gremlin/wiki/Getting-Started
There are plenty of resources available that explain how these things work. Consider looking at GremlinDocs as well as Sql2Gremlin as well.

Resources