簡體   English   中英

泰坦圖數據庫中的Cassandra鍵空間

[英]Cassandra keyspace in Titan graph data base

我使用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 ?

有人可以回復我嗎?

也許您對TitanFactory.open在做什么感到困惑。 你寫:

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

f==TitanFactory.open(conf);

您不會使用該代碼“再創建一個圖”,而是在與該方法的第一次調用相同的鍵空間中連接到同一Cassandra實例。 它是同一張圖,因此當您使用gV查看所有頂點時,您將看到在第一個連接中添加的頂點和在第二個連接中添加的頂點。

如果要共享一個Cassandra實例,則需要在調用TitanFactory.open(conf)之前將conf的鍵空間設置更改為其他鍵空間,在這種情況下,圖形應分開。

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...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM