Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mpollmeier committed May 6, 2024
1 parent 03016f9 commit f72935b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
6 changes: 5 additions & 1 deletion core/src/main/scala/flatgraph/DiffGraphApplier.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import flatgraph.misc.SchemaViolationReporter
import scala.collection.{Iterator, mutable}

object DiffGraphApplier {
def applyDiff(graph: Graph, diff: DiffGraphBuilder, schemaViolationReporter: SchemaViolationReporter = new SchemaViolationReporter): Unit = {
def applyDiff(
graph: Graph,
diff: DiffGraphBuilder,
schemaViolationReporter: SchemaViolationReporter = new SchemaViolationReporter
): Unit = {
if (graph.isClosed) throw new GraphClosedException(s"graph cannot be modified any longer since it's closed")
new DiffGraphApplier(graph, diff, schemaViolationReporter).applyUpdate()
diff.buffer = null
Expand Down
16 changes: 8 additions & 8 deletions core/src/main/scala/flatgraph/misc/SchemaViolationReporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ import org.slf4j.LoggerFactory

import scala.collection.mutable

/** Illegal usage of node properties often roots in deserialising an old storage format, so we
* don't want to error out but rather log a warning, and only do so once for each node/property combination.
*/
/** Illegal usage of node properties often roots in deserialising an old storage format, so we don't want to error out but rather log a
* warning, and only do so once for each node/property combination.
*/
class SchemaViolationReporter {
private val logger = LoggerFactory.getLogger(getClass)
private val loggedSchemaViolations = mutable.Set.empty[(Int, String|Int)] // (NodeKind, PropertyLabel|PropertyKind)
private val logger = LoggerFactory.getLogger(getClass)
private val loggedSchemaViolations = mutable.Set.empty[(Int, String | Int)] // (NodeKind, PropertyLabel|PropertyKind)

def illegalNodeProperty(nodeKind: Int, propertyIdentifier: String|Int, schema: Schema): Unit = {
def illegalNodeProperty(nodeKind: Int, propertyIdentifier: String | Int, schema: Schema): Unit = {
if (loggedSchemaViolations.contains((nodeKind, propertyIdentifier))) {
val contextBuilder = Seq.newBuilder[String]

contextBuilder += s"nodeKind=$nodeKind"
schema.getNodeLabelMaybe(nodeKind).foreach { nodeLabel =>
contextBuilder += s",nodeLabel=$nodeLabel"
}
propertyIdentifier match {
case name: String =>
case name: String =>
contextBuilder += s",propertyName=$name"
case kind: Int =>
contextBuilder += s",propertyKind=$kind"
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/flatgraph/traversal/Language.scala
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ class NodeSteps[A <: GNode](traversal: Iterator[A]) extends AnyVal {

def property[@specialized ValueType](propertyKey: MultiPropertyKey[ValueType]): Iterator[ValueType] =
traversal.flatMap(_.property(propertyKey))

def propertiesMap: Iterator[java.util.Map[String, AnyRef]] =
traversal.map(_.propertiesMap)
}
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,8 @@ class DomainClassesGenerator(schema: Schema) {
}
os.write(outputDir0 / "GraphSchema.scala", schemaFile)

os.write(outputDir0 / "PropertyErrorRegister.scala",
os.write(
outputDir0 / "PropertyErrorRegister.scala",
s"""package $basePackage
|
|object PropertyErrorRegister {
Expand Down
8 changes: 3 additions & 5 deletions tests/src/test/scala/flatgraph/GraphTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ import org.scalatest.wordspec.AnyWordSpec
import scala.collection.mutable
import scala.jdk.CollectionConverters.MapHasAsScala


class GraphTests extends AnyWordSpec with MockFactory {

"node property: log warning for schema-unconform property usage" in {
// unknown node properties often root in deserialising an old storage format,
// so we don't want to error out but rather log a warning
val genericDomain = GenericDomain.empty
val graph = genericDomain.graph
val schema = graph.schema
val genericDomain = GenericDomain.empty
val graph = genericDomain.graph
val schema = graph.schema
val Seq(nodeA, nodeB) = TestHelpers.addNodes(graph, Seq(NewNodeA(), NewNodeB()))

val mockSchemaViolationReporter = mock[SchemaViolationReporter]
Expand All @@ -43,7 +42,6 @@ class GraphTests extends AnyWordSpec with MockFactory {
genericDomain.nodeB.head.propertiesMap.asScala shouldBe Map()
}


/* sample graph:
* L3 <- L2 <- L1 <- Center -> R1 -> R2 -> R3 -> R4 -> R5
*/
Expand Down

0 comments on commit f72935b

Please sign in to comment.