【问题标题】:Errors when trying addVertex() and makeType()尝试 addVertex() 和 makeType() 时出错
【发布时间】:2015-06-13 19:19:10
【问题描述】:

我正在根据新网站的需求文档为我们的 SQLServer 指定一个新数据库。为了学习 Titan,我认为用它来记录架构会很有趣。

我的顶点代表一个表格;边缘将是记录表之间的关系并显示满足要求所需的用户权限。最终,这可能会增加为各种网页和边缘添加顶点以显示使用了哪些表。

我的问题是:我的环境设置是否正常,因为我在尝试创建自己的架构时不断出错?还是我做错了?

我下载了 TitanDB(下载了 0.5.4),能够导入 GraphOfTheGods 并使用它。

现在我正在尝试构建自己的图表,但在尝试添加顶点时遇到了异常。

gremlin> g = TitanFactory.build();
==>com.thinkaurelius.titan.core.TitanFactory$Builder@1950e8ac
gremlin> g.set("storage.backend","cassandra");
==>com.thinkaurelius.titan.core.TitanFactory$Builder@1950e8ac
gremlin> g.set("storage.hostname", IP.ADD.RESS.HERE);
==>com.thinkaurelius.titan.core.TitanFactory$Builder@1950e8ac
gremlin> g.open();
==>titangraph[Cassandra:[IP.ADD.RESS.HERE]]
gremlin> g.addVertex()
No signature of method: com.thinkaurelius.titan.core.TitanFactory$Builder.addVertex() is applicable for arguments types: () values: []
gremlin> g.addVertex(null)
No signature of method: com.thinkaurelius.titan.core.TitanFactory$Builder.addVertex() is applicable for arguments types: (null) values: [null]

.open(); 之后,我在存储引擎中看到了一个名为“titan”的新键空间。

所以我找到了这个(认为我需要定义类型):How to Define Data Type for Titan Graph DB Vertex?

当我尝试这个时: gremlin> graph.makeType().name("name").dataType(String.class).functional().makePropertyKey()

我明白了:groovysh_parse: 83: expecting anything but ''\n''; got it anyway @ line 83, column 79. functional().makePropertyKey()

感谢有关创建自己的图形结构的教程的任何帮助或指导。

【问题讨论】:

    标签: groovy schema graph-databases titan gremlin


    【解决方案1】:

    问题是TitanFactory.build() 返回一个TitanFactory$Builder 而不是titangraph。正是.open() 生成了您要使用的titangraph 实例。

    要做你想做的事,你需要改变:

    gremlin> graphBuilder = TitanFactory.build();
    ==>com.thinkaurelius.titan.core.TitanFactory$Builder@1950e8ac
    gremlin> graphBuilder.set("storage.backend","cassandra");
    ==>com.thinkaurelius.titan.core.TitanFactory$Builder@1950e8ac
    gremlin> graphBuilder.set("storage.hostname", IP.ADD.RESS.HERE);
    ==>com.thinkaurelius.titan.core.TitanFactory$Builder@1950e8ac
    gremlin> g = graphBuilder.open();
    ==>titangraph[Cassandra:[IP.ADD.RESS.HERE]]
    gremlin> g.addVertex()
    

    它应该按预期工作。

    【讨论】:

      猜你喜欢
      • 2017-10-13
      • 2018-07-22
      • 2015-08-16
      • 2023-01-26
      • 2020-05-17
      • 2011-12-27
      • 2014-07-15
      • 2018-03-03
      相关资源
      最近更新 更多