What's the current way to load GraphML data from the console?

1,215 views
Skip to first unread message

Devin Bost

unread,
Jul 10, 2019, 7:08:19 PM7/10/19
to Gremlin-users
Hi,

I've gone through the docs and tried several different approaches to loading a GraphML file from the console, but none are working.

I tried:
g = new TinkerGraph(); g.loadGraphML('/Users/dbost/src/fastDeploy_to_graphML/example.graphml')


and got:


java.lang.NullPointerException
at org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph.selectIdManager(TinkerGraph.java:524)
at org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph.<init>(TinkerGraph.java:112)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
. . . 



I tried:
g = new TinkerGraph(); g.io("/Users/dbost/src/fastDeploy_to_graphML/example.graphml").read().iterate()

and got:


java.lang.IllegalStateException: Could not detect the file format - specify the writer explicitly or rename file with a standard extension
at org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IoStep.detectFileType(IoStep.java:216)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters.get(Parameters.java:107)
. . . 



I tried:


test = GraphMLReader.inputGraph(g, new FileInputStream('/Users/dbost/src/fastDeploy_to_graphML/example.graphml'))


and got:


groovy.lang.MissingMethodException: No signature of method: static org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLReader.inputGraph() is applicable for argument types: (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource...) values: [graphtraversalsource[tinkergraph[vertices:6 edges:6], standard], ...]
at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1525)
at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1511)




How do I actually get my GraphML data into Gremlin?


Thanks,

Devin


 

Stephen Mallette

unread,
Jul 11, 2019, 6:35:27 AM7/11/19
to gremli...@googlegroups.com
Looks like you're mixing a lot of syntax from different versions of Gremlin going back to TinkerPop 1.x. For the most current release of 3.4.2 you would do what is shown here:


As i look at that now, we make the assumption that the user realizes what "g" is - a GraphTraversalSource which you obtain from a Graph instance. So really:

graph =  TinkerGraph.open()
g = graph.traversal()
g.io("graph.xml").read().iterate()

Note that your file extension needs to be ".xml" and not ".graphml" for auto-detection of the type of reader (otherwise it must be specified explicitly using additional configuration. The general form of the operation is described here:






--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/1ac19892-acfc-40de-ab81-146a00e5d186%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Devin Bost

unread,
Jul 11, 2019, 6:55:13 PM7/11/19
to Gremlin-users
Thanks! That works great!
To unsubscribe from this group and stop receiving emails from it, send an email to gremli...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages