diff --git a/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/LazyObjectInspectorFactory.java b/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/LazyObjectInspectorFactory.java index 8fee0fc..ed670b0 100644 --- a/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/LazyObjectInspectorFactory.java +++ b/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/LazyObjectInspectorFactory.java @@ -19,8 +19,8 @@ package org.apache.hadoop.hive.serde2.lazy.objectinspector; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; +import java.util.concurrent.ConcurrentHashMap; import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; import org.apache.hadoop.io.Text; @@ -28,18 +28,18 @@ /** * ObjectInspectorFactory is the primary way to create new ObjectInspector * instances. - * + * * SerDe classes should call the static functions in this library to create an * ObjectInspector to return to the caller of SerDe2.getObjectInspector(). - * + * * The reason of having caches here is that ObjectInspectors do not have an * internal state - so ObjectInspectors with the same construction parameters * should result in exactly the same ObjectInspector. */ public final class LazyObjectInspectorFactory { - static HashMap, LazySimpleStructObjectInspector> cachedLazySimpleStructObjectInspector = - new HashMap, LazySimpleStructObjectInspector>(); + static ConcurrentHashMap, LazySimpleStructObjectInspector> cachedLazySimpleStructObjectInspector = + new ConcurrentHashMap, LazySimpleStructObjectInspector>(); public static LazySimpleStructObjectInspector getLazySimpleStructObjectInspector( List structFieldNames, @@ -78,7 +78,8 @@ public static LazySimpleStructObjectInspector getLazySimpleStructObjectInspector return result; } - static HashMap, LazyListObjectInspector> cachedLazySimpleListObjectInspector = new HashMap, LazyListObjectInspector>(); + static ConcurrentHashMap, LazyListObjectInspector> cachedLazySimpleListObjectInspector = + new ConcurrentHashMap, LazyListObjectInspector>(); public static LazyListObjectInspector getLazySimpleListObjectInspector( ObjectInspector listElementObjectInspector, byte separator, @@ -99,7 +100,8 @@ public static LazyListObjectInspector getLazySimpleListObjectInspector( return result; } - static HashMap, LazyMapObjectInspector> cachedLazySimpleMapObjectInspector = new HashMap, LazyMapObjectInspector>(); + static ConcurrentHashMap, LazyMapObjectInspector> cachedLazySimpleMapObjectInspector = + new ConcurrentHashMap, LazyMapObjectInspector>(); public static LazyMapObjectInspector getLazySimpleMapObjectInspector( ObjectInspector mapKeyObjectInspector, @@ -125,9 +127,9 @@ public static LazyMapObjectInspector getLazySimpleMapObjectInspector( return result; } - static HashMap, LazyUnionObjectInspector> + static ConcurrentHashMap, LazyUnionObjectInspector> cachedLazyUnionObjectInspector = - new HashMap, LazyUnionObjectInspector>(); + new ConcurrentHashMap, LazyUnionObjectInspector>(); public static LazyUnionObjectInspector getLazyUnionObjectInspector( List ois, byte separator, Text nullSequence, diff --git a/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/objectinspector/LazyBinaryObjectInspectorFactory.java b/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/objectinspector/LazyBinaryObjectInspectorFactory.java index f3dea31..b3ec24d 100644 --- a/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/objectinspector/LazyBinaryObjectInspectorFactory.java +++ b/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/objectinspector/LazyBinaryObjectInspectorFactory.java @@ -18,18 +18,18 @@ package org.apache.hadoop.hive.serde2.lazybinary.objectinspector; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; +import java.util.concurrent.ConcurrentHashMap; import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; /** * ObjectInspectorFactory is the primary way to create new ObjectInspector * instances. - * + * * SerDe classes should call the static functions in this library to create an * ObjectInspector to return to the caller of SerDe2.getObjectInspector(). - * + * * The reason of having caches here is that ObjectInspectors do not have an * internal state - so ObjectInspectors with the same construction parameters * should result in exactly the same ObjectInspector. @@ -37,7 +37,8 @@ public final class LazyBinaryObjectInspectorFactory { - static HashMap, LazyBinaryStructObjectInspector> cachedLazyBinaryStructObjectInspector = new HashMap, LazyBinaryStructObjectInspector>(); + static ConcurrentHashMap, LazyBinaryStructObjectInspector> cachedLazyBinaryStructObjectInspector = + new ConcurrentHashMap, LazyBinaryStructObjectInspector>(); public static LazyBinaryStructObjectInspector getLazyBinaryStructObjectInspector( List structFieldNames, @@ -65,7 +66,8 @@ public static LazyBinaryStructObjectInspector getLazyBinaryStructObjectInspector return result; } - static HashMap, LazyBinaryListObjectInspector> cachedLazyBinaryListObjectInspector = new HashMap, LazyBinaryListObjectInspector>(); + static ConcurrentHashMap, LazyBinaryListObjectInspector> cachedLazyBinaryListObjectInspector = + new ConcurrentHashMap, LazyBinaryListObjectInspector>(); public static LazyBinaryListObjectInspector getLazyBinaryListObjectInspector( ObjectInspector listElementObjectInspector) { @@ -80,7 +82,8 @@ public static LazyBinaryListObjectInspector getLazyBinaryListObjectInspector( return result; } - static HashMap, LazyBinaryMapObjectInspector> cachedLazyBinaryMapObjectInspector = new HashMap, LazyBinaryMapObjectInspector>(); + static ConcurrentHashMap, LazyBinaryMapObjectInspector> cachedLazyBinaryMapObjectInspector = + new ConcurrentHashMap, LazyBinaryMapObjectInspector>(); public static LazyBinaryMapObjectInspector getLazyBinaryMapObjectInspector( ObjectInspector mapKeyObjectInspector, diff --git a/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorFactory.java b/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorFactory.java index 0e39073..9a226b3 100644 --- a/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorFactory.java +++ b/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorFactory.java @@ -24,9 +24,9 @@ import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; @@ -34,10 +34,10 @@ /** * ObjectInspectorFactory is the primary way to create new ObjectInspector * instances. - * + * * SerDe classes should call the static functions in this library to create an * ObjectInspector to return to the caller of SerDe2.getObjectInspector(). - * + * * The reason of having caches here is that ObjectInspector is because * ObjectInspectors do not have an internal state - so ObjectInspectors with the * same construction parameters should result in exactly the same @@ -60,7 +60,7 @@ JAVA, THRIFT, PROTOCOL_BUFFERS }; - private static HashMap objectInspectorCache = new HashMap(); + private static ConcurrentHashMap objectInspectorCache = new ConcurrentHashMap(); public static ObjectInspector getReflectionObjectInspector(Type t, ObjectInspectorOptions options) { @@ -197,7 +197,8 @@ private static ObjectInspector getReflectionObjectInspectorNoCache(Type t, return oi; } - static HashMap cachedStandardListObjectInspector = new HashMap(); + static ConcurrentHashMap cachedStandardListObjectInspector = + new ConcurrentHashMap(); public static StandardListObjectInspector getStandardListObjectInspector( ObjectInspector listElementObjectInspector) { @@ -216,7 +217,8 @@ public static StandardConstantListObjectInspector getStandardConstantListObjectI } - static HashMap, StandardMapObjectInspector> cachedStandardMapObjectInspector = new HashMap, StandardMapObjectInspector>(); + static ConcurrentHashMap, StandardMapObjectInspector> cachedStandardMapObjectInspector = + new ConcurrentHashMap, StandardMapObjectInspector>(); public static StandardMapObjectInspector getStandardMapObjectInspector( ObjectInspector mapKeyObjectInspector, @@ -242,9 +244,9 @@ public static StandardConstantMapObjectInspector getStandardConstantMapObjectIns mapValueObjectInspector, constantValue); } - static HashMap, StandardUnionObjectInspector> + static ConcurrentHashMap, StandardUnionObjectInspector> cachedStandardUnionObjectInspector = - new HashMap, StandardUnionObjectInspector>(); + new ConcurrentHashMap, StandardUnionObjectInspector>(); public static StandardUnionObjectInspector getStandardUnionObjectInspector( List unionObjectInspectors) { @@ -257,7 +259,8 @@ public static StandardUnionObjectInspector getStandardUnionObjectInspector( return result; } - static HashMap>, StandardStructObjectInspector> cachedStandardStructObjectInspector = new HashMap>, StandardStructObjectInspector>(); + static ConcurrentHashMap>, StandardStructObjectInspector> cachedStandardStructObjectInspector = + new ConcurrentHashMap>, StandardStructObjectInspector>(); public static StandardStructObjectInspector getStandardStructObjectInspector( List structFieldNames, @@ -283,7 +286,8 @@ public static StandardStructObjectInspector getStandardStructObjectInspector( return result; } - static HashMap, UnionStructObjectInspector> cachedUnionStructObjectInspector = new HashMap, UnionStructObjectInspector>(); + static ConcurrentHashMap, UnionStructObjectInspector> cachedUnionStructObjectInspector = + new ConcurrentHashMap, UnionStructObjectInspector>(); public static UnionStructObjectInspector getUnionStructObjectInspector( List structObjectInspectors) { @@ -296,7 +300,8 @@ public static UnionStructObjectInspector getUnionStructObjectInspector( return result; } - static HashMap, ColumnarStructObjectInspector> cachedColumnarStructObjectInspector = new HashMap, ColumnarStructObjectInspector>(); + static ConcurrentHashMap, ColumnarStructObjectInspector> cachedColumnarStructObjectInspector = + new ConcurrentHashMap, ColumnarStructObjectInspector>(); public static ColumnarStructObjectInspector getColumnarStructObjectInspector( List structFieldNames,