You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by kh...@apache.org on 2014/11/19 01:31:20 UTC

svn commit: r1640458 - /hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/io/HiveInputFormat.java

Author: khorgath
Date: Wed Nov 19 00:31:20 2014
New Revision: 1640458

URL: http://svn.apache.org/r1640458
Log:
HIVE-8808 : HiveInputFormat caching cannot work with all input formats (Brock Noland via Sushanth Sowmyan)

Modified:
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/io/HiveInputFormat.java

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/io/HiveInputFormat.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/io/HiveInputFormat.java?rev=1640458&r1=1640457&r2=1640458&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/io/HiveInputFormat.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/io/HiveInputFormat.java Wed Nov 19 00:31:20 2014
@@ -197,18 +197,22 @@ public class HiveInputFormat<K extends W
 
   public static InputFormat<WritableComparable, Writable> getInputFormatFromCache(
     Class inputFormatClass, JobConf job) throws IOException {
-
-    if (!inputFormats.containsKey(inputFormatClass)) {
+    InputFormat<WritableComparable, Writable> instance = inputFormats.get(inputFormatClass);
+    if (instance == null) {
       try {
-        InputFormat<WritableComparable, Writable> newInstance = (InputFormat<WritableComparable, Writable>) ReflectionUtils
+        instance = (InputFormat<WritableComparable, Writable>) ReflectionUtils
             .newInstance(inputFormatClass, job);
-        inputFormats.put(inputFormatClass, newInstance);
+        // HBase input formats are not thread safe today. See HIVE-8808.
+        String inputFormatName = inputFormatClass.getName().toLowerCase();
+        if (!inputFormatName.contains("hbase")) {
+          inputFormats.put(inputFormatClass, instance);
+        }
       } catch (Exception e) {
         throw new IOException("Cannot create an instance of InputFormat class "
             + inputFormatClass.getName() + " as specified in mapredWork!", e);
       }
     }
-    return inputFormats.get(inputFormatClass);
+    return instance;
   }
 
   public RecordReader getRecordReader(InputSplit split, JobConf job,