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 2016/04/13 23:00:09 UTC

incubator-systemml git commit: [SYSTEMML-551] Enhance JMLC javadocs

Repository: incubator-systemml
Updated Branches:
  refs/heads/master 6aa4eed52 -> b989b0033


[SYSTEMML-551] Enhance JMLC javadocs

Closes #112.


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

Branch: refs/heads/master
Commit: b989b0033405780c53a8b4802227364280cb27c4
Parents: 6aa4eed
Author: Deron Eriksson <de...@us.ibm.com>
Authored: Wed Apr 13 13:57:33 2016 -0700
Committer: Deron Eriksson <de...@us.ibm.com>
Committed: Wed Apr 13 13:57:33 2016 -0700

----------------------------------------------------------------------
 .../org/apache/sysml/api/jmlc/Connection.java   | 114 +++++++-----
 .../org/apache/sysml/api/jmlc/JMLCUtils.java    |  20 ++-
 .../apache/sysml/api/jmlc/PreparedScript.java   | 177 +++++++++++++++----
 .../apache/sysml/api/jmlc/ResultVariables.java  |  35 ++--
 4 files changed, 254 insertions(+), 92 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/b989b003/src/main/java/org/apache/sysml/api/jmlc/Connection.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/api/jmlc/Connection.java b/src/main/java/org/apache/sysml/api/jmlc/Connection.java
index e2d76da..fe6caef 100644
--- a/src/main/java/org/apache/sysml/api/jmlc/Connection.java
+++ b/src/main/java/org/apache/sysml/api/jmlc/Connection.java
@@ -71,11 +71,32 @@ import org.apache.wink.json4j.JSONArray;
 import org.apache.wink.json4j.JSONObject;
 
 /**
- * JMLC (Java Machine Learning Connector) API:
+ * Interaction with SystemML using the JMLC (Java Machine Learning Connector) API is initiated with
+ * a {@link Connection} object. The JMLC API is patterned
+ * after JDBC. A DML script is precompiled by calling
+ * the {@link #prepareScript(String, String[], String[], boolean)}
+ * method or the {@link #prepareScript(String, HashMap, String[], String[], boolean)}
+ * method on the {@link Connection} object, which returns a
+ * {@link PreparedScript} object. Note that this is similar to calling
+ * a {@code prepareStatement} method on a JDBC {@code Connection} object.
  * 
- * NOTES: 
- *   * Currently fused API and implementation in order to reduce complexity. 
- *   * See JUnit test cases (org.apache.sysml.test.integration.functions.jmlc) for examples. 
+ * <p>
+ * Following this, input variable data is passed to the script by calling the
+ * {@code setFrame}, {@code setMatrix}, and {@code setScalar} methods of the {@link PreparedScript}
+ * object. The script is executed via {@link PreparedScript}'s
+ * {@link PreparedScript#executeScript() executeScript} method,
+ * which returns a {@link ResultVariables} object, which is similar to a JDBC
+ * {@code ResultSet}. Data can be read from a {@link ResultVariables} object by calling
+ * its {@link ResultVariables#getFrame(String) getFrame} and
+ * {@link ResultVariables#getMatrix(String) getMatrix} methods.
+ * 
+ * <p>
+ * For examples, please see the following:
+ * <ul>
+ *   <li>JMLC JUnit test cases (org.apache.sysml.test.integration.functions.jmlc)</li>
+ *   <li><a target="_blank" href="http://apache.github.io/incubator-systemml/jmlc.html">JMLC section
+ *   of SystemML online documentation</li>
+ * </ul>
  */
 public class Connection 
 {	
@@ -85,7 +106,7 @@ public class Connection
 	private CompilerConfig _cconf = null;
 	
 	/**
-	 * Connection constructor, starting point for any other JMLC API calls.
+	 * Connection constructor, the starting point for any other JMLC API calls.
 	 * 
 	 */
 	public Connection()
@@ -118,11 +139,13 @@ public class Connection
 	}
 	
 	/**
+	 * Prepares (precompiles) a script and registers input and output variables.
 	 * 
-	 * @param script
-	 * @param inputs
-	 * @param outputs
-	 * @return
+	 * @param script string representing the DML or PyDML script
+	 * @param inputs string array of input variables to register
+	 * @param outputs string array of output variables to register
+	 * @param parsePyDML {@code true} if PyDML, {@code false} if DML
+	 * @return PreparedScript object representing the precompiled script
 	 * @throws DMLException
 	 */
 	public PreparedScript prepareScript( String script, String[] inputs, String[] outputs, boolean parsePyDML) 
@@ -132,12 +155,14 @@ public class Connection
 	}
 	
 	/**
+	 * Prepares (precompiles) a script, sets input parameter values, and registers input and output variables.
 	 * 
-	 * @param script
-	 * @param args
-	 * @param inputs
-	 * @param outputs
-	 * @return
+	 * @param script string representing the DML or PyDML script
+	 * @param args map of input parameters ($) and their values
+	 * @param inputs string array of input variables to register
+	 * @param outputs string array of output variables to register
+	 * @param parsePyDML {@code true} if PyDML, {@code false} if DML
+	 * @return PreparedScript object representing the precompiled script
 	 * @throws DMLException
 	 */
 	public PreparedScript prepareScript( String script, HashMap<String, String> args, String[] inputs, String[] outputs, boolean parsePyDML) 
@@ -186,7 +211,8 @@ public class Connection
 	}
 	
 	/**
-	 * 
+	 * Close connection to SystemML, which clears the
+	 * thread-local DML and compiler configurations.
 	 */
 	public void close() {
 		//clear thread-local dml / compiler configs
@@ -194,9 +220,10 @@ public class Connection
 	}
 	
 	/**
+	 * Read a DML or PyDML file as a string.
 	 * 
-	 * @param fname
-	 * @return
+	 * @param fname the filename of the script
+	 * @return string content of the script file
 	 * @throws IOException
 	 */
 	public String readScript(String fname) 
@@ -240,8 +267,8 @@ public class Connection
 	 * Reads an input matrix in arbitrary format from HDFS into a dense double array.
 	 * NOTE: this call currently only supports default configurations for CSV.
 	 * 
-	 * @param fname
-	 * @return
+	 * @param fname the filename of the input matrix
+	 * @return matrix as a two-dimensional double array
 	 * @throws IOException
 	 */
 	public double[][] readDoubleMatrix(String fname) 
@@ -276,14 +303,14 @@ public class Connection
 	 * Reads an input matrix in arbitrary format from HDFS into a dense double array.
 	 * NOTE: this call currently only supports default configurations for CSV.
 	 * 
-	 * @param fname
-	 * @param iinfo
-	 * @param rows
-	 * @param cols
-	 * @param brlen
-	 * @param bclen
-	 * @param nnz
-	 * @return
+	 * @param fname the filename of the input matrix
+	 * @param iinfo InputInfo object
+	 * @param rows number of rows in the matrix
+	 * @param cols number of columns in the matrix
+	 * @param brlen number of rows per block
+	 * @param bclen number of columns per block
+	 * @param nnz number of non-zero values, -1 indicates unknown
+	 * @return matrix as a two-dimensional double array
 	 * @throws IOException
 	 */
 	public double[][] readDoubleMatrix(String fname, InputInfo iinfo, long rows, long cols, int brlen, int bclen, long nnz) 
@@ -304,10 +331,9 @@ public class Connection
 	 * into a dense double array. The meta data string is the SystemML generated
 	 * .mtd file including the number of rows and columns.  
 	 * 
-	 * @param input
-	 * @param rows
-	 * @param cols
-	 * @return
+	 * @param input string matrix in textcell format
+	 * @param meta string representing SystemML matrix metadata in JSON format
+	 * @return matrix as a two-dimensional double array
 	 * @throws IOException
 	 */
 	public double[][] convertToDoubleMatrix(String input, String meta) 
@@ -340,10 +366,10 @@ public class Connection
 	 * specified because textcell only represents non-zero values and hence
 	 * does not define the dimensions in the general case.
 	 * 
-	 * @param input
-	 * @param rows
-	 * @param cols
-	 * @return
+	 * @param input string matrix in textcell format
+	 * @param rows number of rows in the matrix
+	 * @param cols number of columns in the matrix
+	 * @return matrix as a two-dimensional double array
 	 * @throws IOException
 	 */
 	public double[][] convertToDoubleMatrix(String input, int rows, int cols) 
@@ -359,10 +385,10 @@ public class Connection
 	 * specified because textcell only represents non-zero values and hence
 	 * does not define the dimensions in the general case.
 	 * 
-	 * @param input
-	 * @param rows
-	 * @param cols
-	 * @return
+	 * @param input InputStream to a string matrix in textcell format
+	 * @param rows number of rows in the matrix
+	 * @param cols number of columns in the matrix
+	 * @return matrix as a two-dimensional double array
 	 * @throws IOException
 	 */
 	public double[][] convertToDoubleMatrix(InputStream input, int rows, int cols) 
@@ -392,7 +418,7 @@ public class Connection
 	 * 
 	 * @param spec      transform specification as json string
 	 * @param metapath  hdfs file path to meta data directory
-	 * @return
+	 * @return FrameBlock object representing transform metadata
 	 * @throws IOException
 	 */
 	public FrameBlock readTransformMetaDataFromFile(String spec, String metapath) throws IOException {
@@ -406,7 +432,7 @@ public class Connection
 	 * @param spec      transform specification as json string
 	 * @param metapath  hdfs file path to meta data directory
 	 * @param colDelim  separator for processing column names in the meta data file 'column.names'
-	 * @return
+	 * @return FrameBlock object representing transform metadata
 	 * @throws IOException
 	 */
 	public FrameBlock readTransformMetaDataFromFile(String spec, String metapath, String colDelim) 
@@ -451,7 +477,7 @@ public class Connection
 	 * 
 	 * @param spec      transform specification as json string
 	 * @param metapath  resource path to meta data directory
-	 * @return
+	 * @return FrameBlock object representing transform metadata
 	 * @throws IOException
 	 */
 	public FrameBlock readTransformMetaDataFromPath(String spec, String metapath) throws IOException {
@@ -465,7 +491,7 @@ public class Connection
 	 * @param spec      transform specification as json string
 	 * @param metapath  resource path to meta data directory
 	 * @param colDelim  separator for processing column names in the meta data file 'column.names'
-	 * @return
+	 * @return FrameBlock object representing transform metadata
 	 * @throws IOException
 	 */
 	public FrameBlock readTransformMetaDataFromPath(String spec, String metapath, String colDelim) 
@@ -511,7 +537,7 @@ public class Connection
 	 * @param rows      maximum number of distinct items (number of rows in frame block)
 	 * @param colnames  column names, ordered by position
 	 * @param meta      map of (column name, recode map)-pairs, with recode maps in their original csv representation
-	 * @return
+	 * @return FrameBlock object representing transform metadata
 	 * @throws IOException
 	 */
 	public FrameBlock convertToTransformMetaDataFrame(String spec, int rows, List<String> colnames, HashMap<String,String> meta) 

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/b989b003/src/main/java/org/apache/sysml/api/jmlc/JMLCUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/api/jmlc/JMLCUtils.java b/src/main/java/org/apache/sysml/api/jmlc/JMLCUtils.java
index 8c9a6ae..d8bec42 100644
--- a/src/main/java/org/apache/sysml/api/jmlc/JMLCUtils.java
+++ b/src/main/java/org/apache/sysml/api/jmlc/JMLCUtils.java
@@ -32,13 +32,18 @@ import org.apache.sysml.runtime.controlprogram.WhileProgramBlock;
 import org.apache.sysml.runtime.instructions.Instruction;
 import org.apache.sysml.runtime.instructions.cp.VariableCPInstruction;
 
+/**
+ * Utility class containing static methods for working with JMLC.
+ *
+ */
 public class JMLCUtils 
 {
 	/**
 	 * Removes rmvar instructions that would remove any of the given outputs.
 	 * This is important for keeping registered outputs after the program terminates.
 	 * 
-	 * @param prog
+	 * @param prog the DML/PyDML program
+	 * @param outputs registered output variables
 	 */
 	public static void cleanupRuntimeProgram( Program prog, String[] outputs)
 	{
@@ -58,9 +63,10 @@ public class JMLCUtils
 	}
 	
 	/**
+	 * Cleanup program blocks (called recursively).
 	 * 
-	 * @param pb
-	 * @param outputs
+	 * @param pb program block
+	 * @param outputs registered output variables
 	 */
 	public static void rCleanupRuntimeProgram( ProgramBlock pb, String[] outputs )
 	{
@@ -92,10 +98,12 @@ public class JMLCUtils
 	}
 	
 	/**
+	 * Cleanup runtime instructions, removing rmvar instructions for
+	 * any of the given output variable names.
 	 * 
-	 * @param insts
-	 * @param outputs
-	 * @return
+	 * @param insts list of instructions
+	 * @param outputs registered output variables
+	 * @return list of instructions
 	 */
 	public static ArrayList<Instruction> cleanupRuntimeInstructions( ArrayList<Instruction> insts, String[] outputs )
 	{		

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/b989b003/src/main/java/org/apache/sysml/api/jmlc/PreparedScript.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/api/jmlc/PreparedScript.java b/src/main/java/org/apache/sysml/api/jmlc/PreparedScript.java
index f25d19d..ca10a44 100644
--- a/src/main/java/org/apache/sysml/api/jmlc/PreparedScript.java
+++ b/src/main/java/org/apache/sysml/api/jmlc/PreparedScript.java
@@ -51,9 +51,7 @@ import org.apache.sysml.runtime.util.DataConverter;
 import org.apache.sysml.utils.Explain;
 
 /**
- * JMLC (Java Machine Learning Connector) API:
- * 
- * NOTE: Currently fused API and implementation in order to reduce complexity. 
+ * Representation of a prepared (precompiled) DML/PyDML script.
  */
 public class PreparedScript 
 {
@@ -66,8 +64,12 @@ public class PreparedScript
 	private Program _prog = null;
 	private LocalVariableMap _vars = null; 
 	
-	/** 
-	 * Meant to be invoked only from Connection 
+	/**
+	 * Meant to be invoked only from Connection.
+	 * 
+	 * @param prog the DML/PyDML program
+	 * @param inputs input variables to register
+	 * @param outputs output variables to register
 	 */
 	protected PreparedScript( Program prog, String[] inputs, String[] outputs ) 
 	{
@@ -84,42 +86,93 @@ public class PreparedScript
 		_inVarReuse = new HashMap<String, Data>();
 	}
 	
-	/** Binds a scalar boolean to a registered input variable. */
+	/**
+	 * Binds a scalar boolean to a registered input variable.
+	 * 
+	 * @param varname input variable name
+	 * @param scalar boolean value
+	 * @throws DMLException
+	 */
 	public void setScalar(String varname, boolean scalar) throws DMLException {
 		setScalar(varname, scalar, false);
 	}
 	
-	/** Binds a scalar boolean to a registered input variable. */
+	/**
+	 * Binds a scalar boolean to a registered input variable.
+	 * 
+	 * @param varname input variable name
+	 * @param scalar boolean value
+	 * @param reuse if {@code true}, preserve value over multiple {@code executeScript} calls
+	 * @throws DMLException
+	 */
 	public void setScalar(String varname, boolean scalar, boolean reuse) throws DMLException {
 		setScalar(varname, new BooleanObject(varname, scalar), reuse);
 	}
 	
-	/** Binds a scalar long to a registered input variable. */
+	/**
+	 * Binds a scalar long to a registered input variable.
+	 * 
+	 * @param varname input variable name
+	 * @param scalar long value
+	 * @throws DMLException
+	 */
 	public void setScalar(String varname, long scalar) throws DMLException {
 		setScalar(varname, scalar, false);
 	}
 	
-	/** Binds a scalar long to a registered input variable. */
+	/**
+	 * Binds a scalar long to a registered input variable.
+	 * 
+	 * @param varname input variable name
+	 * @param scalar long value
+	 * @param reuse if {@code true}, preserve value over multiple {@code executeScript} calls
+	 * @throws DMLException
+	 */
 	public void setScalar(String varname, long scalar, boolean reuse) throws DMLException {
 		setScalar(varname, new IntObject(varname, scalar), reuse);
 	}
 	
-	/** Binds a scalar double to a registered input variable. */
+	/** Binds a scalar double to a registered input variable.
+	 * 
+	 * @param varname input variable name
+	 * @param scalar double value
+	 * @throws DMLException
+	 */
 	public void setScalar(String varname, double scalar) throws DMLException {
 		setScalar(varname, scalar, false);
 	}
 	
-	/** Binds a scalar double to a registered input variable. */
+	/**
+	 * Binds a scalar double to a registered input variable.
+	 * 
+	 * @param varname input variable name
+	 * @param scalar double value
+	 * @param reuse if {@code true}, preserve value over multiple {@code executeScript} calls
+	 * @throws DMLException
+	 */
 	public void setScalar(String varname, double scalar, boolean reuse) throws DMLException {
 		setScalar(varname, new DoubleObject(varname, scalar), reuse);
 	}
 	
-	/** Binds a scalar string to a registered input variable. */
+	/**
+	 * Binds a scalar string to a registered input variable.
+	 * 
+	 * @param varname input variable name
+	 * @param scalar string value
+	 * @throws DMLException
+	 */
 	public void setScalar(String varname, String scalar) throws DMLException {
 		setScalar(varname, scalar, false);
 	}
 	
-	/** Binds a scalar string to a registered input variable. */
+	/**
+	 * Binds a scalar string to a registered input variable.
+	 * 
+	 * @param varname input variable name
+	 * @param scalar string value
+	 * @param reuse if {@code true}, preserve value over multiple {@code executeScript} calls
+	 * @throws DMLException
+	 */
 	public void setScalar(String varname, String scalar, boolean reuse) throws DMLException {
 		setScalar(varname, new StringObject(varname, scalar), reuse);
 	}
@@ -129,9 +182,9 @@ public class PreparedScript
 	 * If reuse requested, then the input is guaranteed to be 
 	 * preserved over multiple <code>executeScript</code> calls. 
 	 * 
-	 * @param varname
-	 * @param scalar
-	 * @param reuse
+	 * @param varname input variable name
+	 * @param scalar scalar object
+	 * @param reuse if {@code true}, preserve value over multiple {@code executeScript} calls
 	 * @throws DMLException
 	 */
 	public void setScalar(String varname, ScalarObject scalar, boolean reuse) 
@@ -143,12 +196,25 @@ public class PreparedScript
 		_vars.put(varname, scalar);
 	}
 
-	/** Binds a matrix object to a registered input variable. */
+	/**
+	 * Binds a matrix object to a registered input variable.
+	 * 
+	 * @param varname input variable name
+	 * @param matrix two-dimensional double array matrix representation
+	 * @throws DMLException
+	 */
 	public void setMatrix(String varname, double[][] matrix) throws DMLException {
 		setMatrix(varname, matrix, false);
 	}
 	
-	/** Binds a matrix object to a registered input variable. */
+	/**
+	 * Binds a matrix object to a registered input variable.
+	 * 
+	 * @param varname input variable name
+	 * @param matrix two-dimensional double array matrix representation
+	 * @param reuse if {@code true}, preserve value over multiple {@code executeScript} calls
+	 * @throws DMLException
+	 */
 	public void setMatrix(String varname, double[][] matrix, boolean reuse) throws DMLException {
 		setMatrix(varname, DataConverter.convertToMatrixBlock(matrix), reuse);
 	}
@@ -158,8 +224,9 @@ public class PreparedScript
 	 * If reuse requested, then the input is guaranteed to be 
 	 * preserved over multiple <code>executeScript</code> calls. 
 	 * 
-	 * @param varname
-	 * @param matrix
+	 * @param varname input variable name
+	 * @param matrix matrix represented as a MatrixBlock
+	 * @param reuse if {@code true}, preserve value over multiple {@code executeScript} calls
 	 * @throws DMLException
 	 */
 	public void setMatrix(String varname, MatrixBlock matrix, boolean reuse)
@@ -186,32 +253,77 @@ public class PreparedScript
 		}
 	}
 
-	/** Binds a frame object to a registered input variable. */
+	/**
+	 * Binds a frame object to a registered input variable.
+	 * 
+	 * @param varname input variable name
+	 * @param frame two-dimensional string array frame representation
+	 * @throws DMLException
+	 */
 	public void setFrame(String varname, String[][] frame) throws DMLException {
 		setFrame(varname, frame, false);
 	}
 	
-	/** Binds a frame object to a registered input variable. */
+	/**
+	 * Binds a frame object to a registered input variable.
+	 * 
+	 * @param varname input variable name
+	 * @param frame two-dimensional string array frame representation
+	 * @param schema list representing the types of the frame columns
+	 * @throws DMLException
+	 */
 	public void setFrame(String varname, String[][] frame, List<ValueType> schema) throws DMLException {
 		setFrame(varname, frame, schema, false);
 	}
 	
-	/** Binds a frame object to a registered input variable. */
+	/**
+	 * Binds a frame object to a registered input variable.
+	 * 
+	 * @param varname input variable name
+	 * @param frame two-dimensional string array frame representation
+	 * @param schema list representing the types of the frame columns
+	 * @param colnames frame column names
+	 * @throws DMLException
+	 */
 	public void setFrame(String varname, String[][] frame, List<ValueType> schema, List<String> colnames) throws DMLException {
 		setFrame(varname, frame, schema, colnames, false);
 	}
 	
-	/** Binds a frame object to a registered input variable. */
+	/**
+	 * Binds a frame object to a registered input variable.
+	 * 
+	 * @param varname input variable name
+	 * @param frame two-dimensional string array frame representation
+	 * @param reuse if {@code true}, preserve value over multiple {@code executeScript} calls
+	 * @throws DMLException
+	 */
 	public void setFrame(String varname, String[][] frame, boolean reuse) throws DMLException {
 		setFrame(varname, DataConverter.convertToFrameBlock(frame), reuse);
 	}
 	
-	/** Binds a frame object to a registered input variable. */
+	/**
+	 * Binds a frame object to a registered input variable.
+	 * 
+	 * @param varname input variable name
+	 * @param frame two-dimensional string array frame representation
+	 * @param schema list representing the types of the frame columns
+	 * @param reuse if {@code true}, preserve value over multiple {@code executeScript} calls
+	 * @throws DMLException
+	 */
 	public void setFrame(String varname, String[][] frame, List<ValueType> schema, boolean reuse) throws DMLException {
 		setFrame(varname, DataConverter.convertToFrameBlock(frame, schema), reuse);
 	}
 	
-	/** Binds a frame object to a registered input variable. */
+	/**
+	 * Binds a frame object to a registered input variable.
+	 * 
+	 * @param varname input variable name
+	 * @param frame two-dimensional string array frame representation
+	 * @param schema list representing the types of the frame columns
+	 * @param colnames frame column names
+	 * @param reuse if {@code true}, preserve value over multiple {@code executeScript} calls
+	 * @throws DMLException
+	 */
 	public void setFrame(String varname, String[][] frame, List<ValueType> schema, List<String> colnames, boolean reuse) throws DMLException {
 		setFrame(varname, DataConverter.convertToFrameBlock(frame, schema, colnames), reuse);
 	}
@@ -221,9 +333,9 @@ public class PreparedScript
 	 * If reuse requested, then the input is guaranteed to be 
 	 * preserved over multiple <code>executeScript</code> calls. 
 	 * 
-	 * @param varname
-	 * @param frame
-	 * @param reuse
+	 * @param varname input variable name
+	 * @param frame frame represented as a FrameBlock
+	 * @param reuse if {@code true}, preserve value over multiple {@code executeScript} calls
 	 * @throws DMLException
 	 */
 	public void setFrame(String varname, FrameBlock frame, boolean reuse)
@@ -259,9 +371,9 @@ public class PreparedScript
 	
 	/**
 	 * Executes the prepared script over the bound inputs, creating the
-	 * result variables according to bound and registered outputs. 
+	 * result variables according to bound and registered outputs.
 	 * 
-	 * @return
+	 * @return ResultVariables object encapsulating output results
 	 * @throws DMLException 
 	 */
 	public ResultVariables executeScript() 
@@ -294,8 +406,9 @@ public class PreparedScript
 	}
 	
 	/**
+	 * Explain the DML/PyDML program and view result as a string.
 	 * 
-	 * @return
+	 * @return string results of explain
 	 * @throws DMLException
 	 */
 	public String explain() throws DMLException {

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/b989b003/src/main/java/org/apache/sysml/api/jmlc/ResultVariables.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/api/jmlc/ResultVariables.java b/src/main/java/org/apache/sysml/api/jmlc/ResultVariables.java
index 1add0e4..3203cbd 100644
--- a/src/main/java/org/apache/sysml/api/jmlc/ResultVariables.java
+++ b/src/main/java/org/apache/sysml/api/jmlc/ResultVariables.java
@@ -31,9 +31,10 @@ import org.apache.sysml.runtime.matrix.data.MatrixBlock;
 import org.apache.sysml.runtime.util.DataConverter;
 
 /**
- * JMLC (Java Machine Learning Connector) API:
- * 
- * NOTE: Currently fused API and implementation in order to reduce complexity. 
+ * A ResultVariables object holds the data returned by a call
+ * to {@link PreparedScript}'s {@link PreparedScript#executeScript executeScript}
+ * method, which executes a DML/PyDML script.
+ *
  */
 public class ResultVariables 
 {
@@ -45,20 +46,31 @@ public class ResultVariables
 		_out = new HashMap<String, Data>();
 	}
 	
+	/**
+	 * Obtain the output variable names held by this ResultVariables object.
+	 * 
+	 * @return the set of output variable names
+	 */
 	public Set<String> getVariableNames()
 	{
 		return _out.keySet();
 	}
 	
+	/**
+	 * Obtain the number of output data held by this ResultVariables object.
+	 * 
+	 * @return the number of output variables with data
+	 */
 	public int size()
 	{
 		return _out.size();
 	}
 	
 	/**
+	 * Obtain the matrix represented by the given output variable.
 	 * 
-	 * @param varname
-	 * @return
+	 * @param varname output variable name
+	 * @return matrix as a two-dimensional double array
 	 * @throws DMLException
 	 */
 	public double[][] getMatrix(String varname) 
@@ -84,9 +96,10 @@ public class ResultVariables
 	}
 	
 	/**
+	 * Obtain the frame represented by the given output variable.
 	 * 
-	 * @param varname
-	 * @return
+	 * @param varname output variable name
+	 * @return frame as a two-dimensional string array
 	 * @throws DMLException
 	 */
 	public String[][] getFrame(String varname) 
@@ -112,10 +125,12 @@ public class ResultVariables
 	}
 	
 	/**
+	 * Add the output variable name and generated output data to the ResultVariable
+	 * object. Called during the execution of {@link PreparedScript}'s
+	 * {@link PreparedScript#executeScript executeScript} method.
 	 * 
-	 * 
-	 * @param ovar
-	 * @param data
+	 * @param ovar output variable name
+	 * @param data generated output data
 	 */
 	protected void addResult(String ovar, Data data) 
 	{