Question about import/export in Titan (with GraphML)

2,021 views
Skip to first unread message

Kevin Schumacher

unread,
Jan 10, 2014, 10:52:08 AM1/10/14
to aureliu...@googlegroups.com
Hello all, 

We're trying to find a way to migrate our graph from one instance of Titan to another. Since our graph is pretty small at this point and downtime is acceptable, I was thinking I could use GraphML for this. I've successfully exported the graph using the below method, but I'm having trouble with import. 

Here is my gremlin script (pretty straightforward, according to the tinkerpop docs here):


Export:
g = TitanFactory.open('/opt/titan/conf/titan-cassandra-es.properties')
out = new FileOutputStream("titan-graph.graphml")
GraphMLWriter.outputGraph(g, out)
This outputs a GraphML file just fine (at least, it doesn't print any errors to the console and it looks like an XML file).

Import:
g = TitanFactory.open('/opt/titan/conf/titan-cassandra-es.properties')
in_stream = new FileInputStream("titan-graph.graphml")
GraphMLReader.inputGraph(g, in_stream)

When I try to run the above script to import, however, I get the following error message:
Key with given name does not exist

Immediately before import I am doing a titan.sh clean, so all data is being removed. Is there something else I need to do? 

I'd also be interested in better ways to do this -- especially ones that are more scaleable. 

Thanks in advance,
Kevin

Marko Rodriguez

unread,
Jan 10, 2014, 12:22:29 PM1/10/14
to aureliu...@googlegroups.com
Hello Kevin,

When you create your fresh TitanDB, be sure to define your schema -- g.makeType(),etc.

HTH,
Marko.
--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Kevin Schumacher

unread,
Jan 10, 2014, 1:47:11 PM1/10/14
to aureliu...@googlegroups.com
Marko, 

I am executing makeKey for every vertex and edge property present in the GraphML, per your suggestion (also making the edge labels). I am still seeing the issue, however. Is there a way to determine which key hasn't been made? 

The only key defined at the top of the graphml that I don't explicitly create is:


The only key which I am not explicitly creating is _type. The value I see on all the nodes is "vertex". Is this automatically created by Titan or did I do this without realizing it? 

If it's Titan-specific, what should its datatype be? Just string? 

Thanks,
Kevin

Kevin Schumacher

unread,
Jan 10, 2014, 1:50:12 PM1/10/14
to aureliu...@googlegroups.com
Sorry for the double post -- I made the key for "_type" but the issue persists. How can I tell which key it's looking for?

ankur....@olacabs.com

unread,
Jun 15, 2016, 12:04:52 PM6/15/16
to Aurelius
In the export code above -
g = TitanFactory.open('/opt/titan/conf/titan-cassandra-es.properties')
out = new FileOutputStream("titan-graph.graphml")
GraphMLWriter.outputGraph(g, out)
Titan 1.0 does not identify 'outputGraph'. Is there an updated way of exporting to a graphml file?

Error - 
No signature of method: static org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLWriter.outputGraph() is applicable for argument types: (com.thinkaurelius.titan.graphdb.database.StandardTitanGraph, java.io.FileOutputStream) values: [standardtitangraph[cassandrathrift:[127.0.0.1]], java.io.FileOutputStream@5d7f8467]

Thanks!
Ankur

Daniel Kuppitz

unread,
Jun 15, 2016, 12:11:01 PM6/15/16
to aureliu...@googlegroups.com
Titan 1.0 uses TP3, your code uses the TP2 approach.

Try this:

graph.io(IoCore.graphml()).readGraph("titan-graph.graphml");

And:

graph.io(IoCore.graphml()).writeGraph("titan-graph.graphml");


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.

Ankur Gahlot

unread,
Jun 16, 2016, 5:57:08 AM6/16/16
to aureliu...@googlegroups.com
Thanks Daniel!

This works.

-Ankur

Reply all
Reply to author
Forward
0 new messages