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/09 21:20:13 UTC

svn commit: r1299022 - in /pig/branches/branch-0.9: CHANGES.txt src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/MapReduceLauncher.java src/org/apache/pig/impl/util/UDFContext.java

Author: daijy
Date: Fri Mar  9 20:20:13 2012
New Revision: 1299022

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

Modified:
    pig/branches/branch-0.9/CHANGES.txt
    pig/branches/branch-0.9/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/MapReduceLauncher.java
    pig/branches/branch-0.9/src/org/apache/pig/impl/util/UDFContext.java

Modified: pig/branches/branch-0.9/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.9/CHANGES.txt?rev=1299022&r1=1299021&r2=1299022&view=diff
==============================================================================
--- pig/branches/branch-0.9/CHANGES.txt (original)
+++ pig/branches/branch-0.9/CHANGES.txt Fri Mar  9 20:20:13 2012
@@ -22,6 +22,8 @@ Release 0.9.3 - Unreleased
 
 BUG FIXES
 
+PIG-2576: Change in behavior for UDFContext.getUDFContext().getJobConf() in front-end (thw via daijy)
+
 PIG-2572: e2e harness deploy fails when using pig that does not bundle hadoop (thw via daijy)
 
 PIG-2568: PigOutputCommitter hide exception in commitJob (daijy)

Modified: pig/branches/branch-0.9/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/MapReduceLauncher.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.9/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/MapReduceLauncher.java?rev=1299022&r1=1299021&r2=1299022&view=diff
==============================================================================
--- pig/branches/branch-0.9/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/MapReduceLauncher.java (original)
+++ pig/branches/branch-0.9/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/MapReduceLauncher.java Fri Mar  9 20:20:13 2012
@@ -227,7 +227,7 @@ public class MapReduceLauncher extends L
             Thread jcThread = new Thread(jc) {
                 @Override
                 public void run() {
-                    UDFContext.setUdfContext(udfContext);
+                    UDFContext.setUdfContext(udfContext.clone()); //PIG-2576
                     super.run();
                 }
             };

Modified: pig/branches/branch-0.9/src/org/apache/pig/impl/util/UDFContext.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.9/src/org/apache/pig/impl/util/UDFContext.java?rev=1299022&r1=1299021&r2=1299022&view=diff
==============================================================================
--- pig/branches/branch-0.9/src/org/apache/pig/impl/util/UDFContext.java (original)
+++ pig/branches/branch-0.9/src/org/apache/pig/impl/util/UDFContext.java Fri Mar  9 20:20:13 2012
@@ -201,6 +201,25 @@ public class UDFContext {
     public boolean isUDFConfEmpty() {
         return udfConfs.isEmpty();
     }
+
+    /**
+     * Convenience method for UDF code to check where it runs (see PIG-2576)
+     * @return
+     */
+    public boolean isFrontend() {
+    	return (this.jconf == null || jconf.get("mapred.task.id") == null);
+    }
+    
+    /**
+     * Make a shallow copy of the context.
+     */
+    public UDFContext clone() {
+    	UDFContext other = new UDFContext();
+    	other.clientSysProps = this.clientSysProps;
+    	other.jconf = this.jconf;
+    	other.udfConfs = this.udfConfs;
+    	return other;
+    }
     
     /**
      * Class that acts as key for hashmap in UDFContext,