Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Scalafmt apply
7fb89c767649f28c0405d5f4ba8afa181614504f
33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ import org.opencypher.morpheus.api.MorpheusSession
import org.opencypher.morpheus.api.io.{MorpheusNodeTable, MorpheusRelationshipTable}
import org.opencypher.morpheus.util.App

/**
* Demonstrates basic usage of the Morpheus API by loading an example graph from [[DataFrame]]s.
*/
/** Demonstrates basic usage of the Morpheus API by loading an example graph from [[DataFrame]]s. */
object DataFrameInputExample extends App {
// 1) Create Morpheus session and retrieve Spark session
implicit val morpheus: MorpheusSession = MorpheusSession.local()
Expand All @@ -124,15 +122,23 @@ object DataFrameInputExample extends App {
import spark.sqlContext.implicits._

// 2) Generate some DataFrames that we'd like to interpret as a property graph.
val nodesDF = spark.createDataset(Seq(
(0L, "Alice", 42L),
(1L, "Bob", 23L),
(2L, "Eve", 84L)
)).toDF("id", "name", "age")
val relsDF = spark.createDataset(Seq(
(0L, 0L, 1L, "23/01/1987"),
(1L, 1L, 2L, "12/12/2009")
)).toDF("id", "source", "target", "since")
val nodesDF = spark
.createDataset(
Seq(
(0L, "Alice", 42L),
(1L, "Bob", 23L),
(2L, "Eve", 84L)
)
)
.toDF("id", "name", "age")
val relsDF = spark
.createDataset(
Seq(
(0L, 0L, 1L, "23/01/1987"),
(1L, 1L, 2L, "12/12/2009")
)
)
.toDF("id", "source", "target", "since")

// 3) Generate node- and relationship tables that wrap the DataFrames. The mapping between graph elements and columns
// is derived using naming conventions for identifier columns.
Expand All @@ -147,7 +153,8 @@ object DataFrameInputExample extends App {

// 6) Collect results into string by selecting a specific column.
// This operation may be very expensive as it materializes results locally.
val names: Set[String] = result.records.table.df.collect().map(_.getAs[String]("n_name")).toSet
val names: Set[String] =
result.records.table.df.collect().map(_.getAs[String]("n_name")).toSet

println(names)
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ plugins {

alias(libs.plugins.champeau.jmh).apply(false)
alias(libs.plugins.license).apply(false)
alias(libs.plugins.scalastyle).apply(false)
alias(libs.plugins.shadowjar).apply(false)
alias(libs.plugins.spotless).apply(false)

alias(libs.plugins.versionCatalogUpdate)
}
Expand Down
9 changes: 5 additions & 4 deletions build.style.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
subprojects {
apply plugin: 'com.github.alisiikh.scalastyle'
apply plugin: 'com.diffplug.spotless'

scalastyle {
scalaVersion = libs.versions.scala.major.get()
config = rootProject.file("etc/scalastyle_config.xml")
spotless {
scala {
scalafmt().configFile(rootProject.file('etc/.scalafmt.conf'))
}
}
}
9 changes: 9 additions & 0 deletions etc/.scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version = 3.8.1
runner.dialect = scala212

maxColumn = 100
indent.defnSite = 2

docstrings.style = SpaceAsterisk
docstrings.oneline = fold
docstrings.blankFirstLine = yes
16 changes: 0 additions & 16 deletions etc/scalastyle_config.xml

This file was deleted.

4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mockito = "5.18.0"
neo4j-driver = "1.7.2"
netty = "4.2.7.Final"
# @pin - let's prevent automatic updates for the moment
scala-full = "2.12.20"
scala-full = "2.12.20" # Note, needs to stay aligned with scalafmt.conf
# @pin - let's prevent automatic updates for the moment
scala-major = "2.12"
scalacheck = "1.19.0"
Expand Down Expand Up @@ -83,6 +83,6 @@ testing-scalatest-junit = { module = "org.scalatestplus:junit-5-13_2.12", versio
champeau-jmh = "me.champeau.jmh:0.7.3"
# @pin - version is self-hosted
license = "com.github.hierynomus.license:0.16.3-63da64d"
scalastyle = "com.github.alisiikh.scalastyle:3.5.0"
spotless = "com.diffplug.spotless:8.1.0"
shadowjar = "com.gradleup.shadow:9.2.2"
versionCatalogUpdate = "nl.littlerobots.version-catalog-update:1.0.1"
Loading