graph-databases - 在 Titan Cassandra 中使用新的 KeySpaces 并持久化数据

标签 graph-databases titan

我刚刚开始在 Cassandra 上使用 Titan。我是 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);

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

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

现在我的问题 -

1) 如何设置新的 key 空间?

我尝试使用该属性
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");*/

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

请指教。

最佳答案

我已经弄清楚了这个问题。只是一个 promise 的问题。

单行g.commit();解决这一切。

关于graph-databases - 在 Titan Cassandra 中使用新的 KeySpaces 并持久化数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18223196/

相关文章:

graph-databases - 小 Sprite .match()

scala - Scala 中的 Cypher 查询

solr - 如何在Titan图形服务器上利用ElasticSearch/Solr搜索API?

java - 在java中的gremlin titan中过滤出边数的顶点

mapreduce - GraphDB 查询和分片

elasticsearch - 如何保护 Titan - Elasticsearch 与 ssl/tls 的连接?

neo4j - 快速查询上的三元组与 native 图数据库

sql - 在多对多 SQL 表中查找数据关系或图形

graph-databases - Tinkerpop 嵌入式生产实现

amazon-dynamodb - 使用 Titan Graph DB 是正确的选择吗?