【问题标题】:Creating graph in titan from data in csv - example wiki.Vote gives error从 csv 中的数据创建 Titan 图形 - 示例 wiki.Vote 给出错误
【发布时间】:2015-06-25 21:04:36
【问题描述】:

我是 Titan 新手 - 我加载了 Titan 并成功运行了 GraphOfTheGods 示例,包括给出的查询。接下来我继续尝试批量加载 csv 文件以创建图形并按照十的幂 - 第 1 部分中的步骤http://thinkaurelius.com/2014/05/29/powers-of-ten-part-i/

我在加载 wiki-Vote.txt 时遇到错误

gremlin> g = TitanFactory.open("/tmp/1m") Backend shorthand unknown: /tmp/1m 

我试过了:

g = TitanFactory.open('conf/titan-berkeleydb-es.properties’)

但是在 load-1m.groovy 的下一步中会出错

==>titangraph[berkeleyje:/titan-0.5.4-hadoop2/conf/../db/berkeley] No signature of method: groovy.lang.MissingMethodException.makeKey() is applicable for argument types: () values: [] Possible solutions: every(), any()

任何提示下一步该做什么?我是第一次使用 groovy。与 gremlin 合作需要什么样的 groovy 专业知识

【问题讨论】:

    标签: graph titan bulk-load


    【解决方案1】:

    该博文适用于 Titan 0.4.x。当 Titan 升级到 0.5.x 时,API 发生了变化。帖子中讨论的相同原则通常适用于数据加载,但语法有所不同。目的是在 Titan 1.0 完全支持 TinkerPop3 时以某种形式更新这些帖子。在此之前,您需要将这些代码示例转换为修改后的 API。

    例如,创建 berkeleydb 数据库的一种简单方法是:

    g = TitanFactory.build()
        .set("storage.backend", "berkeleyje")
        .set("storage.directory", "/tmp/1m")
        .open();
    

    请参阅文档here。然后大部分模式创建代码(这是最大的变化)现在描述为herehere

    【讨论】:

    • 我在重新下载 0.5.4 时仍然遇到同样的 MissingMethodException.makeKey() 错误(完全使用博客文章中的代码 + 此更改)。
    • 想通了...看我的回答
    【解决方案2】:

    经过今天的大量实验,我终于弄明白了。需要进行大量更改:

    对于后代,这是应该可以工作的修改后的脚本(从 0.5.4 开始):

    g = TitanFactory.build().set("storage.backend", "berkeleyje").set("storage.directory", "/tmp/1m").open()
    
    m = g.getManagementSystem()
    k = m.makePropertyKey('userId').dataType(String.class).cardinality(Cardinality.SINGLE).make()
    m.buildIndex('byId', Vertex.class).addKey(k).buildCompositeIndex()
    m.makeEdgeLabel('votesFor').make()
    m.commit()
    
    getOrCreate = { id ->
      def p = g.V('userId', id)
        if (p.hasNext()) {
            p.next()
        } else {
            g.addVertex([userId:id])
        }
    }
    
    new File('wiki-Vote.txt').eachLine {
      if (!it.startsWith("#")){
        (fromVertex, toVertex) = it.split('\t').collect(getOrCreate)
        fromVertex.addEdge('votesFor', toVertex)
      }
    }
    
    g.commit()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-11-02
      • 2017-03-31
      • 1970-01-01
      • 1970-01-01
      • 2014-12-13
      • 2019-04-05
      • 2017-01-07
      相关资源
      最近更新 更多