【发布时间】: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