You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by gu...@apache.org on 2014/10/28 21:38:48 UTC

svn commit: r1634971 - in /hive/trunk/common/src: java/org/apache/hadoop/hive/common/ValidTxnListImpl.java test/org/apache/hadoop/hive/common/TestValidTxnImpl.java

Author: gunther
Date: Tue Oct 28 20:38:48 2014
New Revision: 1634971

URL: http://svn.apache.org/r1634971
Log:
HIVE-8631: Compressed transaction list cannot be parsed in job.xml (Alan Gates via Gunther Hagleitner)

Modified:
    hive/trunk/common/src/java/org/apache/hadoop/hive/common/ValidTxnListImpl.java
    hive/trunk/common/src/test/org/apache/hadoop/hive/common/TestValidTxnImpl.java

Modified: hive/trunk/common/src/java/org/apache/hadoop/hive/common/ValidTxnListImpl.java
URL: http://svn.apache.org/viewvc/hive/trunk/common/src/java/org/apache/hadoop/hive/common/ValidTxnListImpl.java?rev=1634971&r1=1634970&r2=1634971&view=diff
==============================================================================
--- hive/trunk/common/src/java/org/apache/hadoop/hive/common/ValidTxnListImpl.java (original)
+++ hive/trunk/common/src/java/org/apache/hadoop/hive/common/ValidTxnListImpl.java Tue Oct 28 20:38:48 2014
@@ -18,23 +18,10 @@
 
 package org.apache.hadoop.hive.common;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 import java.util.Arrays;
-import java.util.zip.GZIPInputStream;
-import java.util.zip.GZIPOutputStream;
 
 public class ValidTxnListImpl implements ValidTxnList {
 
-  static final private Log LOG = LogFactory.getLog(ValidTxnListImpl.class.getName());
-  final static private int MAX_UNCOMPRESSED_LENGTH = 256;
-  final static private char COMPRESSION_MARKER = 'C';
-  final static private String STRING_ENCODING = "ISO-8859-1";
-
   private long[] exceptions;
   private long highWatermark;
 
@@ -108,25 +95,7 @@ public class ValidTxnListImpl implements
         buf.append(except);
       }
     }
-    if (buf.length() > MAX_UNCOMPRESSED_LENGTH) {
-      try {
-        ByteArrayOutputStream byteBuf = new ByteArrayOutputStream();
-        GZIPOutputStream gzip = new GZIPOutputStream(byteBuf);
-        gzip.write(buf.toString().getBytes());
-        gzip.close();
-        StringBuilder buf2 = new StringBuilder();
-        buf2.append(COMPRESSION_MARKER);
-        buf2.append(buf.length());
-        buf2.append(':');
-        buf2.append(byteBuf.toString(STRING_ENCODING));
-        return buf2.toString();
-      } catch (IOException e) {
-        LOG.error("Unable to compress transaction list, " + e.getMessage());
-        throw new RuntimeException(e);
-      }
-    } else {
-      return buf.toString();
-    }
+    return buf.toString();
   }
 
   @Override
@@ -135,36 +104,11 @@ public class ValidTxnListImpl implements
       highWatermark = Long.MAX_VALUE;
       exceptions = new long[0];
     } else {
-      String[] values;
-      if (src.charAt(0) == COMPRESSION_MARKER) {
-        try {
-          int colon = src.indexOf(':');
-          int len = Integer.valueOf(src.substring(1, colon));
-          ByteArrayInputStream byteBuf =
-              new ByteArrayInputStream(src.substring(colon + 1).getBytes(STRING_ENCODING));
-          GZIPInputStream gzip = new GZIPInputStream(byteBuf);
-          byte[] buf = new byte[len];
-          int bytesRead = 0;
-          int offset = 0;
-          int maxReadLen = len;
-          do {
-            bytesRead = gzip.read(buf, offset, maxReadLen);
-            offset += bytesRead;
-            maxReadLen -= bytesRead;
-          } while (maxReadLen > 0);
-          values = new String(buf).split(":");
-        } catch (IOException e) {
-          LOG.error("Unable to decode compressed transaction list, " + e.getMessage());
-          throw new RuntimeException(e);
-        }
-
-      } else {
-        values = src.split(":");
-      }
+      String[] values = src.split(":");
       highWatermark = Long.parseLong(values[0]);
       exceptions = new long[values.length - 1];
-      for (int i = 1; i < values.length; ++i) {
-        exceptions[i - 1] = Long.parseLong(values[i]);
+      for(int i = 1; i < values.length; ++i) {
+        exceptions[i-1] = Long.parseLong(values[i]);
       }
     }
   }

Modified: hive/trunk/common/src/test/org/apache/hadoop/hive/common/TestValidTxnImpl.java
URL: http://svn.apache.org/viewvc/hive/trunk/common/src/test/org/apache/hadoop/hive/common/TestValidTxnImpl.java?rev=1634971&r1=1634970&r2=1634971&view=diff
==============================================================================
--- hive/trunk/common/src/test/org/apache/hadoop/hive/common/TestValidTxnImpl.java (original)
+++ hive/trunk/common/src/test/org/apache/hadoop/hive/common/TestValidTxnImpl.java Tue Oct 28 20:38:48 2014
@@ -64,7 +64,6 @@ public class TestValidTxnImpl {
     for (int i = 0; i < 1000; i++) exceptions[i] = i + 100;
     ValidTxnList txnList = new ValidTxnListImpl(exceptions, 2000);
     String str = txnList.writeToString();
-    Assert.assertEquals('C', str.charAt(0));
     ValidTxnList newList = new ValidTxnListImpl();
     newList.readFromString(str);
     for (int i = 0; i < 100; i++) Assert.assertTrue(newList.isTxnCommitted(i));
@@ -79,7 +78,6 @@ public class TestValidTxnImpl {
     for (int i = 0; i < 1000; i++) exceptions[i] = i + 100;
     ValidTxnList txnList = new ValidTxnListImpl(exceptions, 2000);
     String str = txnList.writeToString();
-    Assert.assertEquals('C', str.charAt(0));
     Configuration conf = new Configuration();
     conf.set(ValidTxnList.VALID_TXNS_KEY, str);
     File tmpFile = File.createTempFile("TestValidTxnImpl", "readWriteConfig");