Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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