org.apache.sysml.api.jmlc

Class PreparedScript



  • public class PreparedScript
    extends Object
    Representation of a prepared (precompiled) DML/PyDML script.
    • Constructor Summary

      Constructors 
      Modifier Constructor and Description
      protected PreparedScript(org.apache.sysml.runtime.controlprogram.Program prog, String[] inputs, String[] outputs)
      Meant to be invoked only from Connection.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void clearParameters()
      Remove all current values bound to input or output variables.
      void enableFunctionRecompile(String fnamespace, String... fnames)
      Enables function recompilation, selectively for the given functions.
      ResultVariables executeScript()
      Executes the prepared script over the bound inputs, creating the result variables according to bound and registered outputs.
      String explain()
      Explain the DML/PyDML program and view result as a string.
      void setFrame(String varname, FrameBlock frame, boolean reuse)
      Binds a frame object to a registered input variable.
      void setFrame(String varname, String[][] frame)
      Binds a frame object to a registered input variable.
      void setFrame(String varname, String[][] frame, boolean reuse)
      Binds a frame object to a registered input variable.
      void setFrame(String varname, String[][] frame, List<org.apache.sysml.parser.Expression.ValueType> schema)
      Binds a frame object to a registered input variable.
      void setFrame(String varname, String[][] frame, List<org.apache.sysml.parser.Expression.ValueType> schema, boolean reuse)
      Binds a frame object to a registered input variable.
      void setFrame(String varname, String[][] frame, List<org.apache.sysml.parser.Expression.ValueType> schema, List<String> colnames)
      Binds a frame object to a registered input variable.
      void setFrame(String varname, String[][] frame, List<org.apache.sysml.parser.Expression.ValueType> schema, List<String> colnames, boolean reuse)
      Binds a frame object to a registered input variable.
      void setMatrix(String varname, double[][] matrix)
      Binds a matrix object to a registered input variable.
      void setMatrix(String varname, double[][] matrix, boolean reuse)
      Binds a matrix object to a registered input variable.
      void setMatrix(String varname, MatrixBlock matrix, boolean reuse)
      Binds a matrix object to a registered input variable.
      void setScalar(String varname, boolean scalar)
      Binds a scalar boolean to a registered input variable.
      void setScalar(String varname, boolean scalar, boolean reuse)
      Binds a scalar boolean to a registered input variable.
      void setScalar(String varname, double scalar)
      Binds a scalar double to a registered input variable.
      void setScalar(String varname, double scalar, boolean reuse)
      Binds a scalar double to a registered input variable.
      void setScalar(String varname, long scalar)
      Binds a scalar long to a registered input variable.
      void setScalar(String varname, long scalar, boolean reuse)
      Binds a scalar long to a registered input variable.
      void setScalar(String varname, org.apache.sysml.runtime.instructions.cp.ScalarObject scalar, boolean reuse)
      Binds a scalar object to a registered input variable.
      void setScalar(String varname, String scalar)
      Binds a scalar string to a registered input variable.
      void setScalar(String varname, String scalar, boolean reuse)
      Binds a scalar string to a registered input variable.
    • Constructor Detail

      • PreparedScript

        protected PreparedScript(org.apache.sysml.runtime.controlprogram.Program prog,
                                 String[] inputs,
                                 String[] outputs)
        Meant to be invoked only from Connection.
        Parameters:
        prog - the DML/PyDML program
        inputs - input variables to register
        outputs - output variables to register
    • Method Detail

      • setScalar

        public void setScalar(String varname,
                              boolean scalar)
                       throws DMLException
        Binds a scalar boolean to a registered input variable.
        Parameters:
        varname - input variable name
        scalar - boolean value
        Throws:
        DMLException - if DMLException occurs
      • setScalar

        public void setScalar(String varname,
                              boolean scalar,
                              boolean reuse)
                       throws DMLException
        Binds a scalar boolean to a registered input variable.
        Parameters:
        varname - input variable name
        scalar - boolean value
        reuse - if true, preserve value over multiple executeScript calls
        Throws:
        DMLException - if DMLException occurs
      • setScalar

        public void setScalar(String varname,
                              long scalar)
                       throws DMLException
        Binds a scalar long to a registered input variable.
        Parameters:
        varname - input variable name
        scalar - long value
        Throws:
        DMLException - if DMLException occurs
      • setScalar

        public void setScalar(String varname,
                              long scalar,
                              boolean reuse)
                       throws DMLException
        Binds a scalar long to a registered input variable.
        Parameters:
        varname - input variable name
        scalar - long value
        reuse - if true, preserve value over multiple executeScript calls
        Throws:
        DMLException - if DMLException occurs
      • setScalar

        public void setScalar(String varname,
                              double scalar)
                       throws DMLException
        Binds a scalar double to a registered input variable.
        Parameters:
        varname - input variable name
        scalar - double value
        Throws:
        DMLException - if DMLException occurs
      • setScalar

        public void setScalar(String varname,
                              double scalar,
                              boolean reuse)
                       throws DMLException
        Binds a scalar double to a registered input variable.
        Parameters:
        varname - input variable name
        scalar - double value
        reuse - if true, preserve value over multiple executeScript calls
        Throws:
        DMLException - if DMLException occurs
      • setScalar

        public void setScalar(String varname,
                              String scalar)
                       throws DMLException
        Binds a scalar string to a registered input variable.
        Parameters:
        varname - input variable name
        scalar - string value
        Throws:
        DMLException - if DMLException occurs
      • setScalar

        public void setScalar(String varname,
                              String scalar,
                              boolean reuse)
                       throws DMLException
        Binds a scalar string to a registered input variable.
        Parameters:
        varname - input variable name
        scalar - string value
        reuse - if true, preserve value over multiple executeScript calls
        Throws:
        DMLException - if DMLException occurs
      • setScalar

        public void setScalar(String varname,
                              org.apache.sysml.runtime.instructions.cp.ScalarObject scalar,
                              boolean reuse)
                       throws DMLException
        Binds a scalar object to a registered input variable. If reuse requested, then the input is guaranteed to be preserved over multiple executeScript calls.
        Parameters:
        varname - input variable name
        scalar - scalar object
        reuse - if true, preserve value over multiple executeScript calls
        Throws:
        DMLException - if DMLException occurs
      • setMatrix

        public void setMatrix(String varname,
                              double[][] matrix)
                       throws DMLException
        Binds a matrix object to a registered input variable.
        Parameters:
        varname - input variable name
        matrix - two-dimensional double array matrix representation
        Throws:
        DMLException - if DMLException occurs
      • setMatrix

        public void setMatrix(String varname,
                              double[][] matrix,
                              boolean reuse)
                       throws DMLException
        Binds a matrix object to a registered input variable.
        Parameters:
        varname - input variable name
        matrix - two-dimensional double array matrix representation
        reuse - if true, preserve value over multiple executeScript calls
        Throws:
        DMLException - if DMLException occurs
      • setMatrix

        public void setMatrix(String varname,
                              MatrixBlock matrix,
                              boolean reuse)
                       throws DMLException
        Binds a matrix object to a registered input variable. If reuse requested, then the input is guaranteed to be preserved over multiple executeScript calls.
        Parameters:
        varname - input variable name
        matrix - matrix represented as a MatrixBlock
        reuse - if true, preserve value over multiple executeScript calls
        Throws:
        DMLException - if DMLException occurs
      • setFrame

        public void setFrame(String varname,
                             String[][] frame)
                      throws DMLException
        Binds a frame object to a registered input variable.
        Parameters:
        varname - input variable name
        frame - two-dimensional string array frame representation
        Throws:
        DMLException - if DMLException occurs
      • setFrame

        public void setFrame(String varname,
                             String[][] frame,
                             List<org.apache.sysml.parser.Expression.ValueType> schema)
                      throws DMLException
        Binds a frame object to a registered input variable.
        Parameters:
        varname - input variable name
        frame - two-dimensional string array frame representation
        schema - list representing the types of the frame columns
        Throws:
        DMLException - if DMLException occurs
      • setFrame

        public void setFrame(String varname,
                             String[][] frame,
                             List<org.apache.sysml.parser.Expression.ValueType> schema,
                             List<String> colnames)
                      throws DMLException
        Binds a frame object to a registered input variable.
        Parameters:
        varname - input variable name
        frame - two-dimensional string array frame representation
        schema - list representing the types of the frame columns
        colnames - frame column names
        Throws:
        DMLException - if DMLException occurs
      • setFrame

        public void setFrame(String varname,
                             String[][] frame,
                             boolean reuse)
                      throws DMLException
        Binds a frame object to a registered input variable.
        Parameters:
        varname - input variable name
        frame - two-dimensional string array frame representation
        reuse - if true, preserve value over multiple executeScript calls
        Throws:
        DMLException - if DMLException occurs
      • setFrame

        public void setFrame(String varname,
                             String[][] frame,
                             List<org.apache.sysml.parser.Expression.ValueType> schema,
                             boolean reuse)
                      throws DMLException
        Binds a frame object to a registered input variable.
        Parameters:
        varname - input variable name
        frame - two-dimensional string array frame representation
        schema - list representing the types of the frame columns
        reuse - if true, preserve value over multiple executeScript calls
        Throws:
        DMLException - if DMLException occurs
      • setFrame

        public void setFrame(String varname,
                             String[][] frame,
                             List<org.apache.sysml.parser.Expression.ValueType> schema,
                             List<String> colnames,
                             boolean reuse)
                      throws DMLException
        Binds a frame object to a registered input variable.
        Parameters:
        varname - input variable name
        frame - two-dimensional string array frame representation
        schema - list representing the types of the frame columns
        colnames - frame column names
        reuse - if true, preserve value over multiple executeScript calls
        Throws:
        DMLException - if DMLException occurs
      • setFrame

        public void setFrame(String varname,
                             FrameBlock frame,
                             boolean reuse)
                      throws DMLException
        Binds a frame object to a registered input variable. If reuse requested, then the input is guaranteed to be preserved over multiple executeScript calls.
        Parameters:
        varname - input variable name
        frame - frame represented as a FrameBlock
        reuse - if true, preserve value over multiple executeScript calls
        Throws:
        DMLException - if DMLException occurs
      • clearParameters

        public void clearParameters()
        Remove all current values bound to input or output variables.
      • executeScript

        public ResultVariables executeScript()
                                      throws DMLException
        Executes the prepared script over the bound inputs, creating the result variables according to bound and registered outputs.
        Returns:
        ResultVariables object encapsulating output results
        Throws:
        DMLException - if DMLException occurs
      • explain

        public String explain()
                       throws DMLException
        Explain the DML/PyDML program and view result as a string.
        Returns:
        string results of explain
        Throws:
        DMLException - if DMLException occurs
      • enableFunctionRecompile

        public void enableFunctionRecompile(String fnamespace,
                                            String... fnames)
                                     throws DMLException
        Enables function recompilation, selectively for the given functions. If dynamic recompilation is globally enabled this has no additional effect; otherwise the given functions are dynamically recompiled once on every entry but not at the granularity of individually last-level program blocks. Use this fine-grained recompilation option for important functions in small-data scenarios where dynamic recompilation overheads might not be amortized.
        Parameters:
        fnamespace - function namespace, null for default namespace
        fnames - function name
        Throws:
        DMLException - if any compilation error occurs

Copyright © 2017 The Apache Software Foundation. All rights reserved.