【问题标题】:Cassandra keyspace in Titan graph data baseTitan 图数据库中的 Cassandra 键空间
【发布时间】:2013-07-05 06:58:46
【问题描述】:

我使用 Cassandra 作为后端,并使用以下属性在 gremlin 中创建了一个密钥空间

conf=new BaseConfiguration();
conf.setProperty('storage.backend','cassandra');
conf.setProperty('storage.hostname','127.0.0.1');
conf.setProperty('storage.keyspace','MyTitanKeySpace');
g=TitanFactory.open(conf);  //opening graph with configuration

Now I'm adding vertices namely subbu and sures and one relation between them

gremlin> Subbu=g.addVertex(null);// adding vertex name Subbu
==>v[4]
gremlin> Sures=g.addVertex(null);
==>v[8]
gremlin> Subbu.setProperty("name","subbu"); //assigning name Subbu to the vertex
==>null
gremlin> Sures.setProperty("name","sures");
==>null
gremlin> edge=g.addEdge(null,Subbu,Sures,'friends');//creating edge

==>e[x-8-2F0LaTPQAS][4-friends->8]

gremlin>g.commit();//save graph
gremlin>g.V
v[4]
v[8]

Now I'm creating one more graph with same key space name

f==TitanFactory.open(conf);

现在我正在添加顶点,即 Muthu 和 Saran 以及它们之间的一种关系

gremlin> Muthu=f.addVertex(null); // adding vertex name Subbu
==>v[12]
gremlin> Saran=f.addVertex(null);
==>v[16]
gremlin> Muthu.setProperty("name","Muthu");//setting name to the vertex
==>null
gremlin> Saran.setProperty("name","Saran");
==>null
gremlin> edge=g.addEdge(null,Muthu,Saran,'friends');//creating edge

==>e[x-12-2F0LaTPQAS][12-friends->16]

gremlin>f.commit();//save graph
gremlin>f.V //displaying all vertices in graph f
v[4]
v[8]
v[12]
v[16]
It is showing all vertices in the key space but i want only particular graph vertices how it is possible why it is showing all vertices ?

有人可以回复我吗?

【问题讨论】:

    标签: cassandra gremlin titan


    【解决方案1】:

    也许你对TitanFactory.open 的所作所为感到困惑。你写:

    Now I'm creating one more graph with same key space name
    
    f==TitanFactory.open(conf);
    

    您不是在使用该代码“再创建一个图形”,而是在与该方法的第一次调用相同的键空间中连接到相同的 Cassandra 实例。这是同一张图,所以当您查看所有带有g.V 的顶点时,您会看到在第一个连接中添加的顶点和在第二个连接中添加的顶点。

    如果您尝试共享单个 Cassandra 实例,则需要在调用 TitanFactory.open(conf) 之前将 conf 中的键空间设置更改为不同的键空间,在这种情况下,图表应该是分开的。

    【讨论】:

      【解决方案2】:
      I did like this it is working fine
      gremlin> g = TitanFactory.open(conf)
          gremlin> pg = new PartitionGraph(g, '_partition', 'a')
          ==>partitiongraph[titangraph[inmemory:null]]
          gremlin> Subbu = pg.addVertex(null)
          ==>v[4]
          gremlin> Sures = pg.addVertex(null)
          ==>v[8]
      etc...
      

      【讨论】:

      • 我们可以删除和设置分区 pg.removeReadPartition('a') ==>null gremlin> pg.setWritePartition('b') ==>null gremlin> pg.addReadPartition('b') ==>空
      猜你喜欢
      • 2016-09-03
      • 2015-05-13
      • 2023-03-27
      • 2016-08-04
      • 1970-01-01
      • 2018-04-08
      • 2017-06-23
      • 2015-01-01
      • 1970-01-01
      相关资源
      最近更新 更多