【问题标题】:Store Gremlin graph in local DynamoDB将 Gremlin 图存储在本地 DynamoDB 中
【发布时间】:2017-04-11 23:51:51
【问题描述】:

我没有使用 AWS,而是使用其本地可用的 DynamoDB 数据库并在 Gremlin 控制台中创建图表。

我的电脑正在使用Gremlin-version=3.0.1.incubatingTitan-version=1.0.0

我的问题:如何将图表保存在我的本地 DynamoDB 中,以便我可以随时取回它? (例如在计算机重新启动后)。

我已经尝试了很多,使用save()commit() 图表。但我总是报错:

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)

我正在使用Tinkerpop 3

【问题讨论】:

    标签: titan gremlin gremlin-server


    【解决方案1】:

    相关文档链接:

    正如 Filipe 所提到的,g.commit() 会引发异常,因为在 g 上没有 commit() 方法 GraphTraversalSource。我建议您使用graph.tx().commit(),其中graph.tx()Graph 获取Transaction。在 cmets 中,我们发现您试图在不支持事务的 TinkerGraph 上进行 commit() 事务。

    您需要实例化 TitanGraph,而不是 TinkerGraph。这通常使用properties file 完成,dynamodb-titan-storage-backend 存储库中有一个 DynamoDB Local example properties file。确保更新storage.dynamodb.client.endpoint 以匹配您的配置。如果您使用来自 DynamoDB-Titan 链接的 Titan 服务器说明,则端口为 4567。如果您使用上述 DynamoDB 本地链接中的说明,则默认端口为 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
    

    另请注意,DynamoDB-Titan 方向最终会启动内存中的 DynamoDB Local 实例。可以通过将 -inMemory 参数注释掉 pom.xml 来更改此行为。

    【讨论】:

    • 可能会有所帮助我一定会注意到它并回来顺便说一句感谢您的精彩建议..! :)
    【解决方案2】:

    您正在尝试提交您的遍历g。您应该尝试像这样提交您的图表:graph.commit()

    g 是这样初始化的遍历:g = graph.traversal(),它不能被提交。

    【讨论】:

    • 嘿,我已经使用上面的命令尝试过了,但它显示以下错误:graph.commit() No signature of method: org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph.commit () 适用于参数类型:() 值:[] 可能的解决方案:compute()、compute(java.lang.Class)、wait()、collect()、wait(long)、collect(groovy.lang.Closure ) 显示堆栈跟踪? [yN] 你能解决这个问题吗.....
    • TinkerGra‌ph 只是一个内存图,因此无法提交。检查您如何初始化图表。因为看起来你正试图在发电机上使用泰坦,你应该看看here
    • 绝对正确,因为我在它上面使用了 Titan。但我不知道如何保存图表并检索它
    • 您错误地初始化了 TinkerGraph。你应该初始化一个泰坦图,详细here
    • graph.tx().commit()
    猜你喜欢
    • 2017-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多