store gremlin graph in local dynamodb

2019-01-28 07:42发布

问题:

Hey instead of using aws web I am using its local available 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 (after pc restart).

I have tried as many and give a lot time by using save() or commit() graph but in order that i always have 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, please help.

Thank You.

回答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.