Last active
August 29, 2015 14:22
-
-
Save mpollmeier/108ab8998e3b0321f020 to your computer and use it in GitHub Desktop.
Neo4j with Gremlin-Scala
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
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph | |
import gremlin.scala._ | |
val dbPath = "/tmp/test" + math.random | |
val timeStart = System.currentTimeMillis | |
val graph = Neo4jGraph.open(dbPath) | |
val sg = ScalaGraph(graph) | |
val gs = GremlinScala(graph) | |
// graph.tx.open() | |
(1 to 30000) foreach { _ ⇒ | |
sg.addVertex("some label") | |
.setProperty(s"property ${math.random}", math.random) | |
} | |
// graph.tx.commit() | |
val timeEnd = System.currentTimeMillis | |
val vertexCount = gs.V.count.head | |
println("---------------") | |
println(s"time to create: ${(timeEnd - timeStart) / 1000f}s") | |
println(s"vertex count: $vertexCount") | |
println("---------------") | |
graph.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Without a bulk api for neo4j it takes nearly 70s to create 30k vertices.
There is currently no publicly available build artifact of tinkerpop3 that contains neo4j-gremlin, so this all depends on custom local builds.