Package org.apache.sysds.api.mlcontext
Class Script
- java.lang.Object
- 
- org.apache.sysds.api.mlcontext.Script
 
- 
 public class Script extends Object A Script object encapsulates a DML or PYDML script.
- 
- 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearAll()Clear the script string, inputs, outputs, and symbol table.voidclearInputs()Clear the inputs.voidclearIO()Clear the inputs and outputs, but not the symbol table.voidclearIOS()Clear the inputs, outputs, and symbol table.voidclearOutputs()Clear the outputs.voidclearSymbolTable()Clear the symbol table.StringdisplayInputParameters()Display the script input parameters.StringdisplayInputs()Display the script inputs.StringdisplayInputVariables()Display the script input variables.StringdisplayOutputs()Display the script outputs.StringdisplayOutputVariables()Display the script output variables.StringdisplaySymbolTable()Display the script symbol table.MLResultsexecute()Execute the script and return the results as an MLResults object.Map<String,Metadata>getInputMetadata()Obtain an unmodifiable map of input matrix/frame metadata.Map<String,Object>getInputParameters()Obtain an unmodifiable map of all input parameters ($).Map<String,Object>getInputs()Obtain an unmodifiable map of all inputs (parameters ($) and variables).Set<String>getInputVariables()Obtain the input variable names as an unmodifiable set of strings.StringgetName()Obtain the script name.Set<String>getOutputVariables()Obtain the output variable names as an unmodifiable set of strings.MLResultsgetResults()Obtain the results of the script execution.StringgetScriptExecutionString()Generate the script execution string, which adds read/load/write/save statements to the beginning and end of the script to execute.ScriptExecutorgetScriptExecutor()Obtain the script executor used by this Script.StringgetScriptString()Obtain the script string.LocalVariableMapgetSymbolTable()Obtain the symbol table, which is essentially aHashMap<String, Data>representing variables and their values.Scriptin(String name, Object value)Register an input (parameter ($) or variable).Scriptin(String name, Object value, Metadata metadata)Register an input (parameter ($) or variable) with optional matrix metadata.Scriptin(Map<String,Object> inputs)Pass a map of inputs to the script.Scriptin(scala.collection.Map<String,?> inputs)Pass a Scala Map of inputs to the script.Scriptin(scala.collection.Seq<Object> inputs)Pass a Scala Seq of inputs to the script.Stringinfo()Display information about the script as a String.Scriptout(String outputName)Register an output variable.Scriptout(String... outputNames)Register output variables.Scriptout(List<String> outputNames)Register output variables.Scriptout(scala.collection.Seq<String> outputNames)Register output variables.MLResultsresults()Obtain the results of the script execution.ScriptsetName(String name)Set the script name.voidsetResults(MLResults results)Set the results of the script execution.voidsetScriptExecutor(ScriptExecutor scriptExecutor)Set the ScriptExecutor used by this Script.ScriptsetScriptString(String scriptString)Set the script string.StringtoString()
 
- 
- 
- 
Constructor Detail- 
Scriptpublic Script() Script constructor, which by default creates a DML script.
 - 
Scriptpublic Script(String scriptString) Script constructor, specifying the script content. By default, the script type is DML.- Parameters:
- scriptString- the script content as a string
 
 
- 
 - 
Method Detail- 
getScriptStringpublic String getScriptString() Obtain the script string.- Returns:
- the script string
 
 - 
setScriptStringpublic Script setScriptString(String scriptString) Set the script string.- Parameters:
- scriptString- the script string
- Returns:
- thisScript object to allow chaining of methods
 
 - 
getInputVariablespublic Set<String> getInputVariables() Obtain the input variable names as an unmodifiable set of strings.- Returns:
- the input variable names
 
 - 
getOutputVariablespublic Set<String> getOutputVariables() Obtain the output variable names as an unmodifiable set of strings.- Returns:
- the output variable names
 
 - 
getSymbolTablepublic LocalVariableMap getSymbolTable() Obtain the symbol table, which is essentially aHashMap<String, Data>representing variables and their values.- Returns:
- the symbol table
 
 - 
getInputspublic Map<String,Object> getInputs() Obtain an unmodifiable map of all inputs (parameters ($) and variables).- Returns:
- all inputs to the script
 
 - 
getInputMetadatapublic Map<String,Metadata> getInputMetadata() Obtain an unmodifiable map of input matrix/frame metadata.- Returns:
- input matrix/frame metadata
 
 - 
inpublic Script in(Map<String,Object> inputs) Pass a map of inputs to the script.- Parameters:
- inputs- map of inputs (parameters ($) and variables).
- Returns:
- thisScript object to allow chaining of methods
 
 - 
inpublic Script in(scala.collection.Map<String,?> inputs) Pass a Scala Map of inputs to the script.Note that the Mapvalue type is not explicitly specified on this method because[String, Any]can't be recognized on the Java side sinceAnydoesn't have an equivalent in the Java class hierarchy (scala.Anyis a superclass ofscala.AnyRef, which is equivalent tojava.lang.Object). Therefore, specifyingscala.collection.Map<String, Object>as an input parameter to this Java method is not encompassing enough and would require types such as ascala.Doubleto be cast usingasInstanceOf[AnyRef].- Parameters:
- inputs- Scala Map of inputs (parameters ($) and variables).
- Returns:
- thisScript object to allow chaining of methods
 
 - 
inpublic Script in(scala.collection.Seq<Object> inputs) Pass a Scala Seq of inputs to the script. The inputs are either two-value or three-value tuples, where the first value is the variable name, the second value is the variable value, and the third optional value is the metadata.- Parameters:
- inputs- Scala Seq of inputs (parameters ($) and variables).
- Returns:
- thisScript object to allow chaining of methods
 
 - 
getInputParameterspublic Map<String,Object> getInputParameters() Obtain an unmodifiable map of all input parameters ($).- Returns:
- input parameters ($)
 
 - 
inpublic Script in(String name, Object value) Register an input (parameter ($) or variable).- Parameters:
- name- name of the input
- value- value of the input
- Returns:
- thisScript object to allow chaining of methods
 
 - 
inpublic Script in(String name, Object value, Metadata metadata) Register an input (parameter ($) or variable) with optional matrix metadata.- Parameters:
- name- name of the input
- value- value of the input
- metadata- optional matrix/frame metadata
- Returns:
- thisScript object to allow chaining of methods
 
 - 
outpublic Script out(String outputName) Register an output variable.- Parameters:
- outputName- name of the output variable
- Returns:
- thisScript object to allow chaining of methods
 
 - 
outpublic Script out(String... outputNames) Register output variables.- Parameters:
- outputNames- names of the output variables
- Returns:
- thisScript object to allow chaining of methods
 
 - 
outpublic Script out(scala.collection.Seq<String> outputNames) Register output variables.- Parameters:
- outputNames- names of the output variables
- Returns:
- thisScript object to allow chaining of methods
 
 - 
outpublic Script out(List<String> outputNames) Register output variables.- Parameters:
- outputNames- names of the output variables
- Returns:
- thisScript object to allow chaining of methods
 
 - 
clearIOSpublic void clearIOS() Clear the inputs, outputs, and symbol table.
 - 
clearIOpublic void clearIO() Clear the inputs and outputs, but not the symbol table.
 - 
clearAllpublic void clearAll() Clear the script string, inputs, outputs, and symbol table.
 - 
clearInputspublic void clearInputs() Clear the inputs.
 - 
clearOutputspublic void clearOutputs() Clear the outputs.
 - 
clearSymbolTablepublic void clearSymbolTable() Clear the symbol table.
 - 
resultspublic MLResults results() Obtain the results of the script execution.- Returns:
- the results of the script execution.
 
 - 
getResultspublic MLResults getResults() Obtain the results of the script execution.- Returns:
- the results of the script execution.
 
 - 
setResultspublic void setResults(MLResults results) Set the results of the script execution.- Parameters:
- results- the results of the script execution.
 
 - 
getScriptExecutorpublic ScriptExecutor getScriptExecutor() Obtain the script executor used by this Script.- Returns:
- the ScriptExecutor used by this Script.
 
 - 
setScriptExecutorpublic void setScriptExecutor(ScriptExecutor scriptExecutor) Set the ScriptExecutor used by this Script.- Parameters:
- scriptExecutor- the script executor
 
 - 
getScriptExecutionStringpublic String getScriptExecutionString() Generate the script execution string, which adds read/load/write/save statements to the beginning and end of the script to execute.- Returns:
- the script execution string
 
 - 
infopublic String info() Display information about the script as a String. This consists of the script type, inputs, outputs, input parameters, input variables, output variables, the symbol table, the script string, and the script execution string.- Returns:
- information about this script as a String
 
 - 
displayInputspublic String displayInputs() Display the script inputs.- Returns:
- the script inputs
 
 - 
displayOutputspublic String displayOutputs() Display the script outputs.- Returns:
- the script outputs as a String
 
 - 
displayInputParameterspublic String displayInputParameters() Display the script input parameters.- Returns:
- the script input parameters as a String
 
 - 
displayInputVariablespublic String displayInputVariables() Display the script input variables.- Returns:
- the script input variables as a String
 
 - 
displayOutputVariablespublic String displayOutputVariables() Display the script output variables.- Returns:
- the script output variables as a String
 
 - 
displaySymbolTablepublic String displaySymbolTable() Display the script symbol table.- Returns:
- the script symbol table as a String
 
 - 
getNamepublic String getName() Obtain the script name.- Returns:
- the script name
 
 - 
setNamepublic Script setName(String name) Set the script name.- Parameters:
- name- the script name
- Returns:
- thisScript object to allow chaining of methods
 
 - 
executepublic MLResults execute() Execute the script and return the results as an MLResults object.- Returns:
- results as an MLResults object
 
 
- 
 
-