Load example GraphSON file in Gremlin with Cassandra

802 views
Skip to first unread message

Yordi Verkroost

unread,
Apr 19, 2015, 1:51:50 PM4/19/15
to aureliu...@googlegroups.com
I'm trying to load the example Graph of the Gods file that is distributed with Titan with the loadGraphSON function. I have executed the following steps and are working with Titan 0.5.4 with Hadoop 2.

  1. Downloaded and unpacked a fresh Titan 0.5.4 with Hadoop 2.
  2. Started Titan, Rexster, Cassandra, ElasticSearch with the command
    bin/titan.sh -c cassandra-es start


  3. Run Gremlin with:
    bin/gremlin.sh


  4. Open a new TitanFactory instance with the required settings:
    g = TitanFactory.open('conf/titan-cassandra-es.properties')


  5. Then I tried to load the Graph of the Gods from the examples-directory with
    g.loadGraphSON("examples/graph-of-the-gods")



I do not get an error, but trying to show all vertices with g.V returns nothing. Am I executing the rights steps here, or am I doing something wrong?

Daniel Kuppitz

unread,
Apr 20, 2015, 5:50:09 AM4/20/15
to aureliu...@googlegroups.com
Hi Yordi,

1) the filename should be examples/graph-of-the-gods.json
2) you can also use GraphOfTheGodsFactory.load(g) which will also create indexes and type definitions
3) just for your info: it's not necessary to start Rexster, if you just want to check things out in the REPL

Cheers,
Daniel


--
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/92c206fb-5276-4c5e-b301-98a3e6c33932%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yordi Verkroost

unread,
Apr 20, 2015, 8:49:47 AM4/20/15
to aureliu...@googlegroups.com
Hi Daniel,

Thanks for your answer. The missing .json filetype was a typo, I'm sorry for that. When executing the loadGraphSON function with the proper file path, the JSON-file containing the Graph of the Gods is still not loaded into Gremlin (e.g. g.V returns no nodes).

gremlin> g.loadGraphSON("examples/graph-of-the-gods.json")
==>null
gremlin
> g.V
13:40:57 WARN  com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx  - Query requires iterating over all vertices [()]. For better performance, use indexes

I'm aware of the fact that I can use the built-in GraphofTheGodsFactory in this specific case (and this indeeds loads the Graph of the Gods successfully), but my final goal is to load a custom .json-file of a custom graph into Gremlin (or Rexster), in order to create and load a new Titan graph. Then, I would like to store this custom graph using the Cassandra storage backend.

My custom .json-file has the following syntax. I think this is the right way to represent a Titan graph in JSON, but please correct me if I'm wrong.

{"username": "AntonioAquino", "first_name": "Antonio", "last_name": "Aquino", "_outE": [{"_label": "knows", "_id": 16767, "_inV": 2199023293923}, ...], "creation_date": "2010-04-16T00:43:28.313+0000", "_inE": [{"_label": "hasCreator", "_id": 72, "_outV": 34359738458}, ...], "_id": 1099511693994, "type": "person"}

Regards,
Yordi

Op maandag 20 april 2015 11:50:09 UTC+2 schreef Daniel Kuppitz:

Daniel Kuppitz

unread,
Apr 20, 2015, 9:24:48 AM4/20/15
to aureliu...@googlegroups.com
The GraphSON file is made for use with GraphSONInputFormat. If you haven't done any Titan/Hadoop jobs yet, please check the Hadoop section in the docs: http://s3.thinkaurelius.com/docs/titan/0.5.4/hadoop.html
Once you know how to execute a Titan/Hadoop job, you will find a sample configuration under conf/hadoop/titan-graphson.properties to load the aforementioned GraphSON file.

Cheers,
Daniel


Stephen Mallette

unread,
Apr 20, 2015, 9:25:13 AM4/20/15
to aureliu...@googlegroups.com
just to close the loop here, the issue is discussed here on SO: http://stackoverflow.com/a/29746503/1831717

Charlie Harrison

unread,
Apr 20, 2015, 10:56:55 AM4/20/15
to aureliu...@googlegroups.com
Hi Yordi,


In a Gremlin shell it would be something like:

InputStream in = FileInputStream("examples/graph-of-the-gods.json")
GraphSONReader.inputGraph(g, in)

Hope that helps.

Cheers,

Charlie
Reply all
Reply to author
Forward
0 new messages