mbeckerle closed pull request #41: Schema cache now works whether you check all
top-levels or not.
URL: https://github.com/apache/incubator-daffodil/pull/41
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/daffodil-tdml/src/main/scala/org/apache/daffodil/tdml/SchemaCache.scala
b/daffodil-tdml/src/main/scala/org/apache/daffodil/tdml/SchemaCache.scala
index 6238192b0..1640bb900 100644
--- a/daffodil-tdml/src/main/scala/org/apache/daffodil/tdml/SchemaCache.scala
+++ b/daffodil-tdml/src/main/scala/org/apache/daffodil/tdml/SchemaCache.scala
@@ -43,9 +43,9 @@ object SchemaDataProcessorCache extends
SchemaCache[(Seq[Diagnostic], DFDL.DataP
class SchemaCache[CachedType, DiagnosticType] {
private class Cache
- extends mutable.HashMap[(URISchemaSource, Boolean), (URISchemaSource,
CachedType)] {
+ extends mutable.HashMap[(URISchemaSource, Boolean, Boolean, String,
String), (URISchemaSource, CachedType)] {
- override def getOrElseUpdate(key: (URISchemaSource, Boolean), body: =>
(URISchemaSource, CachedType)) = synchronized {
+ override def getOrElseUpdate(key: (URISchemaSource, Boolean, Boolean,
String, String), body: => (URISchemaSource, CachedType)) = synchronized {
super.getOrElseUpdate(key, body)
}
@@ -78,10 +78,20 @@ class SchemaCache[CachedType, DiagnosticType] {
* If the same URI is used, and it identifies a file, then if the
modification time
* is such that the file is newer then when last compiled, the newer file
will
* be compiled and cached.
+ *
+ * If compileAllTopLevels is true, then all elements are compiled. If false,
and
+ * no rootElementName is null, then the first element of the first schema
file
+ * is used as the single root element. Otherwise the rootElementName must be
+ * provided. If ambiguous, the rootElementNamespace must also be supplied
but this
+ * can be null if the name alone is unambiguous.
+ *
*/
- def compileAndCache(uss: URISchemaSource, useSerializedProcessor:
Boolean)(doCompileByName: => CompileResult): CompileResult = {
+ def compileAndCache(uss: URISchemaSource, useSerializedProcessor: Boolean,
+ compileAllTopLevels: Boolean,
+ rootElementName: String,
+ rootElementNamespace: String)(doCompileByName: => CompileResult):
CompileResult = {
lazy val doCompile = doCompileByName // exactly once
- val key = (uss, useSerializedProcessor)
+ val key = (uss, useSerializedProcessor, compileAllTopLevels,
rootElementName, rootElementNamespace)
synchronized {
// if the file is newer then when last compiled, drop from the cache.
val optExistingEntry = compiledSchemaCache.get(key)
diff --git
a/daffodil-tdml/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala
b/daffodil-tdml/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala
index 4f85f7f34..0a90c66a4 100644
--- a/daffodil-tdml/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala
+++ b/daffodil-tdml/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala
@@ -63,7 +63,6 @@ import java.io.ByteArrayInputStream
import scala.language.postfixOps
import java.nio.file.Paths
import java.nio.file.Files
-import org.apache.daffodil.equality._
import org.apache.commons.io.IOUtils
import org.apache.daffodil.processors.HasSetDebugger
import org.apache.daffodil.processors.UnparseResult
@@ -424,10 +423,13 @@ abstract class TestCase(testCaseXML: NodeSeq, val parent:
DFDLTestSuite)
final protected def getProcessor(schemaSource: DaffodilSchemaSource,
useSerializedProcessor: Boolean): DFDLTestSuite.CompileResult = {
val res: DFDLTestSuite.CompileResult = schemaSource match {
- case uss: URISchemaSource if parent.checkAllTopLevel =#= true =>
- SchemaDataProcessorCache.compileAndCache(uss, useSerializedProcessor) {
- compileProcessor(uss, useSerializedProcessor)
- }
+ case uss: URISchemaSource =>
+ SchemaDataProcessorCache.compileAndCache(uss, useSerializedProcessor,
+ parent.checkAllTopLevel,
+ root,
+ null) {
+ compileProcessor(uss, useSerializedProcessor)
+ }
case _ => {
compileProcessor(schemaSource, useSerializedProcessor)
}
diff --git
a/daffodil-tdml/src/test/scala/org/apache/daffodil/tdml/TestSchemaCache.scala
b/daffodil-tdml/src/test/scala/org/apache/daffodil/tdml/TestSchemaCache.scala
index 938d1c243..25de0faff 100644
---
a/daffodil-tdml/src/test/scala/org/apache/daffodil/tdml/TestSchemaCache.scala
+++
b/daffodil-tdml/src/test/scala/org/apache/daffodil/tdml/TestSchemaCache.scala
@@ -65,7 +65,7 @@ class TestSchemaCache {
}
def compileTheSchema(uss: URISchemaSource) {
- SCache.compileAndCache(uss, false) {
+ SCache.compileAndCache(uss, false, false, null, null) {
compileCount += 1
uss.newInputSource().getByteStream().close()
Right(null)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services