【问题标题】:Using a new KeySpaces in Titan Cassandra and persisting data在 Titan Cassandra 中使用新的 KeySpaces 并持久化数据
【发布时间】:2013-08-14 04:26:18
【问题描述】:

我刚刚开始使用 Titan 而不是 Cassandra。我是 Titan 的新手,也是图形数据库概念的新手。只需按照 github 和 wiki 上的说明进行操作。

Configuration conf = new BaseConfiguration();
conf.setProperty("storage.backend", "cassandra");
conf.setProperty("storage.hostname", "127.0.0.1");
TitanGraph g = TitanFactory.open(conf);

这就是我打开图表的方式。

我了解默认键空间是titan。我在默认键空间中创建了一些节点和关系。我对顶点进行了索引并查询了节点并能够遍历结果。

现在我的问题 -

1) 如何设置新的密钥空间?

我尝试使用该属性

conf.setProperty("storage.keyspace ", "newkeyspace");

不幸的是,当我检查 cassandra 键空间时,我只能找到 titan。没有名称为 newkeyspace 的键空间。可能是什么原因?

2) 如何持久化已创建的图表?

例如,

g.createKeyIndex("name", Vertex.class);
Vertex juno = g.addVertex(null);
juno.setProperty("name", "juno");
juno.setProperty("type", "node");
Vertex juno1 = g.addVertex(null);
juno1.setProperty("name", "juno");
juno1.setProperty("type", "node1");

这是一个示例图。一旦我发出表单查询

Iterator<Vertex> junoIterator = g.getVertices("name", "juno")
                .iterator();
        while (junoIterator.hasNext()) {
            Vertex vertex = (Vertex) junoIterator.next();
            System.out.println(vertex.getProperty("type"));
        }

我的预期结果是

node 
node1

一旦我评论以下部分,相同的查询应该可以正常工作 -

    /*g.createKeyIndex("name", Vertex.class);
        Vertex juno = g.addVertex(null);
        juno.setProperty("name", "juno");
        juno.setProperty("type", "node");
        Vertex juno1 = g.addVertex(null);
        juno1.setProperty("name", "juno");
        juno1.setProperty("type", "node1");*/

在这里,我认为节点、关系和索引已经构建并保存在某个数据存储中。我是不是信仰错误?

请指教。

【问题讨论】:

    标签: graph-databases titan


    【解决方案1】:

    我已经解决了这个问题。只是一个承诺的问题。

    一行g.commit(); 解决了所有问题。

    【讨论】:

      【解决方案2】:

      要创建一个新的 Titan 表(cassandra 中的键空间),请使用以下属性:

      set("storage.cassandra.keyspace","TitanTest")

      整个命令应该是这样的:

      图 = TitanFactory.build()。 设置(“存储。后端”,“卡桑德拉”)。 set("storage.hostname","127.0.0.1").set("index.search.backend","elasticsearch").set("storage.cassandra.astyanax.cluster-name","Test Cluster")。 set("storage.cassandra.keyspace","TitanTest").set("cache.db-cache","true").open();

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-09-03
        • 1970-01-01
        • 2017-01-16
        • 1970-01-01
        • 2020-10-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多