Populating a Stardog graph through gremlin console?

1 view
Skip to first unread message

jesusbarra...@gmail.com

unread,
Dec 31, 2015, 7:43:40 AM12/31/15
to Stardog
Hi,
I can load the Graph Modern example from the Gremlin console as described in the docs:
graph.io(graphml()).readGraph('data/tinkerpop-modern.xml')

Is there any doc/examples on how to generalise this? What is the file format and what other formats are valid?

Also, is it possible to do transactional updates to the Stardog graph from Gremlin?
Things like createVertex, createEdge, addProperty, updateProperty... (these are made up names, but I guess the idea is clear). Again, any examples?

I've unsuccessfully tried this:

gremlin> v = g.addVertex('http://mytest.com/individual1')

No signature of method: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource.addVertex() is applicable for argument types: (java.lang.String) values: [http://mytest.com/individual1]

Display stack trace? [yN] 



gremlin> g.V("http://mytest.com/MembershipRole").testJB = 'val'

No such property: testJB for class: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal

Display stack trace? [yN] 


Thanks,


JB.

Edgar Rodriguez

unread,
Dec 31, 2015, 5:29:52 PM12/31/15
to sta...@clarkparsia.com
Hello,


On Thu, Dec 31, 2015 at 7:43 AM, <jesusbarra...@gmail.com> wrote:
Hi,
I can load the Graph Modern example from the Gremlin console as described in the docs:
graph.io(graphml()).readGraph('data/tinkerpop-modern.xml')

Is there any doc/examples on how to generalise this? What is the file format and what other formats are valid?

For more information on this you may want to take a look at TinkerPop3's IO documentation in [1].
 

Also, is it possible to do transactional updates to the Stardog graph from Gremlin?
Things like createVertex, createEdge, addProperty, updateProperty... (these are made up names, but I guess the idea is clear). Again, any examples?

Yes, you can do it directly on the graph object handling the transaction manually as described in [2]:

```
gremlin> graph.tx().close() // close any transaction left open (maybe you'll need to commit/rollback if there are pending changes
==>null
gremlin> graph.tx().open()
==>null
gremlin> meV.property('name', 'Edgar')
==>vp[name->Edgar]
gremlin> graph.tx().commit()
gremlin> graph.tx().close()
==>null
gremlin> g.V().has('name', 'Edgar')
```

For more information on TP3 `Graph` API, please refer to [3].

You could do the same via the `g` object, which is a `GraphTraversalSource`:

gremlin> g.tx().close()
==>null
gremlin> g.tx().open()
==>null
gremlin> g.addV('name', 'stardog', 'lang', 'java')
gremlin> g.tx().commit()
==>null
gremlin> g.tx().close()
==>null
 
You may want to take a look at the full TinkerPop3 JavaDocs in [4].

gremlin> g.V("http://mytest.com/MembershipRole").testJB = 'val'

No such property: testJB for class: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal

Display stack trace? [yN] 


jesusbarra...@gmail.com

unread,
Jan 1, 2016, 6:15:43 PM1/1/16
to Stardog
Really useful stuff!

Gracias Edgar :)
Reply all
Reply to author
Forward
0 new messages