Skip to content

Commit

Permalink
improved titan support to support remote cassandra
Browse files Browse the repository at this point in the history
  • Loading branch information
ccjason committed Jun 22, 2016
1 parent 4f040d0 commit 1f0dc03
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public Graph open(String urlPath, String faction, String fmode) throws Unsupport
//log.setLevel()
System.setProperty("org.slf4j.simpleLogger.log.com.thinkaurelius.titan.graphdb.query.QueryProcessor", "info");
return g;
} else if (store.equals("hbase")) {
} else if (store.equals("hbase")) {
String hostname = LocatableGraphFactoryFactoryImpl.parseForURLParameter("&hostname=", urlPath);
if ("localhost".equals(hostname)) hostname = null;
BaseConfiguration conf = new BaseConfiguration();
Expand All @@ -69,18 +69,14 @@ public Graph open(String urlPath, String faction, String fmode) throws Unsupport
//g.createKeyIndex(idPropForId, Vertex.class);
//g.loadGraphML('data/onevertex.xml')
return g;
} else if (store.equals("cassandra")) {
} else if (store.equals("cassandra")) {
String hostname = LocatableGraphFactoryFactoryImpl.parseForURLParameter("&hostname=", urlPath);
if ("localhost".equals(hostname)) hostname = null;
BaseConfiguration conf = new BaseConfiguration();
conf.setProperty("storage.backend","cassandra");
conf.setProperty("storage.hostname",hostname);
conf.setProperty("storage.tablename","titan"+graphname);
TitanGraph g = TitanFactory.open(conf);
//g.createKeyIndex(idPropForId, Vertex.class);
//g.loadGraphML('data/onevertex.xml')
if ("localhost".equals(hostname)) hostname = "127.0.0.1";
if (null == hostname) hostname = "127.0.0.1";
TitanGraph g = TitanFactory.build().set("storage.backend","cassandra").set("storage.hostname",hostname).set("storage.cassandra.keyspace","pgcreategraph").open();
//TitanGraph g = TitanFactory.build().set("storage.backend","cassandrathrift").set("storage.hostname",hostname).open();
return g;
} else {
} else {
throw new RuntimeException("unknown store");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@
/* $endif$ */
import org.propelgraph.KeyIndexableGraphSupport;
import java.util.Set;
//import static org.jasonnet.logln.Logln.logln;
import static org.jasonnet.logln.Logln.logln; import org.jasonnet.logln.Logln;

public class TitanKeyIndexableGraphSupport implements KeyIndexableGraphSupport {


TitanGraph gr;

static void logln(String ss) {
//Logln.logln(ss,1); // comment out this line if you want the full featured logln
}


// default constructor
public TitanKeyIndexableGraphSupport( ) {}

Expand Down Expand Up @@ -52,7 +56,7 @@ public <T extends Element> void createKeyIndex(String key, Class<T> elementClass
return ; // it already exists
}
}
//logln("making index starting with the key");
//logln("making index starting with the key: "+key);
PropertyKey pk = mgmt.makePropertyKey(key).dataType(String.class).make();
mgmt.buildIndex( indexname,elementClass).addKey(pk).buildCompositeIndex();
mgmt.commit();
Expand Down

0 comments on commit 1f0dc03

Please sign in to comment.