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 2013/05/31 19:18:25 UTC

svn commit: r1488320 - in /pig/trunk: CHANGES.txt src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/JobControlCompiler.java test/org/apache/pig/test/TestJobSubmission.java

Author: daijy
Date: Fri May 31 17:18:24 2013
New Revision: 1488320

URL: http://svn.apache.org/r1488320
Log:
PIG-2956: Invalid cache specification for some streaming statement

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/JobControlCompiler.java
    pig/trunk/test/org/apache/pig/test/TestJobSubmission.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1488320&r1=1488319&r2=1488320&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Fri May 31 17:18:24 2013
@@ -192,6 +192,8 @@ PIG-3013: BinInterSedes improve chararra
 
 BUG FIXES
 
+PIG-2956: Invalid cache specification for some streaming statement (daijy)
+
 PIG-3310: ImplicitSplitInserter does not generate new uids for nested schema fields, leading to miscomputations (cstenac via daijy)
 
 PIG-3334: Fix Windows piggybank unit test failures (daijy)

Modified: pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/JobControlCompiler.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/JobControlCompiler.java?rev=1488320&r1=1488319&r2=1488320&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/JobControlCompiler.java (original)
+++ pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/JobControlCompiler.java Fri May 31 17:18:24 2013
@@ -1446,8 +1446,21 @@ public class JobControlCompiler{
      * @throws ExecException
      */
     private static URI toURI(Path src) throws ExecException {
+        String pathInString = src.toString();
+        String fragment = null;
+        if (pathInString.contains("#")) {
+            fragment = pathInString.substring(pathInString.indexOf("#"));
+            pathInString = pathInString.substring(0, pathInString.indexOf("#"));
+        }
+        
+        // Encode the path
+        URI uri = new Path(pathInString).toUri();
+        String uriEncoded = uri.toString();
+        if (fragment!=null) {
+            uriEncoded = uriEncoded + fragment;
+        }
         try {
-            return new URI(src.toString());
+            return new URI(uriEncoded);
         } catch (URISyntaxException ue) {
             int errCode = 6003;
             String msg = "Invalid cache specification. " +

Modified: pig/trunk/test/org/apache/pig/test/TestJobSubmission.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestJobSubmission.java?rev=1488320&r1=1488319&r2=1488320&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestJobSubmission.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestJobSubmission.java Fri May 31 17:18:24 2013
@@ -21,10 +21,15 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
+import java.lang.reflect.Method;
+import java.net.URI;
 import java.util.Iterator;
 import java.util.Random;
 
+import junit.framework.Assert;
+
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.MiniHBaseCluster;
@@ -709,4 +714,20 @@ public class TestJobSubmission {
         //Third job is the order, which uses the estimated number of reducers
         Util.assertParallelValues(-1, -1, reducer, reducer, jobControl.getWaitingJobs().get(0).getJobConf());
     }
+    
+    @Test
+    public void testToUri() throws Exception {
+        Class<JobControlCompiler> jobControlCompilerClass = JobControlCompiler.class;
+        Method toURIMethod = jobControlCompilerClass.getDeclaredMethod("toURI", Path.class);
+        toURIMethod.setAccessible(true);
+        
+        Path p1 = new Path("/tmp/temp-1510081022/tmp-1308657145#pigsample_1889145873_1351808882314");
+        URI uri1 = (URI)toURIMethod.invoke(null, p1);
+        Assert.assertEquals(uri1.toString(), "/tmp/temp-1510081022/tmp-1308657145#pigsample_1889145873_1351808882314");
+        
+        Path p2 = new Path("C:/Program Files/GnuWin32/bin/head.exe#pigsample_1889145873_1351808882314");
+        URI uri2 = (URI)toURIMethod.invoke(null, p2);
+        Assert.assertTrue(uri2.toString().equals("C:/Program%20Files/GnuWin32/bin/head.exe#pigsample_1889145873_1351808882314")||
+                uri2.toString().equals("/C:/Program%20Files/GnuWin32/bin/head.exe#pigsample_1889145873_1351808882314"));
+    }
 }