Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete graph in Titan with Cassandra storage backend?

I use Titan 0.4.0 All, running Rexster in shared VM mode on Ubuntu 12.04.

How could I properly delete a graph in Titan which is using the Cassandra storage backend?

I have tried the TitanCleanup.clear(graph), but it does not delete everything. The indices are still there. My real issue is that I have an index which I don't want (it crashes every query), however as I understand Titan's documentation it is impossible to remove an index once it is created.

like image 994
Automatico Avatar asked Oct 20 '13 12:10

Automatico


4 Answers

For the continuation of Titan called JanusGraph, the command is JanusGraphFactory.clear(graph) but is soon to be JanusGraphCleanup.clear(graph).

like image 52
rjurney Avatar answered Oct 23 '22 00:10

rjurney


You can clear all the edges/vertices with:

g.V.remove()

but as you have found that won't clear the types/indices previously created. The most cleanly option would be to just delete the Cassandra data directory.

If you are executing the delete via a unit test you might try to do this as part of your test setup:

this.config = new BaseConfiguration(){{
    addProperty("storage.backend", "berkeleyje")
    addProperty("storage.directory", "/tmp/titan-schema-test")
}}
GraphDatabaseConfiguration graphconfig = new GraphDatabaseConfiguration(config)
graphconfig.getBackend().clearStorage()
g = (StandardTitanGraph) TitanFactory.open(config)

Be sure to call g.shutdown() in your test teardown method.

like image 35
stephen mallette Avatar answered Oct 23 '22 00:10

stephen mallette


Just to update this answer.

With Titan 1.0.0 this can be done programmatically in Java with:

TitanGraph graph = TitanFactory.open(config);
graph.close();
TitanCleanup.clear(graph);
like image 21
Filipe Teixeira Avatar answered Oct 23 '22 01:10

Filipe Teixeira


As was mentioned in one of the comments to the earlier answer DROPping a keyspace titan using cqlsh should do it:

cqlsh> DROP KEYSPACE titan;

The name of the keyspace Titan uses is set up using storage.cassandra.keyspace configuration option. You can change it to whatever name you want and is acceptable by Cassandra.

storage.cassandra.keyspace=hello_titan

When Cassandra is getting up, it prints out the keyspace's name as follows:

INFO 19:50:32 Create new Keyspace: KSMetaData{name=hello_titan, strategyClass=SimpleStrategy, strategyOptions={replication_factor=1}, cfMetaData={}, durableWrites=true, userTypes=org.apache.cassandra.config.UTMetaData@767d6a9f}

In 0.9.0-M1, the name appears in Titan's log in DEBUG (set log4j.rootLogger=DEBUG, stdout in conf/log4j-server.properties):

[DEBUG] AstyanaxStoreManager - Found keyspace titan

or the following when it doesn't:

[DEBUG] AstyanaxStoreManager - Creating keyspace titan...
[DEBUG] AstyanaxStoreManager - Created keyspace titan
like image 1
Jacek Laskowski Avatar answered Oct 23 '22 01:10

Jacek Laskowski