Search code examples
cassandratitantinkerpoprexster

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.


Solution

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