Store Gremlin graph in local DynamoDB

走远了吗. 提交于 2019-11-28 08:50:17

问题


Instead of using AWS, I am using its local available DynamoDB database and creating a graph in the Gremlin console.

My PC is using Gremlin-version=3.0.1.incubating and Titan-version=1.0.0

My question: How to save a graph in my local DynamoDB so that I can retrieve it back whenever I wish? (E.g. after computer restart).

I have tried a lot, using save() or commit() graph. But I always got an error:

g.commit()
No signature of method: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph
  .GraphTraversalSource.commit() is applicable for argument types: () values: []
Possible solutions: wait(), computer(), collect(), wait(long), computer(java.lang.Class), collect(groovy.lang.Closure)

I am using Tinkerpop 3.


回答1:


Relevant documentation links:

  • Amazon DynamoDB Storage Backend for Titan
  • Running DynamoDB on Your Computer

As Filipe mentioned, g.commit() throws an exception because there is no commit() method on g which is a GraphTraversalSource. I suggested that you use graph.tx().commit(), where graph.tx() gets the Transaction from the Graph. In the comments we found out that you were trying to commit() a transaction on a TinkerGraph, which does not support transactions.

You need to instantiate a TitanGraph, not a TinkerGraph. This commonly done with a properties file, and there is a DynamoDB Local example properties file in the dynamodb-titan-storage-backend repository. Make sure to update the storage.dynamodb.client.endpoint to match your configuration. If you are using the Titan Server directions from the DynamoDB-Titan link, the port is 4567. If you are using the directions from the DynamoDB local link above, the default port is 8000.

gremlin> graph = TitanFactory.open('conf/gremlin-server/dynamodb-local.properties')
==>standardtitangraph[com.amazon.titan.diskstorage.dynamodb.DynamoDBStoreManager:[127.0.0.1]]
gremlin> v0 = graph.addVertex('name', 'jason'); v1 = graph.addVertex('name', 'mustaffa'); v0.addEdge('helps', v1)
==>e[175-39k-1lh-374][4232-helps->4144]
gremlin> graph.tx().commit()
==>null

Also note, the DynamoDB-Titan directions end up starting an in-memory DynamoDB Local instance. This behavior can be changed by commenting out the -inMemory argument the pom.xml.




回答2:


You are attempting to commit your traversal g. You should be attempting to commit your graph like so: graph.commit().

g is the traversal which is initialised as such: g = graph.traversal() and it cannot be committed.



来源:https://stackoverflow.com/questions/40841236/store-gremlin-graph-in-local-dynamodb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!