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 2014/10/28 21:47:58 UTC

svn commit: r1634979 - in /pig/trunk: CHANGES.txt src/org/apache/pig/impl/util/JarManager.java

Author: daijy
Date: Tue Oct 28 20:47:57 2014
New Revision: 1634979

URL: http://svn.apache.org/r1634979
Log:
PIG-4252: Tez container reuse fail when using script udf

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/impl/util/JarManager.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1634979&r1=1634978&r2=1634979&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Tue Oct 28 20:47:57 2014
@@ -105,6 +105,8 @@ OPTIMIZATIONS
  
 BUG FIXES
 
+PIG-4252: Tez container reuse fail when using script udf (daijy)
+
 PIG-4241: Auto local mode mistakenly converts large jobs to local mode when using with Hive tables (cheolsoo)
 
 PIG-4184: UDF backward compatibility issue after POStatus.STATUS_NULL refactory (daijy)

Modified: pig/trunk/src/org/apache/pig/impl/util/JarManager.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/impl/util/JarManager.java?rev=1634979&r1=1634978&r2=1634979&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/impl/util/JarManager.java (original)
+++ pig/trunk/src/org/apache/pig/impl/util/JarManager.java Tue Oct 28 20:47:57 2014
@@ -105,15 +105,16 @@ public class JarManager {
         for (String path: pigContext.scriptFiles) {
             log.debug("Adding entry " + path + " to job jar" );
             InputStream stream = null;
-            if (new File(path).exists()) {
-                stream = new FileInputStream(new File(path));
+            File inputFile = new File(path);
+            if (inputFile.exists()) {
+                stream = new FileInputStream(inputFile);
             } else {
                 stream = PigContext.getClassLoader().getResourceAsStream(path);
             }
             if (stream==null) {
                 throw new IOException("Cannot find " + path);
             }
-            addStream(jarOutputStream, path, stream, contents);
+            addStream(jarOutputStream, path, stream, contents, inputFile.lastModified());
         }
         for (Map.Entry<String, File> entry : pigContext.getScriptFiles().entrySet()) {
             log.debug("Adding entry " + entry.getKey() + " to job jar" );
@@ -126,7 +127,7 @@ public class JarManager {
             if (stream==null) {
                 throw new IOException("Cannot find " + entry.getValue().getPath());
             }
-            addStream(jarOutputStream, entry.getKey(), stream, contents);
+            addStream(jarOutputStream, entry.getKey(), stream, contents, entry.getValue().lastModified());
         }
         if (!contents.isEmpty()) {
             jarOutputStream.close();
@@ -169,15 +170,20 @@ public class JarManager {
      * @param contents
      *            the current contents of the Jar file. (We use this to avoid adding two streams
      *            with the same name.
+     * @param timestamp
+     *            timestamp of the entry
      * @throws IOException
      */
-    private static void addStream(JarOutputStream os, String name, InputStream is, Map<String, String> contents)
+    private static void addStream(JarOutputStream os, String name, InputStream is, Map<String, String> contents,
+            long timestamp)
             throws IOException {
         if (contents.get(name) != null) {
             return;
         }
         contents.put(name, "");
-        os.putNextEntry(new JarEntry(name));
+        JarEntry entry = new JarEntry(name);
+        entry.setTime(timestamp);
+        os.putNextEntry(entry);
         byte buffer[] = new byte[4096];
         int rc;
         while ((rc = is.read(buffer)) > 0) {