Skip to content

Instantly share code, notes, and snippets.

@cleishm
Created March 2, 2012 01:54
Show Gist options
  • Save cleishm/1954882 to your computer and use it in GitHub Desktop.
Save cleishm/1954882 to your computer and use it in GitHub Desktop.
Create a huge neo4j dataset
import org.neo4j.kernel.impl.batchinsert.*;
import org.neo4j.graphdb.*;
import java.util.*;
class RandomDB {
public static void main(final String args[]) {
final Map<String, String> params = new HashMap<String,String>();
params.put("neostore.nodestore.db.mapped_memory", "1024M");
params.put("neostore.relationshipstore.db.mapped_memory", "2048M");
params.put("neostore.propertystore.db.mapped_memory", "1024M");
params.put("neostore.propertystore.db.strings.mapped_memory", "130M");
params.put("neostore.propertystore.db.arrays.mapped_memory", "130M");
final BatchInserter inserter = new BatchInserterImpl("/data/random.db", params);
final int numNodes = 100000000;
final int numRels = 200000000;
for (int i = 0; i < numNodes; i++) {
if ((i % 100000) == 0) {
System.out.println("Creating node: " + i);
}
final Map<String,Object> props = new HashMap<String,Object>();
props.put("name", java.util.UUID.randomUUID().toString());
inserter.createNode(props);
}
final RelationshipType relType = DynamicRelationshipType.withName("connection");
final Random random = new Random();
for (int i = 0; i < numRels; i++) {
if ((i % 1000) == 0) {
System.out.println("Creating rel: " + i);
}
long node1 = random.nextInt(numNodes);
long node2 = random.nextInt(numNodes);
final Map<String,Object> props = new HashMap<String,Object>();
props.put("name", java.util.UUID.randomUUID().toString());
inserter.createRelationship(node1, node2, relType, props);
}
inserter.shutdown();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment