You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apex.apache.org by ch...@apache.org on 2015/09/10 00:32:04 UTC
[16/50] [abbrv] incubator-apex-malhar git commit: MLHR-1740:Fix names
and description of properties in R operator
MLHR-1740:Fix names and description of properties in R operator
Project: http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/commit/c2b5f7cf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/tree/c2b5f7cf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/diff/c2b5f7cf
Branch: refs/heads/master
Commit: c2b5f7cfbac7af8242ad41152f9731f691de5720
Parents: b7ba521
Author: Sandeep Deshmukh <sa...@datatorrent.com>
Authored: Wed Jun 17 18:07:06 2015 +0530
Committer: Pramod Immaneni <pr...@datatorrent.com>
Committed: Tue Jul 28 21:57:53 2015 -0700
----------------------------------------------------------------------
.../java/com/datatorrent/contrib/r/RMax.java | 3 +
.../java/com/datatorrent/contrib/r/RMin.java | 3 +
.../java/com/datatorrent/contrib/r/RScript.java | 144 +++++++++++++------
.../contrib/r/RStandardDeviation.java | 3 +
4 files changed, 107 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/c2b5f7cf/contrib/src/main/java/com/datatorrent/contrib/r/RMax.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/com/datatorrent/contrib/r/RMax.java b/contrib/src/main/java/com/datatorrent/contrib/r/RMax.java
index 5acaeed..181218d 100755
--- a/contrib/src/main/java/com/datatorrent/contrib/r/RMax.java
+++ b/contrib/src/main/java/com/datatorrent/contrib/r/RMax.java
@@ -45,6 +45,9 @@ import com.datatorrent.netlet.util.DTThrowable;
* <br>
* <br>
*
+ * @displayName R Max
+ * @category Scripting
+ * @tags script, r
* @since 2.1.0
*/
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/c2b5f7cf/contrib/src/main/java/com/datatorrent/contrib/r/RMin.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/com/datatorrent/contrib/r/RMin.java b/contrib/src/main/java/com/datatorrent/contrib/r/RMin.java
index d25d491..ef408c1 100755
--- a/contrib/src/main/java/com/datatorrent/contrib/r/RMin.java
+++ b/contrib/src/main/java/com/datatorrent/contrib/r/RMin.java
@@ -45,6 +45,9 @@ import com.datatorrent.netlet.util.DTThrowable;
* <br>
* <br>
*
+ * @displayName R Min
+ * @category Scripting
+ * @tags script, r
* @since 2.1.0
**/
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/c2b5f7cf/contrib/src/main/java/com/datatorrent/contrib/r/RScript.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/com/datatorrent/contrib/r/RScript.java b/contrib/src/main/java/com/datatorrent/contrib/r/RScript.java
index 66c4379..5fb1076 100755
--- a/contrib/src/main/java/com/datatorrent/contrib/r/RScript.java
+++ b/contrib/src/main/java/com/datatorrent/contrib/r/RScript.java
@@ -37,35 +37,46 @@ import com.datatorrent.netlet.util.DTThrowable;
* This operator enables a user to execute a R script on tuples for Map<String, Object>. The script should be in the
* form of a function. This function will then be called by the operator.
*
- * The user should - 1. set the name of the script file (which contains the script in the form of a function) 2. set the
- * function name. 3. set the name of the return variable 4. Make sure that the script file is available in the
- * classpath. 5. set the type of arguments being passed. This will be done in a Map. 6. Send the data in the form of a
- * tuple consisting of a key:value pair where, "key" represents the name of the argument "value" represents the actual
- * value of the argument. A map of all the arguments is created and passed as input. The result will be returned on one
- * of the output ports depending on the type of the return value.
+ * The user should <br>
+ * 1. set the name of the script file (which contains the script in the form of a function) <br>
+ * 2. set the function name <br>
+ * 3. set the name of the return variable <br>
+ * 4. Make sure that the script file is available in the classpath <br>
+ * 5. set the type of arguments being passed. This will be done in a Map <br>
+ * 6. Send the data in the form of a tuple consisting of a key:value pair where, "key" represents the name of the
+ * argument "value" represents the actual value of the argument. A map of all the arguments is created and passed as
+ * input. <br> <br>
+ *
+ * The result will be returned on one of the output ports depending on the type of the return value.
+ * <br> <br>
+ *
+ * <b> Sample Usage Code : </b> oper is an object of type RScript. Create it by passing <br> < name of the R script with
+ * path from classpath>, < name of the function to be invoked>, < name of the return variable>);
+ * <br> <br>
+ * Map<String, RScript.REXP_TYPE> argTypeMap = new HashMap<String, RScript.REXP_TYPE>(); <br>
+ * argTypeMap.put(< argument name>, RScript.< argument type in the form of REXP_TYPE>); <br>
+ * argTypeMap.put(< argument name>, RScript.< argument type in the form of REXP_TYPE>); <br>
+ * ...... <br>
*
- * <b> Sample Usage Code : </b> oper is an object of type RScript. Create it by passing - <name of the R script with
- * path from classpath>, <name of the function to be invoked>, <name of the return variable>);
+ * oper.setArgTypeMap(argTypeMap); <br>
*
- * Map<String, RScript.REXP_TYPE> argTypeMap = new HashMap<String, RScript.REXP_TYPE>(); argTypeMap.put(<argument name>,
- * RScript.<argument type in the form of REXP_TYPE>); argTypeMap.put(<argument name>, RScript.<argument type in the form
- * of REXP_TYPE>); ... ...
- *
- * oper.setArgTypeMap(argTypeMap);
- *
- * HashMap map = new HashMap();
- *
- * map.put("<argument name>", <argument value>); map.put("<argument name>", <argument value>); ... ...
+ * HashMap map = new HashMap(); <br>
*
+ * map.put("< argument name1>", < argument value1>); <br>
+ * map.put("< argument name2>", < argument value2>); <br>
+ * ... ...
+ * <br>
* Note that the number of arguments inserted into the map should be same in number and order as that mentioned in the
- * argument type map above it.
+ * argument type map above it. <br>
*
- * Pass this 'map' to the operator now.
+ * Pass this 'map' to the operator now. <br> <br>
*
* Currently, support has been added for only int, real, string and boolean type of values and the corresponding arrays
- * to be passed and returned from the R scripts.
- *
+ * to be passed and returned from the R scripts. <br>
*
+ * @displayName R Script
+ * @category Scripting
+ * @tags script, r
* @since 2.1.0
* */
@@ -75,16 +86,6 @@ public class RScript extends ScriptOperator
@SuppressWarnings("unused")
private static final long serialVersionUID = 201401161205L;
- public Map<String, REXP_TYPE> getArgTypeMap()
- {
- return argTypeMap;
- }
-
- public void setArgTypeMap(Map<String, REXP_TYPE> argTypeMap)
- {
- this.argTypeMap = argTypeMap;
- }
-
public enum REXP_TYPE {
REXP_INT(1), REXP_DOUBLE(2), REXP_STR(3), REXP_BOOL(6), REXP_ARRAY_INT(32), REXP_ARRAY_DOUBLE(33), REXP_ARRAY_STR(34), REXP_ARRAY_BOOL(36);
@@ -99,13 +100,20 @@ public class RScript extends ScriptOperator
@NotNull
private Map<String, REXP_TYPE> argTypeMap;
- // Name of the return variable
+ /**
+ * Name of the return variable in R script
+ */
private String returnVariable = "retVal";
- // Function name given to the script inside the script file.
+ /**
+ * Function name to be invoked in R script
+ */
@NotNull
private String functionName;
+ /**
+ * Path of the R script file
+ */
@NotNull
protected String scriptFilePath;
@@ -125,44 +133,88 @@ public class RScript extends ScriptOperator
this.setReturnVariable(returnVariable);
}
+ /**
+ * Returns mapping of argument name to argument type
+ * @return argTypeMap
+ * map of argument types
+ */
+ public Map<String, REXP_TYPE> getArgTypeMap()
+ {
+ return argTypeMap;
+ }
+
+ /**
+ * Set mapping of argument name to argument type
+ * @param argTypeMap
+ * map of argument types
+ */
+ public void setArgTypeMap(Map<String, REXP_TYPE> argTypeMap)
+ {
+ this.argTypeMap = argTypeMap;
+ }
+
+ /**
+ * Unused in this operator
+ * @return null
+ */
@Override
public Map<String, Object> getBindings()
{
- return null; // To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
- // Get the value of the name of the variable being returned
+ /**
+ * Get name of the return variable in R script
+ * @return returnVariable
+ */
public String getReturnVariable()
{
return returnVariable;
}
- // Set the name for the return variable
+ /**
+ * Set return variable name in R script
+ * @param returnVariable
+ */
public void setReturnVariable(String returnVariable)
{
this.returnVariable = returnVariable;
}
- // Get the value of the script file with path as specified.
- public String getScriptFilePath()
+ /**
+ * Get name of the function to be invoked in R script
+ * @return functionName
+ */
+ public String getFunctionName()
{
- return scriptFilePath;
+ return functionName;
}
- // Set the value of the script file which should be executed.
- public void setScriptFilePath(String scriptFilePath)
+ /**
+ * Set function to be invoked in R script
+ * @param functionName
+ */
+ public void setFunctionName(String functionName)
{
- this.scriptFilePath = scriptFilePath;
+ this.functionName = functionName;
}
- public String getFunctionName()
+ /**
+ * Get path of R script file
+ * @return scriptFilePath
+ */
+ public String getScriptFilePath()
{
- return functionName;
+ return scriptFilePath;
}
- public void setFunctionName(String functionName)
+ /**
+ * Set path of R script file
+ * @param scriptFilePath
+ */
+ public void setScriptFilePath(String scriptFilePath)
{
- this.functionName = functionName;
+ this.scriptFilePath = scriptFilePath;
}
// Output port on which an int type of value is returned.
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/c2b5f7cf/contrib/src/main/java/com/datatorrent/contrib/r/RStandardDeviation.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/com/datatorrent/contrib/r/RStandardDeviation.java b/contrib/src/main/java/com/datatorrent/contrib/r/RStandardDeviation.java
index 96fac0a..8b54c72 100755
--- a/contrib/src/main/java/com/datatorrent/contrib/r/RStandardDeviation.java
+++ b/contrib/src/main/java/com/datatorrent/contrib/r/RStandardDeviation.java
@@ -45,6 +45,9 @@ import com.datatorrent.netlet.util.DTThrowable;
* <b>Partitions : No</b>, no. <br>
* <br>
*
+ * @displayName R Standard Deviation
+ * @category Scripting
+ * @tags script, r
* @since 2.1.0
*/