Skip to content

Commit

Permalink
Merge pull request #422 from renaissance-benchmarks/devel/neo4j
Browse files Browse the repository at this point in the history
Update Neo4j to version 5.12.0 and migrate to Scala 2.13
  • Loading branch information
lbulej authored Oct 12, 2023
2 parents 401de1c + 377ec4d commit ae761c6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ The following is the complete list of benchmarks, separated into groups.

- `neo4j-analytics` - Executes Neo4j graph queries against a movie database.
\
Default repetitions: 20; GPL3 license, GPL3 distribution; Supported JVM: 11 - 20
Default repetitions: 20; GPL3 license, GPL3 distribution; Supported JVM: 17 and later

#### functional

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.renaissance.neo4j

import org.neo4j.configuration.GraphDatabaseSettings
import org.neo4j.dbms.api.{DatabaseManagementService, DatabaseManagementServiceBuilder}
import org.neo4j.logging.Level
import org.neo4j.io.ByteUnit
import org.renaissance.Benchmark._
import org.renaissance.BenchmarkResult.Validators
import org.renaissance.neo4j.analytics.AnalyticsBenchmark
Expand All @@ -19,8 +19,7 @@ import scala.io.{Codec, Source}
@Group("neo4j")
@Summary("Executes Neo4j graph queries against a movie database.")
@Licenses(Array(License.GPL3))
@RequiresJvm("11")
@SupportsJvm("20")
@RequiresJvm("17")
@Repetitions(20)
@Parameter(name = "long_query_threads", defaultValue = "2")
@Parameter(name = "long_query_repeats", defaultValue = "1")
Expand Down Expand Up @@ -122,8 +121,7 @@ final class Neo4jAnalytics extends Benchmark {

dbms.set(
new DatabaseManagementServiceBuilder(graphDbDir)
.setConfig(GraphDatabaseSettings.pagecache_memory, "500M")
.setConfig(GraphDatabaseSettings.store_internal_log_level, Level.WARN)
.setConfig(GraphDatabaseSettings.pagecache_memory, Long.box(ByteUnit.mebiBytes(512)))
.build()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import org.neo4j.graphdb.{GraphDatabaseService, Label, RelationshipType, Result}
import org.renaissance.neo4j.analytics.AnalyticsBenchmark._

import java.util.concurrent.TimeUnit
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.collection.{Seq, _}

/*
* Model of JSON data.
*/
object AnalyticsBenchmark {

type VertexId = Int
private type VertexId = Int

trait Vertex {
def id: VertexId
Expand Down Expand Up @@ -63,8 +63,8 @@ class AnalyticsBenchmark(
private def populateVertices(
db: GraphDatabaseService,
vertices: Iterable[Vertex]
): Map[VertexId, Long] = {
val mapping = mutable.Map[VertexId, Long]()
): Map[VertexId, String] = {
val mapping = mutable.Map[VertexId, String]()

val tx = db.beginTx()

Expand All @@ -88,7 +88,7 @@ class AnalyticsBenchmark(
sys.error(s"Unknown $vertex.")
}

mapping(vertex.id) = node.getId
mapping(vertex.id) = node.getElementId
} catch {
case e: Exception =>
throw new RuntimeException(s"Error in: $vertex", e)
Expand All @@ -105,21 +105,21 @@ class AnalyticsBenchmark(
private def populateEdges(
db: GraphDatabaseService,
edges: Iterable[Edge],
vertexNodeIds: Map[VertexId, Long]
vertexNodeIds: Map[VertexId, String]
): Long = {
var edgeCount = 0
val tx = db.beginTx()

try {
for (edge <- edges) try {
val sourceNodeId = vertexNodeIds(edge.source)
val sourceNode = tx.getNodeById(sourceNodeId)
val sourceNode = tx.getNodeByElementId(sourceNodeId)
if (sourceNode == null) {
sys.error("Null source node for: " + sourceNodeId)
}

val destinationNodeId = vertexNodeIds(edge.destination)
val destinationNode = tx.getNodeById(destinationNodeId)
val destinationNode = tx.getNodeByElementId(destinationNodeId)
if (destinationNode == null) {
sys.error("Null destination node for: " + destinationNodeId)
}
Expand Down Expand Up @@ -275,7 +275,7 @@ class AnalyticsBenchmark(
// Find how many directors directed at least 3 movies.
(
"""match (d: Director)
|with d, size((d)-[: FILMS]->()) as c
|with d, count { (d)-[: FILMS]->() } as c
|where c > $c
|return count(d)""".stripMargin,
Map("c" -> Long.box(3)),
Expand All @@ -296,7 +296,7 @@ class AnalyticsBenchmark(
// Find the genre with the most movies.
(
"""match (g: Genre)
|with g, size(()-[: GENRE]->(g)) as filmCount
|with g, count { ()-[: GENRE]->(g) } as filmCount
|order by filmCount desc
|limit 1
|return g.name, filmCount""".stripMargin,
Expand Down
11 changes: 6 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,13 @@ lazy val jdkStreamsBenchmarks = (project in file("benchmarks/jdk-streams"))
lazy val neo4jBenchmarks = (project in file("benchmarks/neo4j"))
.settings(
name := "neo4j",
commonSettingsScala212,
commonSettingsScala213,
libraryDependencies ++= Seq(
// neo4j 4.4 does not support Scala 2.13 yet.
// neo4j 5.0 supports Scala 2.13 and requires JDK17
"org.neo4j" % "neo4j" % "4.4.26",
"com.typesafe.play" %% "play-json" % "2.10.1"
// neo4j 4.4 supports Scala 2.12 and requires JDK11.
// neo4j 5.x supports Scala 2.13 and requires JDK17.
"org.neo4j" % "neo4j" % "5.12.0",
// play-json 2.10.x requires SBT running on JDK11 to compile.
"com.typesafe.play" %% "play-json" % "2.9.4"
),
dependencyOverrides ++= Seq(
// Force newer JNA to support more platforms/architectures.
Expand Down

0 comments on commit ae761c6

Please sign in to comment.