Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
421 views
in Technique[技术] by (71.8m points)

titan - Store Gremlin graph in local DynamoDB

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Relevant documentation links:

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...