Skip to content

Commit

Permalink
(squash) Make another 2 suggested changes
Browse files Browse the repository at this point in the history
Make save reset variables to original variables defined in schema, and
put coverage off/on around unimplemented methods.

DataProcessor.scala: Ensure variableMap is serialized as well as
validationMode, but reset back to original variables when saving.

Runtime2DataProcessor.scala: Put coverage off/on around unimplemented
methods.
  • Loading branch information
tuxji committed Dec 8, 2022
1 parent 07abf28 commit 8d91441
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@ object DataProcessor {
* It enables us to implement restrictions on what you can/cannot do with a reloaded
* processor versus an original one.
*
* When we reload a processor, it will have default values for everything settable
* When we reload a processor, we want it to have default values for everything settable
* like validation mode, debug mode, and debugger.
*
* Note that this class does preserve validationMode. That is because validationMode
* may be needed by serializations other than our own save/reload (e.g., Apache Spark
* Note that this class does preserve variableMap and validationMode. That is because
* serializations other than our own save/reload may need such settings (e.g., Apache Spark
* which serializes to move objects for remote execution).
*
* Hence, we're depending on the save method to explicitly turn off validationMode.
* Hence, we're depending on the save method to explicitly reset them to default values.
*/
private class SerializableDataProcessor(
ssrd: SchemaSetRuntimeData,
tunables: DaffodilTunables,
variableMap: VariableMap,
variableMap: VariableMap, // must be explicitly reset by save method
validationMode: ValidationMode.Type, // must be explicitly turned off by save method
) extends DataProcessor(ssrd, tunables, variableMap, validationMode) {

Expand Down Expand Up @@ -270,13 +270,14 @@ class DataProcessor(

//
// Make a copy of this object so that we can make its saved state
// different than its original state. Note that the serialization
// system *does* preserve validationMode since it may be required by
// other software like Apache Spark. But for our save/reload purposes,
// we don't want validationMode preserved.
// different than its original state. Note other software like
// Apache Spark may require variableMap and validationMode to be
// preserved. But for our save/reload purposes, we want to reset
// them back to their original values.
//
val dpToSave = this.copy(
validationMode = ValidationMode.Off, // explicitly turn off, so restored processor won't be validating.
variableMap = ssrd.originalVariables, // reset to original variables defined in schema
validationMode = ValidationMode.Off, // explicitly turn off, so restored processor won't be validating
)

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ import org.apache.daffodil.util.Maybe
import org.apache.daffodil.util.Maybe.Nope

/**
* Effectively a scala proxy object that does its work via the underlying C-code.
* Will need to consider how to use features of underlying C-code to get infoset,
* walk infoset, generate XML for use by TDML tests.
* Effectively a scala proxy object that does its work via the underlying C-code
* to get infoset, walk infoset, and generate XML for use by TDML tests.
*/
class Runtime2DataProcessor(executableFile: os.Path) extends DFDL.DataProcessorBase {

//$COVERAGE-OFF$
override def withValidationMode(mode: ValidationMode.Type): DFDL.DataProcessor = ???
override def withTunable(name: String, value: String): DFDL.DataProcessor = ???
override def withTunables(tunables: Map[String, String]): DFDL.DataProcessor = ???
Expand All @@ -53,12 +53,11 @@ class Runtime2DataProcessor(executableFile: os.Path) extends DFDL.DataProcessorB
override def withExternalVariables(extVars: Seq[Binding]): DFDL.DataProcessor = ???
override def withDebugger(dbg:AnyRef): DFDL.DataProcessor = ???
override def withDebugging(flag: Boolean): DFDL.DataProcessor = ???

override def save(output: DFDL.Output): Unit = ???

override def tunables: DaffodilTunables = ???
override def variableMap: VariableMap = ???
override def validationMode: ValidationMode.Type = ???
//$COVERAGE-ON$

/**
* Returns an object which contains the result, and/or diagnostic information.
Expand Down

0 comments on commit 8d91441

Please sign in to comment.