Skip to content

Instantly share code, notes, and snippets.

@li-boxuan
Created August 30, 2021 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save li-boxuan/d8059d1c40652c3c5308670ce383e96a to your computer and use it in GitHub Desktop.
Save li-boxuan/d8059d1c40652c3c5308670ce383e96a to your computer and use it in GitHub Desktop.
Insert 10 million nodes into JanusGraph
graph = JanusGraphFactory.open("conf/janusgraph-cql-es.properties")
mgmt = graph.openManagement();
name = mgmt.makePropertyKey("name").dataType(String.class).cardinality(Cardinality.SINGLE).make();
mgmt.buildIndex("nameIndex", Vertex.class).addKey(name).buildCompositeIndex();
age = mgmt.makePropertyKey('age').dataType(Integer.class).make()
mgmt.buildIndex("ageIndex", Vertex.class).addKey(age).buildMixedIndex("search")
mgmt.commit();
v = graph.addVertex("name", "outer");
for (i = 0; i < 2500; i++) {
otherV = graph.addVertex("name", "middle")
v.addEdge("connects", otherV);
for (j = 0; j < 4000; j++) {
innerV = graph.addVertex("name", "inner" + (j % 50), "age", j % 100);
otherV.addEdge("connects", innerV);
}
graph.tx().commit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment