Skip to content

Instantly share code, notes, and snippets.

@mpollmeier
Last active August 29, 2015 14:22
Show Gist options
  • Save mpollmeier/108ab8998e3b0321f020 to your computer and use it in GitHub Desktop.
Save mpollmeier/108ab8998e3b0321f020 to your computer and use it in GitHub Desktop.
Neo4j with Gremlin-Scala
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
@mpollmeier
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment