Reputation: 109
I used Cassandra as my back end and created a key space in gremlin using the following properties
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);
Now I'm adding vertices namely Muthu and Saran and one relation between them
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 ?
can any one reply me on this?
Upvotes: 0
Views: 1593
Reputation: 109
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...
Upvotes: 0
Reputation: 46206
Perhaps you are confused by what TitanFactory.open
is doing. You write:
Now I'm creating one more graph with same key space name
f==TitanFactory.open(conf);
You aren't "creating one more graph" with that code, you are connecting to the same Cassandra instance in the same key space as the first call of that method. It is the same graph, so when you view all vertices with g.V
you will see vertices added in the first connection and vertices added in the second connection.
If you are trying to share a single Cassandra instance then you need to change the keyspace setting in the conf
to a different keyspace prior to calling TitanFactory.open(conf)
in which case the graphs should be separate.
Upvotes: 4