Database Reference
In-Depth Information
BatchGraph bGraph = new BatchGraph<TITAN GRAPH
INSTANCE>,<VERTEX ID TYPE>,<BATCH SIZE>);
Using a bulk loading API, we can push a batch of records with a single database
call. That way graph data loading will always be faster.
Let's explore more about bulk loading in Titan with a sample Java recipe. In this
example, we will read data from a .csv file.
Figure 7-20 shows data in the format of User A following User B. Each user has
fname , lname, and twitter_tag as properties of the vertex, where an edge label
is following and contains a property value as Cassandra. Please note that you can find
the sample .csv file with source code for this topic under the src/main/re-
sources folder.
Figure 7-20 . A table showing the user-to-follower relationship
Follow these steps to complete the recipe:
1.
First, the common step is to configure a graph for Cassandra:
import
org.apache.commons.configuration.BaseConfiguration;
import
org.apache.commons.configuration.Configuration;
import
com.thinkaurelius.titan.core.TitanFactory;
import
com.thinkaurelius.titan.core.TitanGraph;
import
com.thinkaurelius.titan.core.TitanKey;Configuration
conf = new BaseConfiguration();
conf.setProperty("storage.backend",
"cassandrathrift");
conf.setProperty("storage.hostname",
"localhost");
 
 
Search WWH ::




Custom Search