You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by an...@apache.org on 2014/05/28 17:19:58 UTC
svn commit: r1598038 - in /pig/branches/branch-0.13: CHANGES.txt
src/docs/src/documentation/content/xdocs/func.xml
src/docs/src/documentation/content/xdocs/udf.xml
src/org/apache/pig/builtin/CONCAT.java
src/org/apache/pig/builtin/StringConcat.java
Author: aniket486
Date: Wed May 28 15:19:58 2014
New Revision: 1598038
URL: http://svn.apache.org/r1598038
Log:
PIG-3966: Document variable input arguments of UDFs (lbendig via aniket486)
Modified:
pig/branches/branch-0.13/CHANGES.txt
pig/branches/branch-0.13/src/docs/src/documentation/content/xdocs/func.xml
pig/branches/branch-0.13/src/docs/src/documentation/content/xdocs/udf.xml
pig/branches/branch-0.13/src/org/apache/pig/builtin/CONCAT.java
pig/branches/branch-0.13/src/org/apache/pig/builtin/StringConcat.java
Modified: pig/branches/branch-0.13/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.13/CHANGES.txt?rev=1598038&r1=1598037&r2=1598038&view=diff
==============================================================================
--- pig/branches/branch-0.13/CHANGES.txt (original)
+++ pig/branches/branch-0.13/CHANGES.txt Wed May 28 15:19:58 2014
@@ -32,6 +32,8 @@ PIG-2207: Support custom counters for ag
IMPROVEMENTS
+PIG-3966: Document variable input arguments of UDFs (lbendig via aniket486)
+
PIG-3963: Documentation for BagToString UDF (mrflip via daijy)
PIG-3929: pig.temp.dir should allow to substitute vars as hadoop configuration does (aniket486)
Modified: pig/branches/branch-0.13/src/docs/src/documentation/content/xdocs/func.xml
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.13/src/docs/src/documentation/content/xdocs/func.xml?rev=1598038&r1=1598037&r2=1598038&view=diff
==============================================================================
--- pig/branches/branch-0.13/src/docs/src/documentation/content/xdocs/func.xml (original)
+++ pig/branches/branch-0.13/src/docs/src/documentation/content/xdocs/func.xml Wed May 28 15:19:58 2014
@@ -298,14 +298,14 @@ team_parkyearslist = FOREACH (GROUP team
<!-- ++++++++++++++++++++++++++++++++++++++++++++++ -->
<section id="concat">
<title>CONCAT</title>
- <p>Concatenates two expressions of identical type.</p>
+ <p>Concatenates two or more expressions of identical type.</p>
<section>
<title>Syntax</title>
<table>
<tr>
<td>
- <p>CONCAT (expression, expression)</p>
+ <p>CONCAT (expression, expression, [...expression])</p>
</td>
</tr>
</table>
@@ -327,14 +327,14 @@ team_parkyearslist = FOREACH (GROUP team
<section>
<title>Usage</title>
- <p>Use the CONCAT function to concatenate two expressions. The result values of the two expressions must have identical types.</p>
- <p>If either subexpression is null, the resulting expression is null.</p>
+ <p>Use the CONCAT function to concatenate two or more expressions. The result values of the expressions must have identical types.</p>
+ <p>If any subexpression is null, the resulting expression is null.</p>
</section>
<section>
<title>Example</title>
- <p>In this example fields f2 and f3 are concatenated.</p>
+ <p>In this example, fields f1, an underscore string literal, f2 and f3 are concatenated.</p>
<source>
A = LOAD 'data' as (f1:chararray, f2:chararray, f3:chararray);
@@ -343,12 +343,12 @@ DUMP A;
(hadoop,map,reduce)
(pig,pig,latin)
-X = FOREACH A GENERATE CONCAT(f2,f3);
+X = FOREACH A GENERATE CONCAT(f1, '_', f2,f3);
DUMP X;
-(opensource)
-(mapreduce)
-(piglatin)
+(apache_opensource)
+(hadoop_mapreduce)
+(pig_piglatin)
</source>
</section>
</section>
Modified: pig/branches/branch-0.13/src/docs/src/documentation/content/xdocs/udf.xml
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.13/src/docs/src/documentation/content/xdocs/udf.xml?rev=1598038&r1=1598037&r2=1598038&view=diff
==============================================================================
--- pig/branches/branch-0.13/src/docs/src/documentation/content/xdocs/udf.xml (original)
+++ pig/branches/branch-0.13/src/docs/src/documentation/content/xdocs/udf.xml Wed May 28 15:19:58 2014
@@ -807,7 +807,17 @@ A = LOAD 'student_data' AS (name, age, g
B = FOREACH A GENERATE myudfs.UPPER(name);
DUMP B;
</source>
-
+<p>Variable-length arguments: </p>
+<p>The last input schema field in <code>getArgToFuncMapping()</code> can be marked as vararg, which enables UDF writers to create UDFs that take variable length arguments. This is done by overriding
+the <code>getSchemaType()</code> method:
+</p>
+<source>
+@Override
+public SchemaType getSchemaType() {
+ return SchemaType.VARARG;
+}
+</source>
+<p>For an example see <a href="http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/builtin/CONCAT.java?view=markup">CONCAT</a>.</p>
</section>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++ -->
Modified: pig/branches/branch-0.13/src/org/apache/pig/builtin/CONCAT.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.13/src/org/apache/pig/builtin/CONCAT.java?rev=1598038&r1=1598037&r2=1598038&view=diff
==============================================================================
--- pig/branches/branch-0.13/src/org/apache/pig/builtin/CONCAT.java (original)
+++ pig/branches/branch-0.13/src/org/apache/pig/builtin/CONCAT.java Wed May 28 15:19:58 2014
@@ -33,8 +33,8 @@ import org.apache.pig.impl.logicalLayer.
/**
- * Generates the concatenation of the first two arguments. It can be
- * used with two bytearrays or two chararrays (but not a mixture of the two).
+ * Generates the concatenation of two or more arguments. It can be
+ * used with two or more bytearrays or two or more chararrays (but not a mixture of the two).
*/
public class CONCAT extends EvalFunc<DataByteArray> {
Modified: pig/branches/branch-0.13/src/org/apache/pig/builtin/StringConcat.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.13/src/org/apache/pig/builtin/StringConcat.java?rev=1598038&r1=1598037&r2=1598038&view=diff
==============================================================================
--- pig/branches/branch-0.13/src/org/apache/pig/builtin/StringConcat.java (original)
+++ pig/branches/branch-0.13/src/org/apache/pig/builtin/StringConcat.java Wed May 28 15:19:58 2014
@@ -18,9 +18,9 @@
package org.apache.pig.builtin;
import java.io.IOException;
+
import org.apache.pig.EvalFunc;
import org.apache.pig.PigException;
-import org.apache.pig.EvalFunc.SchemaType;
import org.apache.pig.backend.executionengine.ExecException;
import org.apache.pig.data.DataType;
import org.apache.pig.data.Tuple;