You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by da...@apache.org on 2012/03/16 23:16:45 UTC

svn commit: r1301793 - in /pig/branches/branch-0.9/test/e2e/pig: tests/nightly.conf udfs/java/org/apache/pig/test/udf/evalfunc/UdfContextFrontend.java

Author: daijy
Date: Fri Mar 16 22:16:45 2012
New Revision: 1301793

URL: http://svn.apache.org/viewvc?rev=1301793&view=rev
Log:
PIG-2576: Change in behavior for UDFContext.getUDFContext().getJobConf() in front-end

Added:
    pig/branches/branch-0.9/test/e2e/pig/udfs/java/org/apache/pig/test/udf/evalfunc/UdfContextFrontend.java
Modified:
    pig/branches/branch-0.9/test/e2e/pig/tests/nightly.conf

Modified: pig/branches/branch-0.9/test/e2e/pig/tests/nightly.conf
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.9/test/e2e/pig/tests/nightly.conf?rev=1301793&r1=1301792&r2=1301793&view=diff
==============================================================================
--- pig/branches/branch-0.9/test/e2e/pig/tests/nightly.conf (original)
+++ pig/branches/branch-0.9/test/e2e/pig/tests/nightly.conf Fri Mar 16 22:16:45 2012
@@ -3620,6 +3620,21 @@ store E into ':OUTPATH:';\, 
                                 STORE B1 INTO ':OUTPATH:.1';
                                 C = DISTINCT B1 ;
                                 store C into ':OUTPATH:.2';?,
+                    }, {
+                        # PIG-2576
+                        'num' => 4,
+                        'execonly' => 'mapred',
+                        'pig' => q?register :FUNCPATH:/testudf.jar;
+                                define printconf org.apache.pig.test.udf.evalfunc.UdfContextFrontend('dummy');
+                                a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
+                                b = limit a 1;
+                                c = foreach b generate printconf(name);
+	                        store c into ':OUTPATH:';
+                                fs -ls;
+                                ?,
+                        'rc' => 0,
+                        'not_expected_out_regex' => "checkJobConf: conf is null: false",
+                        'expected_out_regex' => "checkJobConf: conf is null: true",
                     }
                 ],
             },

Added: pig/branches/branch-0.9/test/e2e/pig/udfs/java/org/apache/pig/test/udf/evalfunc/UdfContextFrontend.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.9/test/e2e/pig/udfs/java/org/apache/pig/test/udf/evalfunc/UdfContextFrontend.java?rev=1301793&view=auto
==============================================================================
--- pig/branches/branch-0.9/test/e2e/pig/udfs/java/org/apache/pig/test/udf/evalfunc/UdfContextFrontend.java (added)
+++ pig/branches/branch-0.9/test/e2e/pig/udfs/java/org/apache/pig/test/udf/evalfunc/UdfContextFrontend.java Fri Mar 16 22:16:45 2012
@@ -0,0 +1,27 @@
+package org.apache.pig.test.udf.evalfunc;
+
+import java.io.IOException;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.pig.EvalFunc;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.util.UDFContext;
+
+public class UdfContextFrontend extends EvalFunc<Boolean> {
+	
+	public UdfContextFrontend(){}
+	
+	public UdfContextFrontend(String param){
+		checkJobConf(); // call here and it will execute multiple times in front end
+	}
+	
+	private void checkJobConf() {
+		Configuration jobConf = UDFContext.getUDFContext().getJobConf();
+		System.out.println("checkJobConf: conf is null: " + (jobConf == null) + " conf: "  + jobConf);
+	}
+	
+	public Boolean exec(Tuple input) throws IOException {
+		checkJobConf(); // will execute in map only
+		return true;
+	}
+}