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/05/13 00:06:51 UTC
svn commit: r1594103 -
/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/io/HiveInputFormat.java
Author: gunther
Date: Mon May 12 22:06:51 2014
New Revision: 1594103
URL: http://svn.apache.org/r1594103
Log:
HIVE-7011: HiveInputFormat's split generation isn't thread safe (Gunther Hagleitner, reviewed by Vikram Dixit K)
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=1594103&r1=1594102&r2=1594103&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 Mon May 12 22:06:51 2014
@@ -26,6 +26,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.Map.Entry;
import org.apache.commons.logging.Log;
@@ -184,14 +185,12 @@ public class HiveInputFormat<K extends W
/**
* A cache of InputFormat instances.
*/
- protected static Map<Class, InputFormat<WritableComparable, Writable>> inputFormats;
+ protected static Map<Class, InputFormat<WritableComparable, Writable>> inputFormats
+ = new ConcurrentHashMap<Class, InputFormat<WritableComparable, Writable>>();
public static InputFormat<WritableComparable, Writable> getInputFormatFromCache(
Class inputFormatClass, JobConf job) throws IOException {
- if (inputFormats == null) {
- inputFormats = new HashMap<Class, InputFormat<WritableComparable, Writable>>();
- }
if (!inputFormats.containsKey(inputFormatClass)) {
try {
InputFormat<WritableComparable, Writable> newInstance = (InputFormat<WritableComparable, Writable>) ReflectionUtils