You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemml.apache.org by de...@apache.org on 2017/01/07 01:50:10 UTC

incubator-systemml git commit: [SYSTEMML-1165] Setup method for ScriptExecutor execution

Repository: incubator-systemml
Updated Branches:
  refs/heads/master 75b993759 -> c36229012


[SYSTEMML-1165] Setup method for ScriptExecutor execution

Create setup method to perform basic setup operations for ScriptExecutor.
This simplifies specifying a custom execution when subclassing ScriptExecutor,
since an overridden execute method can call the setup method as its
first step.

Closes #332.


Project: http://git-wip-us.apache.org/repos/asf/incubator-systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-systemml/commit/c3622901
Tree: http://git-wip-us.apache.org/repos/asf/incubator-systemml/tree/c3622901
Diff: http://git-wip-us.apache.org/repos/asf/incubator-systemml/diff/c3622901

Branch: refs/heads/master
Commit: c362290123d2659e2306b19e563740cb3200a333
Parents: 75b9937
Author: Deron Eriksson <de...@us.ibm.com>
Authored: Fri Jan 6 17:45:35 2017 -0800
Committer: Deron Eriksson <de...@us.ibm.com>
Committed: Fri Jan 6 17:45:35 2017 -0800

----------------------------------------------------------------------
 .../sysml/api/mlcontext/ScriptExecutor.java     | 25 +++++++++++++++-----
 1 file changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/c3622901/src/main/java/org/apache/sysml/api/mlcontext/ScriptExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/api/mlcontext/ScriptExecutor.java b/src/main/java/org/apache/sysml/api/mlcontext/ScriptExecutor.java
index 791557a..7f80267 100644
--- a/src/main/java/org/apache/sysml/api/mlcontext/ScriptExecutor.java
+++ b/src/main/java/org/apache/sysml/api/mlcontext/ScriptExecutor.java
@@ -275,6 +275,7 @@ public class ScriptExecutor {
 	 * primary methods:
 	 * 
 	 * <ol>
+	 * <li>{@link #setup(Script)}</li>
 	 * <li>{@link #parseScript()}</li>
 	 * <li>{@link #liveVariableAnalysis()}</li>
 	 * <li>{@link #validateScript()}</li>
@@ -298,14 +299,9 @@ public class ScriptExecutor {
 	 * @return the results as a MLResults object
 	 */
 	public MLResults execute(Script script) {
-		this.script = script;
-		checkScriptHasTypeAndString();
-		script.setScriptExecutor(this);
-		setScriptStringInSparkMonitor();
-		// Set global variable indicating the script type
-		DMLScript.SCRIPT_TYPE = script.getScriptType();
 
 		// main steps in script execution
+		setup(script);
 		parseScript();
 		liveVariableAnalysis();
 		validateScript();
@@ -336,6 +332,23 @@ public class ScriptExecutor {
 	}
 
 	/**
+	 * Sets the script in the ScriptExecutor, checks that the script has a type
+	 * and string, sets the ScriptExecutor in the script, sets the script string
+	 * in the Spark Monitor, and globally sets the script type.
+	 * 
+	 * @param script
+	 *            the DML or PYDML script to execute
+	 */
+	protected void setup(Script script) {
+		this.script = script;
+		checkScriptHasTypeAndString();
+		script.setScriptExecutor(this);
+		setScriptStringInSparkMonitor();
+		// Set global variable indicating the script type
+		DMLScript.SCRIPT_TYPE = script.getScriptType();
+	}
+
+	/**
 	 * Perform any necessary cleanup operations after program execution.
 	 */
 	protected void cleanupAfterExecution() {