Q:

Error while using BatchGraph with TitanGraph

I am trying to load the data in Titan using BatchGraph. With TitanGraph as a object parameter.
According to Batch Implementation by Tinkerpop, This is how implementation should be:
TitanGraph g = TitanFactory.open("titan-cassandra.properties");
BatchGraph bgraph = new BatchGraph( g, VertexIDType.STRING, 1000);

But In BatchGraph constructor requires the TrasanctionalGraph object. So when I cast it as :
TitanGraph g = TitanFactory.open("titan-cassandra.properties");

 BatchGraph bgraph = new BatchGraph( (TransactionalGraph) g, VertexIDType.STRING, 1000)

This gives following error:
Exception in thread "main" java.lang.ClassCastException:
com.thinkaurelius.titan.graphdb.database.StandardTitanGraph cannot be cast to com.tinkerpop.blueprints.TransactionalGraph

How to use BatchGraph in this case? How it can be handled? 
I am using Titan 1.0.0 and Blueprints 2.7.0 with cassandra version 2.2.4.
Thanks.

A:

You can't use BatchGraph from Blueprints (TinkerPop 2.x) with Titan 1.0. They are not compatible.  Titan 1.0 supports TinkerPop 3.x and there is no BatchGraph in TinkerPop 3.x.
BatchGraph is pretty simple to recreate. It basically just hides a cache of newly inserted vertices that tracks their ids for future lookup.  Using this in-memory cache will be faster than Titan's index lookups.  You could use existing caches like guava to replicate this.
If your graph is very large, you can load your data with BLVP (BulkLoaderVertexProgram). There is some demonstration of that here. Note that the link to BLVP above is to the version currently supported by Titan 1.0.0 - the documentation and support has improved for the future 1.1.0 found here. There are also better examples of BLVP usage with Spark and other providers.

