Skip to content

Instantly share code, notes, and snippets.

@fancyerii
Last active August 29, 2015 14:05
Show Gist options
  • Save fancyerii/2057fa45eb49e50698ed to your computer and use it in GitHub Desktop.
Save fancyerii/2057fa45eb49e50698ed to your computer and use it in GitHub Desktop.
Schema-define
public class CreateFreebaseGraph {
public static final String INDEX_NAME = "search";
public static void main(String[] args) {
TitanGraph graph=TitanFactory.open("/Users/lili/soft/titan-server-0.4.4/conf/titan-hbase-es.properties");
graph.shutdown();
TitanCleanup.clear(graph);
graph=TitanFactory.open("/Users/lili/soft/titan-server-0.4.4/conf/titan-hbase-es.properties");
graph.makeKey("name").dataType(String.class).make();
graph.makeKey("l_name").dataType(String.class).indexed(Vertex.class).make();
graph.makeKey("f_name").dataType(String.class).indexed(INDEX_NAME, Vertex.class).make();
graph.makeKey("uri").dataType(String.class).indexed(Vertex.class).unique().make();
graph.makeKey("v_type").dataType(Integer.class).indexed(Vertex.class).make();
graph.makeKey("str_value").dataType(String.class).make();
graph.makeKey("i_value").dataType(Integer.class).make();
graph.makeKey("l_value").dataType(Long.class).make();
graph.makeKey("f_value").dataType(Float.class).make();
graph.makeKey("d_value").dataType(Double.class).make();
graph.makeKey("spo").dataType(String.class).indexed(INDEX_NAME, Edge.class).make();
graph.makeKey("sp").dataType(String.class).indexed(INDEX_NAME, Edge.class).make();
graph.makeKey("po").dataType(String.class).indexed(INDEX_NAME, Edge.class).make();
graph.makeKey("so").dataType(String.class).indexed(INDEX_NAME, Edge.class).make();
graph.commit();
graph.shutdown();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment