Index: ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java (revision 1196618) +++ ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java (working copy) @@ -22,11 +22,12 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; @@ -223,7 +224,7 @@ /** * The mapping from expression function names to expression classes. */ - static Map mFunctions = new LinkedHashMap(); + private static ConcurrentMap mFunctions = new ConcurrentHashMap(); static { registerUDF("concat", UDFConcat.class, false); registerUDF("substr", UDFSubstr.class, false); @@ -470,7 +471,7 @@ if (UDF.class.isAssignableFrom(UDFClass)) { FunctionInfo fI = new FunctionInfo(isNative, displayName, new GenericUDFBridge(displayName, isOperator, UDFClass)); - mFunctions.put(functionName.toLowerCase(), fI); + mFunctions.putIfAbsent(functionName.toLowerCase(), fI); } else { throw new RuntimeException("Registering UDF Class " + UDFClass + " which does not extend " + UDF.class); @@ -492,7 +493,7 @@ if (GenericUDF.class.isAssignableFrom(genericUDFClass)) { FunctionInfo fI = new FunctionInfo(isNative, functionName, (GenericUDF) ReflectionUtils.newInstance(genericUDFClass, null)); - mFunctions.put(functionName.toLowerCase(), fI); + mFunctions.putIfAbsent(functionName.toLowerCase(), fI); } else { throw new RuntimeException("Registering GenericUDF Class " + genericUDFClass + " which does not extend " + GenericUDF.class); @@ -514,7 +515,7 @@ if (GenericUDTF.class.isAssignableFrom(genericUDTFClass)) { FunctionInfo fI = new FunctionInfo(isNative, functionName, (GenericUDTF) ReflectionUtils.newInstance(genericUDTFClass, null)); - mFunctions.put(functionName.toLowerCase(), fI); + mFunctions.putIfAbsent(functionName.toLowerCase(), fI); } else { throw new RuntimeException("Registering GenericUDTF Class " + genericUDTFClass + " which does not extend " + GenericUDTF.class); @@ -759,7 +760,7 @@ public static void registerGenericUDAF(boolean isNative, String functionName, GenericUDAFResolver genericUDAFResolver) { - mFunctions.put(functionName.toLowerCase(), new FunctionInfo(isNative, + mFunctions.putIfAbsent(functionName.toLowerCase(), new FunctionInfo(isNative, functionName.toLowerCase(), genericUDAFResolver)); } @@ -774,7 +775,7 @@ public static void registerUDAF(boolean isNative, String functionName, Class udafClass) { - mFunctions.put(functionName.toLowerCase(), new FunctionInfo(isNative, + mFunctions.putIfAbsent(functionName.toLowerCase(), new FunctionInfo(isNative, functionName.toLowerCase(), new GenericUDAFBridge( (UDAF) ReflectionUtils.newInstance(udafClass, null)))); }