-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
schema-conflicting node properties: only warn, don't error (#195)
* schema-conflicting node properties: only warn, don't error 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. * fmt * add one more test case * fixup, cleanup
- Loading branch information
1 parent
f17ba4c
commit 08009ce
Showing
12 changed files
with
274 additions
and
134 deletions.
There are no files selected for viewing
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
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
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
38 changes: 38 additions & 0 deletions
38
core/src/main/scala/flatgraph/misc/SchemaViolationReporter.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package flatgraph.misc | ||
|
||
import flatgraph.Schema | ||
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. | ||
*/ | ||
class SchemaViolationReporter { | ||
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 = { | ||
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 => | ||
contextBuilder += s",propertyName=$name" | ||
case kind: Int => | ||
contextBuilder += s",propertyKind=$kind" | ||
schema.getPropertyLabelMaybe(nodeKind, kind).foreach { name => | ||
contextBuilder += s",propertyName=$name" | ||
} | ||
} | ||
val context = contextBuilder.result().mkString(",") | ||
logger.warn(s"""Unsupported (deprecated?) property on node: $context""") | ||
loggedSchemaViolations.addOne((nodeKind, propertyIdentifier)) | ||
} | ||
} | ||
|
||
} |
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
3 changes: 1 addition & 2 deletions
3
...scala/flatgraph/misc/DiffGraphTests.scala → ...test/scala/flatgraph/DiffGraphTests.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
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
Oops, something went wrong.