org.apache.sysml.api.jmlc

Class Connection

    • Constructor Detail

      • Connection

        public Connection()
        Connection constructor, the starting point for any other JMLC API calls.
    • Method Detail

      • prepareScript

        public PreparedScript prepareScript(String script,
                                            String[] inputs,
                                            String[] outputs,
                                            boolean parsePyDML)
                                     throws DMLException
        Prepares (precompiles) a script and registers input and output variables.
        Parameters:
        script - string representing the DML or PyDML script
        inputs - string array of input variables to register
        outputs - string array of output variables to register
        parsePyDML - true if PyDML, false if DML
        Returns:
        PreparedScript object representing the precompiled script
        Throws:
        DMLException - if DMLException occurs
      • prepareScript

        public PreparedScript prepareScript(String script,
                                            Map<String,String> args,
                                            String[] inputs,
                                            String[] outputs,
                                            boolean parsePyDML)
                                     throws DMLException
        Prepares (precompiles) a script, sets input parameter values, and registers input and output variables.
        Parameters:
        script - string representing the DML or PyDML script
        args - map of input parameters ($) and their values
        inputs - string array of input variables to register
        outputs - string array of output variables to register
        parsePyDML - true if PyDML, false if DML
        Returns:
        PreparedScript object representing the precompiled script
        Throws:
        DMLException - if DMLException occurs
      • close

        public void close()
        Close connection to SystemML, which clears the thread-local DML and compiler configurations.
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface AutoCloseable
      • readScript

        public String readScript(String fname)
                          throws IOException
        Read a DML or PyDML file as a string.
        Parameters:
        fname - the filename of the script
        Returns:
        string content of the script file
        Throws:
        IOException - if IOException occurs
      • readDoubleMatrix

        public double[][] readDoubleMatrix(String fname)
                                    throws IOException
        Reads an input matrix in arbitrary format from HDFS into a dense double array. NOTE: this call currently only supports default configurations for CSV.
        Parameters:
        fname - the filename of the input matrix
        Returns:
        matrix as a two-dimensional double array
        Throws:
        IOException - if IOException occurs
      • readDoubleMatrix

        public double[][] readDoubleMatrix(String fname,
                                           InputInfo iinfo,
                                           long rows,
                                           long cols,
                                           int brlen,
                                           int bclen,
                                           long nnz)
                                    throws IOException
        Reads an input matrix in arbitrary format from HDFS into a dense double array. NOTE: this call currently only supports default configurations for CSV.
        Parameters:
        fname - the filename of the input matrix
        iinfo - InputInfo object
        rows - number of rows in the matrix
        cols - number of columns in the matrix
        brlen - number of rows per block
        bclen - number of columns per block
        nnz - number of non-zero values, -1 indicates unknown
        Returns:
        matrix as a two-dimensional double array
        Throws:
        IOException - if IOException occurs
      • convertToDoubleMatrix

        public double[][] convertToDoubleMatrix(String input,
                                                String meta)
                                         throws IOException
        Converts an input string representation of a matrix in csv or textcell format into a dense double array. The meta data string is the SystemML generated .mtd file including the number of rows and columns.
        Parameters:
        input - string matrix in csv or textcell format
        meta - string representing SystemML matrix metadata in JSON format
        Returns:
        matrix as a two-dimensional double array
        Throws:
        IOException - if IOException occurs
      • convertToDoubleMatrix

        public double[][] convertToDoubleMatrix(String input,
                                                int rows,
                                                int cols)
                                         throws IOException
        Converts an input string representation of a matrix in textcell format into a dense double array.
        Parameters:
        input - string matrix in textcell format
        rows - number of rows in the matrix
        cols - number of columns in the matrix
        Returns:
        matrix as a two-dimensional double array
        Throws:
        IOException - if IOException occurs
      • convertToDoubleMatrix

        public double[][] convertToDoubleMatrix(InputStream input,
                                                int rows,
                                                int cols)
                                         throws IOException
        Converts an input stream of a string matrix in textcell format into a dense double array.
        Parameters:
        input - InputStream to a string matrix in textcell format
        rows - number of rows in the matrix
        cols - number of columns in the matrix
        Returns:
        matrix as a two-dimensional double array
        Throws:
        IOException - if IOException occurs
      • convertToDoubleMatrix

        public double[][] convertToDoubleMatrix(InputStream input,
                                                int rows,
                                                int cols,
                                                String format)
                                         throws IOException
        Converts an input stream of a string matrix in csv or textcell format into a dense double array.
        Parameters:
        input - InputStream to a string matrix in csv or textcell format
        rows - number of rows in the matrix
        cols - number of columns in the matrix
        format - input format of the given stream
        Returns:
        matrix as a two-dimensional double array
        Throws:
        IOException - if IOException occurs
      • readStringFrame

        public String[][] readStringFrame(String fname)
                                   throws IOException
        Reads an input frame in arbitrary format from HDFS into a dense string array. NOTE: this call currently only supports default configurations for CSV.
        Parameters:
        fname - the filename of the input frame
        Returns:
        frame as a two-dimensional string array
        Throws:
        IOException - if IOException occurs
      • readStringFrame

        public String[][] readStringFrame(String fname,
                                          InputInfo iinfo,
                                          long rows,
                                          long cols)
                                   throws IOException
        Reads an input frame in arbitrary format from HDFS into a dense string array. NOTE: this call currently only supports default configurations for CSV.
        Parameters:
        fname - the filename of the input frame
        iinfo - InputInfo object
        rows - number of rows in the frame
        cols - number of columns in the frame
        Returns:
        frame as a two-dimensional string array
        Throws:
        IOException - if IOException occurs
      • convertToStringFrame

        public String[][] convertToStringFrame(String input,
                                               String meta)
                                        throws IOException
        Converts an input string representation of a frame in csv or textcell format into a dense string array. The meta data string is the SystemML generated .mtd file including the number of rows and columns.
        Parameters:
        input - string frame in csv or textcell format
        meta - string representing SystemML frame metadata in JSON format
        Returns:
        frame as a two-dimensional string array
        Throws:
        IOException - if IOException occurs
      • convertToStringFrame

        public String[][] convertToStringFrame(String input,
                                               int rows,
                                               int cols)
                                        throws IOException
        Converts an input string representation of a frame in textcell format into a dense string array.
        Parameters:
        input - string frame in textcell format
        rows - number of rows in the frame
        cols - number of columns in the frame
        Returns:
        frame as a two-dimensional string array
        Throws:
        IOException - if IOException occurs
      • convertToStringFrame

        public String[][] convertToStringFrame(InputStream input,
                                               int rows,
                                               int cols)
                                        throws IOException
        Converts an input stream of a string frame in textcell format into a dense string array.
        Parameters:
        input - InputStream to a string frame in textcell format
        rows - number of rows in the frame
        cols - number of columns in the frame
        Returns:
        frame as a two-dimensional string array
        Throws:
        IOException - if IOException occurs
      • convertToStringFrame

        public String[][] convertToStringFrame(InputStream input,
                                               int rows,
                                               int cols,
                                               String format)
                                        throws IOException
        Converts an input stream of a string frame in csv or textcell format into a dense string array.
        Parameters:
        input - InputStream to a string frame in csv or textcell format
        rows - number of rows in the frame
        cols - number of columns in the frame
        format - input format of the given stream
        Returns:
        frame as a two-dimensional string array
        Throws:
        IOException - if IOException occurs
      • readTransformMetaDataFromFile

        public FrameBlock readTransformMetaDataFromFile(String metapath)
                                                 throws IOException
        Reads transform meta data from an HDFS file path and converts it into an in-memory FrameBlock object. The column names in the meta data file 'column.names' is processed with default separator ','.
        Parameters:
        metapath - hdfs file path to meta data directory
        Returns:
        FrameBlock object representing transform metadata
        Throws:
        IOException - if IOException occurs
      • readTransformMetaDataFromFile

        public FrameBlock readTransformMetaDataFromFile(String spec,
                                                        String metapath)
                                                 throws IOException
        Reads transform meta data from an HDFS file path and converts it into an in-memory FrameBlock object. The column names in the meta data file 'column.names' is processed with default separator ','.
        Parameters:
        spec - transform specification as json string
        metapath - hdfs file path to meta data directory
        Returns:
        FrameBlock object representing transform metadata
        Throws:
        IOException - if IOException occurs
      • readTransformMetaDataFromFile

        public FrameBlock readTransformMetaDataFromFile(String spec,
                                                        String metapath,
                                                        String colDelim)
                                                 throws IOException
        Reads transform meta data from an HDFS file path and converts it into an in-memory FrameBlock object.
        Parameters:
        spec - transform specification as json string
        metapath - hdfs file path to meta data directory
        colDelim - separator for processing column names in the meta data file 'column.names'
        Returns:
        FrameBlock object representing transform metadata
        Throws:
        IOException - if IOException occurs
      • readTransformMetaDataFromPath

        public FrameBlock readTransformMetaDataFromPath(String metapath)
                                                 throws IOException
        Reads transform meta data from the class path and converts it into an in-memory FrameBlock object. The column names in the meta data file 'column.names' is processed with default separator ','.
        Parameters:
        metapath - resource path to meta data directory
        Returns:
        FrameBlock object representing transform metadata
        Throws:
        IOException - if IOException occurs
      • readTransformMetaDataFromPath

        public FrameBlock readTransformMetaDataFromPath(String spec,
                                                        String metapath)
                                                 throws IOException
        Reads transform meta data from the class path and converts it into an in-memory FrameBlock object. The column names in the meta data file 'column.names' is processed with default separator ','.
        Parameters:
        spec - transform specification as json string
        metapath - resource path to meta data directory
        Returns:
        FrameBlock object representing transform metadata
        Throws:
        IOException - if IOException occurs
      • readTransformMetaDataFromPath

        public FrameBlock readTransformMetaDataFromPath(String spec,
                                                        String metapath,
                                                        String colDelim)
                                                 throws IOException
        Reads transform meta data from the class path and converts it into an in-memory FrameBlock object.
        Parameters:
        spec - transform specification as json string
        metapath - resource path to meta data directory
        colDelim - separator for processing column names in the meta data file 'column.names'
        Returns:
        FrameBlock object representing transform metadata
        Throws:
        IOException - if IOException occurs

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