Last active
August 29, 2015 14:22
-
-
Save sarmbruster/35f6da569757b970aab7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab(group = "org.neo4j", module = "neo4j-kernel", version = "1.9.9") | |
@Grab(group = "org.neo4j", module = "neo4j-lucene-index", version = "1.9.9") | |
import org.neo4j.graphdb.DynamicRelationshipType | |
import org.neo4j.graphdb.GraphDatabaseService | |
import org.neo4j.graphdb.factory.GraphDatabaseFactory | |
import org.neo4j.tooling.GlobalGraphOperations | |
def graphDbDir = "/tmp/dummy" | |
new File(graphDbDir).deleteDir() | |
GraphDatabaseService graphDatabaseService = new GraphDatabaseFactory().newEmbeddedDatabase("/tmp/dummy") | |
def now = new Date().time | |
def tx | |
try { | |
tx = graphDatabaseService.beginTx() | |
for (int i = 0; i < 65536; i++) { | |
if (i % 5000 == 0) { | |
println "${new Date().time - now} created $i rels/rel types" | |
tx.success() | |
tx.finish() | |
tx = graphDatabaseService.beginTx() | |
} | |
def node1 = graphDatabaseService.createNode() | |
def node2 = graphDatabaseService.createNode() | |
node1.createRelationshipTo(node2, DynamicRelationshipType.withName("rel_$i")) | |
} | |
tx.success() | |
} finally { | |
tx.finish() | |
} | |
tx = graphDatabaseService.beginTx() | |
try { | |
def ggo = GlobalGraphOperations.at(graphDatabaseService); | |
// check how many reltypes we can find | |
def count = 0; | |
for (r in ggo.allRelationshipTypes) { | |
count++ | |
} | |
println "total: $count rel types (according to ggo.getAllRelationshipTypes())" | |
// check if a relationship type is used only once at most | |
count = 0 | |
def reltypes = [] | |
for (r in ggo.allRelationships) { | |
count++ | |
def type = r.type.name() | |
assert !reltypes.contains(type) | |
reltypes << type | |
} | |
println "total: $count rels" | |
tx.success() | |
} finally { | |
tx.finish() | |
} | |
graphDatabaseService.shutdown() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment