hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1529771 [2/3] - in /hive/trunk: contrib/src/java/org/apache/hadoop/hive/contrib/util/typedbytes/ ql/src/java/org/apache/hadoop/hive/ql/exec/ ql/src/java/org/apache/hadoop/hive/ql/io/orc/ ql/src/java/org/apache/hadoop/hive/ql/parse/ ql/src/...
Date Mon, 07 Oct 2013 06:39:53 GMT
Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyIntObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyIntObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyIntObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyIntObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -19,7 +19,7 @@ package org.apache.hadoop.hive.serde2.la
 
 import org.apache.hadoop.hive.serde2.lazy.LazyInteger;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.IntObjectInspector;
-import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 import org.apache.hadoop.io.IntWritable;
 
 /**
@@ -30,7 +30,7 @@ public class LazyIntObjectInspector exte
     IntObjectInspector {
 
   LazyIntObjectInspector() {
-    super(PrimitiveObjectInspectorUtils.intTypeEntry);
+    super(TypeInfoFactory.intTypeInfo);
   }
 
   @Override

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyLongObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyLongObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyLongObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyLongObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -19,7 +19,7 @@ package org.apache.hadoop.hive.serde2.la
 
 import org.apache.hadoop.hive.serde2.lazy.LazyLong;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.LongObjectInspector;
-import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 import org.apache.hadoop.io.LongWritable;
 
 /**
@@ -30,7 +30,7 @@ public class LazyLongObjectInspector ext
     LongObjectInspector {
 
   LazyLongObjectInspector() {
-    super(PrimitiveObjectInspectorUtils.longTypeEntry);
+    super(TypeInfoFactory.longTypeInfo);
   }
 
   @Override

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyPrimitiveObjectInspectorFactory.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyPrimitiveObjectInspectorFactory.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyPrimitiveObjectInspectorFactory.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyPrimitiveObjectInspectorFactory.java Mon Oct  7 06:39:52 2013
@@ -20,14 +20,13 @@ package org.apache.hadoop.hive.serde2.la
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Map;
 
-import org.apache.hadoop.hive.serde2.SerDeException;
-import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
+import org.apache.hadoop.hive.serde.serdeConstants;
 import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory;
-import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
-import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.PrimitiveTypeEntry;
-import org.apache.hadoop.hive.serde2.typeinfo.BaseTypeParams;
-import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeSpec;
+import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
+import org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeInfo;
 
 /**
  * LazyPrimitiveObjectInspectorFactory is the primary way to create new
@@ -67,115 +66,88 @@ public final class LazyPrimitiveObjectIn
       new LazyBinaryObjectInspector();
   public static final LazyHiveDecimalObjectInspector LAZY_BIG_DECIMAL_OBJECT_INSPECTOR =
       new LazyHiveDecimalObjectInspector();
-  public static final LazyHiveVarcharObjectInspector LAZY_VARCHAR_OBJECT_INSPECTOR =
-      new LazyHiveVarcharObjectInspector(PrimitiveObjectInspectorUtils.varcharTypeEntry);
 
-  static HashMap<ArrayList<Object>, LazyStringObjectInspector> cachedLazyStringObjectInspector =
-      new HashMap<ArrayList<Object>, LazyStringObjectInspector>();
-
-  public static LazyStringObjectInspector getLazyStringObjectInspector(
-      boolean escaped, byte escapeChar) {
-    ArrayList<Object> signature = new ArrayList<Object>();
-    signature.add(Boolean.valueOf(escaped));
-    signature.add(Byte.valueOf(escapeChar));
-    LazyStringObjectInspector result = cachedLazyStringObjectInspector
-        .get(signature);
-    if (result == null) {
-      result = new LazyStringObjectInspector(escaped, escapeChar);
-      cachedLazyStringObjectInspector.put(signature, result);
-    }
-    return result;
+  private LazyPrimitiveObjectInspectorFactory() {
+    // prevent instantiation
   }
 
-  static PrimitiveObjectInspectorUtils.ParameterizedObjectInspectorMap
-    cachedParameterizedLazyObjectInspectors =
-      new PrimitiveObjectInspectorUtils.ParameterizedObjectInspectorMap();
-
-  public static PrimitiveObjectInspector getParameterizedObjectInspector(
-      PrimitiveTypeSpec typeSpec) {
-    PrimitiveCategory primitiveCategory = typeSpec.getPrimitiveCategory();
-    BaseTypeParams typeParams = typeSpec.getTypeParams();
-    PrimitiveObjectInspector poi =
-        cachedParameterizedLazyObjectInspectors.getObjectInspector(typeSpec);
-    if (poi == null) {
-      // Object inspector hasn't been cached for this type/params yet, create now
-      switch (primitiveCategory) {
-        case VARCHAR:
-          PrimitiveTypeEntry typeEntry = PrimitiveObjectInspectorUtils.getTypeEntryFromTypeSpecs(
-              primitiveCategory,
-              typeParams);
-          poi = new LazyHiveVarcharObjectInspector(typeEntry);
-          poi.setTypeParams(typeParams);
-          cachedParameterizedLazyObjectInspectors.setObjectInspector(poi);
-          break;
-
-        default:
-          throw new RuntimeException(
-              "Primitve type " + primitiveCategory + " should not take parameters");
-      }
-    }
+  private static HashMap<ArrayList<Object>, LazyStringObjectInspector> cachedLazyStringObjectInspector =
+      new HashMap<ArrayList<Object>, LazyStringObjectInspector>();
 
-    return poi;
+  private static Map<PrimitiveTypeInfo, AbstractPrimitiveLazyObjectInspector<?>>
+     cachedPrimitiveLazyObjectInspectors =
+    new HashMap<PrimitiveTypeInfo, AbstractPrimitiveLazyObjectInspector<?>>();
+  static {
+    cachedPrimitiveLazyObjectInspectors.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.BOOLEAN_TYPE_NAME),
+        LAZY_BOOLEAN_OBJECT_INSPECTOR);
+    cachedPrimitiveLazyObjectInspectors.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.TINYINT_TYPE_NAME),
+        LAZY_BYTE_OBJECT_INSPECTOR);
+    cachedPrimitiveLazyObjectInspectors.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.SMALLINT_TYPE_NAME),
+        LAZY_SHORT_OBJECT_INSPECTOR);
+    cachedPrimitiveLazyObjectInspectors.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.INT_TYPE_NAME),
+        LAZY_INT_OBJECT_INSPECTOR);
+    cachedPrimitiveLazyObjectInspectors.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.FLOAT_TYPE_NAME),
+        LAZY_FLOAT_OBJECT_INSPECTOR);
+    cachedPrimitiveLazyObjectInspectors.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.DOUBLE_TYPE_NAME),
+        LAZY_DOUBLE_OBJECT_INSPECTOR);
+    cachedPrimitiveLazyObjectInspectors.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.BIGINT_TYPE_NAME),
+        LAZY_LONG_OBJECT_INSPECTOR);
+    cachedPrimitiveLazyObjectInspectors.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.VOID_TYPE_NAME),
+        LAZY_VOID_OBJECT_INSPECTOR);
+    cachedPrimitiveLazyObjectInspectors.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.DATE_TYPE_NAME),
+        LAZY_DATE_OBJECT_INSPECTOR);
+    cachedPrimitiveLazyObjectInspectors.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.TIMESTAMP_TYPE_NAME),
+        LAZY_TIMESTAMP_OBJECT_INSPECTOR);
+    cachedPrimitiveLazyObjectInspectors.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.DECIMAL_TYPE_NAME),
+        LAZY_BIG_DECIMAL_OBJECT_INSPECTOR);
+    cachedPrimitiveLazyObjectInspectors.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.BINARY_TYPE_NAME),
+        LAZY_BINARY_OBJECT_INSPECTOR);
   }
+
   public static AbstractPrimitiveLazyObjectInspector<?> getLazyObjectInspector(
-      PrimitiveCategory primitiveCategory, boolean escaped, byte escapeChar) {
-    switch (primitiveCategory) {
-    case BOOLEAN:
-      return LAZY_BOOLEAN_OBJECT_INSPECTOR;
-    case BYTE:
-      return LAZY_BYTE_OBJECT_INSPECTOR;
-    case SHORT:
-      return LAZY_SHORT_OBJECT_INSPECTOR;
-    case INT:
-      return LAZY_INT_OBJECT_INSPECTOR;
-    case LONG:
-      return LAZY_LONG_OBJECT_INSPECTOR;
-    case FLOAT:
-      return LAZY_FLOAT_OBJECT_INSPECTOR;
-    case DOUBLE:
-      return LAZY_DOUBLE_OBJECT_INSPECTOR;
+      PrimitiveTypeInfo typeInfo, boolean escaped, byte escapeChar) {
+    PrimitiveCategory primitiveCategory = typeInfo.getPrimitiveCategory();
+
+    switch(primitiveCategory) {
     case STRING:
       return getLazyStringObjectInspector(escaped, escapeChar);
-    case VARCHAR:
-      return LAZY_VARCHAR_OBJECT_INSPECTOR;
-    case BINARY:
-      return LAZY_BINARY_OBJECT_INSPECTOR;
-    case VOID:
-      return LAZY_VOID_OBJECT_INSPECTOR;
-    case DATE:
-      return LAZY_DATE_OBJECT_INSPECTOR;
-    case TIMESTAMP:
-      return LAZY_TIMESTAMP_OBJECT_INSPECTOR;
-    case DECIMAL:
-      return LAZY_BIG_DECIMAL_OBJECT_INSPECTOR;
     default:
-      throw new RuntimeException("Internal error: Cannot find ObjectInspector "
-          + " for " + primitiveCategory);
+     return getLazyObjectInspector(typeInfo);
     }
   }
 
   public static AbstractPrimitiveLazyObjectInspector<?> getLazyObjectInspector(
-      PrimitiveTypeSpec typeSpec, boolean escaped, byte escapeChar) {
-    PrimitiveCategory primitiveCategory = typeSpec.getPrimitiveCategory();
-    BaseTypeParams typeParams = typeSpec.getTypeParams();
-
-    if (typeParams == null) {
-      return getLazyObjectInspector(primitiveCategory, escaped, escapeChar);
-    } else {
-      switch(primitiveCategory) {
-        case VARCHAR:
-          LazyHiveVarcharObjectInspector oi = (LazyHiveVarcharObjectInspector)
-            getParameterizedObjectInspector(typeSpec);
-          return oi;
-
-        default:
-          throw new RuntimeException("Type " + primitiveCategory + " does not take parameters");
-      }
+      PrimitiveTypeInfo typeInfo) {
+    AbstractPrimitiveLazyObjectInspector<?> poi = cachedPrimitiveLazyObjectInspectors.get(typeInfo);
+    if (poi != null) {
+      return poi;
+    }
+
+    // Object inspector hasn't been cached for this type/params yet, create now
+    switch (typeInfo.getPrimitiveCategory()) {
+    case VARCHAR:
+      poi = new LazyHiveVarcharObjectInspector((VarcharTypeInfo)typeInfo);
+      break;
+    default:
+      throw new RuntimeException(
+          "Primitve type " + typeInfo.getPrimitiveCategory() + " should not take parameters");
     }
+
+    cachedPrimitiveLazyObjectInspectors.put(typeInfo, poi);
+    return poi;
   }
 
-  private LazyPrimitiveObjectInspectorFactory() {
-    // prevent instantiation
+  public static LazyStringObjectInspector getLazyStringObjectInspector(boolean escaped, byte escapeChar) {
+    ArrayList<Object> signature = new ArrayList<Object>();
+    signature.add(Boolean.valueOf(escaped));
+    signature.add(Byte.valueOf(escapeChar));
+    LazyStringObjectInspector result = cachedLazyStringObjectInspector
+        .get(signature);
+    if (result == null) {
+      result = new LazyStringObjectInspector(escaped, escapeChar);
+      cachedLazyStringObjectInspector.put(signature, result);
+    }
+    return result;
   }
 
 }

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyShortObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyShortObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyShortObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyShortObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -19,8 +19,8 @@ package org.apache.hadoop.hive.serde2.la
 
 import org.apache.hadoop.hive.serde2.io.ShortWritable;
 import org.apache.hadoop.hive.serde2.lazy.LazyShort;
-import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.ShortObjectInspector;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 
 /**
  * A WritableShortObjectInspector inspects a ShortWritable Object.
@@ -30,7 +30,7 @@ public class LazyShortObjectInspector ex
     ShortObjectInspector {
 
   LazyShortObjectInspector() {
-    super(PrimitiveObjectInspectorUtils.shortTypeEntry);
+    super(TypeInfoFactory.shortTypeInfo);
   }
 
   @Override

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyStringObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyStringObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyStringObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyStringObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -18,8 +18,8 @@
 package org.apache.hadoop.hive.serde2.lazy.objectinspector.primitive;
 
 import org.apache.hadoop.hive.serde2.lazy.LazyString;
-import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.StringObjectInspector;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 import org.apache.hadoop.io.Text;
 
 /**
@@ -36,7 +36,7 @@ public class LazyStringObjectInspector e
   }
 
   LazyStringObjectInspector(boolean escaped, byte escapeChar) {
-    super(PrimitiveObjectInspectorUtils.stringTypeEntry);
+    super(TypeInfoFactory.stringTypeInfo);
     this.escaped = escaped;
     this.escapeChar = escapeChar;
   }

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyTimestampObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyTimestampObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyTimestampObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyTimestampObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -21,15 +21,15 @@ import java.sql.Timestamp;
 
 import org.apache.hadoop.hive.serde2.io.TimestampWritable;
 import org.apache.hadoop.hive.serde2.lazy.LazyTimestamp;
-import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.TimestampObjectInspector;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 
 public class LazyTimestampObjectInspector
     extends AbstractPrimitiveLazyObjectInspector<TimestampWritable>
     implements TimestampObjectInspector {
 
   protected LazyTimestampObjectInspector() {
-    super(PrimitiveObjectInspectorUtils.timestampTypeEntry);
+    super(TypeInfoFactory.timestampTypeInfo);
   }
 
   public Object copyObject(Object o) {

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyVoidObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyVoidObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyVoidObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyVoidObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -17,8 +17,8 @@
  */
 package org.apache.hadoop.hive.serde2.lazy.objectinspector.primitive;
 
-import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.VoidObjectInspector;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 import org.apache.hadoop.io.NullWritable;
 
 /**
@@ -29,7 +29,7 @@ public class LazyVoidObjectInspector ext
     VoidObjectInspector {
 
   LazyVoidObjectInspector() {
-    super(PrimitiveObjectInspectorUtils.voidTypeEntry);
+    super(TypeInfoFactory.voidTypeInfo);
   }
 
   @Override

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryHiveVarchar.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryHiveVarchar.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryHiveVarchar.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryHiveVarchar.java Mon Oct  7 06:39:52 2013
@@ -20,7 +20,7 @@ package org.apache.hadoop.hive.serde2.la
 import org.apache.hadoop.hive.serde2.io.HiveVarcharWritable;
 import org.apache.hadoop.hive.serde2.lazy.ByteArrayRef;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableHiveVarcharObjectInspector;
-import org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeParams;
+import org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeInfo;
 import org.apache.hadoop.io.Text;
 
 public class LazyBinaryHiveVarchar extends
@@ -30,12 +30,7 @@ public class LazyBinaryHiveVarchar exten
 
   LazyBinaryHiveVarchar(WritableHiveVarcharObjectInspector oi) {
     super(oi);
-    // Check for params
-    VarcharTypeParams typeParams = (VarcharTypeParams)oi.getTypeParams();
-    if (typeParams == null) {
-      throw new RuntimeException("varchar type used without type params");
-    }
-    maxLength = typeParams.length;
+    maxLength = ((VarcharTypeInfo)oi.getTypeInfo()).getLength();
     data = new HiveVarcharWritable();
   }
 

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorConverters.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorConverters.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorConverters.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorConverters.java Mon Oct  7 06:39:52 2013
@@ -39,6 +39,7 @@ import org.apache.hadoop.hive.serde2.obj
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableTimestampObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.VoidObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableStringObjectInspector;
+import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
 
 /**
  * ObjectInspectorConverters.
@@ -222,7 +223,8 @@ public final class ObjectInspectorConver
     case PRIMITIVE:
       // Create a writable object inspector for primitive type and return it.
       PrimitiveObjectInspector primOutputOI = (PrimitiveObjectInspector) outputOI;
-      return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(primOutputOI);
+      return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
+          (PrimitiveTypeInfo)primOutputOI.getTypeInfo());
     case STRUCT:
       StructObjectInspector structOutputOI = (StructObjectInspector) outputOI;
       // create a standard settable struct object inspector.

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorUtils.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorUtils.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorUtils.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorUtils.java Mon Oct  7 06:39:52 2013
@@ -65,6 +65,7 @@ import org.apache.hadoop.hive.serde2.obj
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.StringObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.TimestampObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableStringObjectInspector;
+import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils;
 import org.apache.hadoop.hive.shims.ShimLoader;
 import org.apache.hadoop.io.BytesWritable;
@@ -102,7 +103,8 @@ public final class ObjectInspectorUtils 
     if (oi.getCategory() == Category.PRIMITIVE) {
       PrimitiveObjectInspector poi = (PrimitiveObjectInspector) oi;
       if (!(poi instanceof AbstractPrimitiveWritableObjectInspector)) {
-        return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(poi);
+        return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
+            (PrimitiveTypeInfo)poi.getTypeInfo());
       }
     }
     return oi;
@@ -126,23 +128,24 @@ public final class ObjectInspectorUtils 
       switch (objectInspectorOption) {
       case DEFAULT: {
         if (poi.preferWritable()) {
-          result = PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(poi);
+          result = PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
+              poi.getTypeInfo());
         } else {
-          result = PrimitiveObjectInspectorFactory
-              .getPrimitiveJavaObjectInspector(poi);
+          result = PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector(
+              poi.getTypeInfo());
         }
         break;
       }
       case JAVA: {
-        result = PrimitiveObjectInspectorFactory
-            .getPrimitiveJavaObjectInspector(poi);
+        result = PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector(
+            poi.getTypeInfo());
         break;
       }
-      case WRITABLE: {
-        result = PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(poi);
+      case WRITABLE:
+        result = PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
+            poi.getTypeInfo());
         break;
       }
-      }
       break;
     }
     case LIST: {
@@ -971,7 +974,7 @@ public final class ObjectInspectorUtils 
       case PRIMITIVE:
         PrimitiveObjectInspector poi = (PrimitiveObjectInspector) oi;
         return PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
-            poi, writableValue);
+            poi.getTypeInfo(), writableValue);
       case LIST:
         ListObjectInspector loi = (ListObjectInspector) oi;
         return ObjectInspectorFactory.getStandardConstantListObjectInspector(

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/PrimitiveObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/PrimitiveObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/PrimitiveObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/PrimitiveObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -17,14 +17,14 @@
  */
 package org.apache.hadoop.hive.serde2.objectinspector;
 
-import org.apache.hadoop.hive.serde2.typeinfo.BaseTypeParams;
-import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeSpec;
+import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
+
 
 /**
  * PrimitiveObjectInspector.
  *
  */
-public interface PrimitiveObjectInspector extends ObjectInspector, PrimitiveTypeSpec {
+public interface PrimitiveObjectInspector extends ObjectInspector {
 
   /**
    * The primitive types supported by Hive.
@@ -34,6 +34,8 @@ public interface PrimitiveObjectInspecto
     DATE, TIMESTAMP, BINARY, DECIMAL, VARCHAR, UNKNOWN
   };
 
+  public PrimitiveTypeInfo getTypeInfo();
+
   /**
    * Get the primitive category of the PrimitiveObjectInspector.
    */
@@ -78,16 +80,4 @@ public interface PrimitiveObjectInspecto
    */
   boolean preferWritable();
 
-  /**
-   * If the type has type parameters (such as varchar length, or decimal precision/scale),
-   * then return the parameters for the type.
-   * @return A BaseTypeParams object representing the parameters for the type, or null
-   */
-  BaseTypeParams getTypeParams();
-
-  /**
-   * Set the type parameters for the type.
-   * @param newParams type parameters for the type
-   */
-  void setTypeParams(BaseTypeParams newParams);
 }

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveJavaObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveJavaObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveJavaObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveJavaObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -17,7 +17,7 @@
  */
 package org.apache.hadoop.hive.serde2.objectinspector.primitive;
 
-import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.PrimitiveTypeEntry;
+import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
 
 /**
  * An AbstractJavaPrimitiveObjectInspector for a Java object.
@@ -28,8 +28,8 @@ public abstract class AbstractPrimitiveJ
   protected AbstractPrimitiveJavaObjectInspector() {
     super();
   }
-  protected AbstractPrimitiveJavaObjectInspector(PrimitiveTypeEntry typeEntry) {
-    super(typeEntry);
+  protected AbstractPrimitiveJavaObjectInspector(PrimitiveTypeInfo typeInfo) {
+    super(typeInfo);
   }
 
   @Override

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -18,8 +18,7 @@
 package org.apache.hadoop.hive.serde2.objectinspector.primitive;
 
 import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
-import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.PrimitiveTypeEntry;
-import org.apache.hadoop.hive.serde2.typeinfo.BaseTypeParams;
+import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
 
 /**
  * An AbstractPrimitiveObjectInspector is based on
@@ -28,7 +27,7 @@ import org.apache.hadoop.hive.serde2.typ
 public abstract class AbstractPrimitiveObjectInspector implements
     PrimitiveObjectInspector {
 
-  protected PrimitiveTypeEntry typeEntry;
+  protected PrimitiveTypeInfo typeInfo;
 
   protected AbstractPrimitiveObjectInspector() {
     super();
@@ -36,8 +35,8 @@ public abstract class AbstractPrimitiveO
   /**
    * Construct a AbstractPrimitiveObjectInspector.
    */
-  protected AbstractPrimitiveObjectInspector(PrimitiveTypeEntry typeEntry) {
-    this.typeEntry = typeEntry;
+  protected AbstractPrimitiveObjectInspector(PrimitiveTypeInfo typeInfo) {
+    this.typeInfo = typeInfo;
   }
 
   /**
@@ -46,7 +45,7 @@ public abstract class AbstractPrimitiveO
    */
   @Override
   public Class<?> getJavaPrimitiveClass() {
-    return typeEntry.primitiveJavaClass;
+    return typeInfo.getPrimitiveJavaClass();
   }
 
   /**
@@ -55,7 +54,7 @@ public abstract class AbstractPrimitiveO
    */
   @Override
   public PrimitiveCategory getPrimitiveCategory() {
-    return typeEntry.primitiveCategory;
+    return typeInfo.getPrimitiveCategory();
   }
 
   /**
@@ -64,7 +63,7 @@ public abstract class AbstractPrimitiveO
    */
   @Override
   public Class<?> getPrimitiveWritableClass() {
-    return typeEntry.primitiveWritableClass;
+    return typeInfo.getPrimitiveWritableClass();
   }
 
   /**
@@ -80,19 +79,11 @@ public abstract class AbstractPrimitiveO
    */
   @Override
   public String getTypeName() {
-    return typeEntry.toString();
+    return typeInfo.getTypeName();
   }
 
-  public BaseTypeParams getTypeParams() {
-    return typeEntry.typeParams;
+  public PrimitiveTypeInfo getTypeInfo() {
+    return this.typeInfo;
   }
 
-  public void setTypeParams(BaseTypeParams newParams) {
-    BaseTypeParams typeParams = typeEntry.typeParams;
-    if (typeParams != null && !typeEntry.isParameterized()) {
-      throw new UnsupportedOperationException(
-          "Attempting to add type parameters " + typeParams + " to type " + getTypeName());
-    }
-    typeEntry.typeParams = newParams;
-  }
 }

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveWritableObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveWritableObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveWritableObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveWritableObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -17,7 +17,7 @@
  */
 package org.apache.hadoop.hive.serde2.objectinspector.primitive;
 
-import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.PrimitiveTypeEntry;
+import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
 
 /**
  * An AbstractWritablePrimitiveObjectInspector for a Writable object.
@@ -29,8 +29,8 @@ public abstract class AbstractPrimitiveW
     super();
   }
   protected AbstractPrimitiveWritableObjectInspector(
-      PrimitiveTypeEntry typeEntry) {
-    super(typeEntry);
+      PrimitiveTypeInfo typeInfo) {
+    super(typeInfo);
   }
 
   @Override

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBinaryObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBinaryObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBinaryObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBinaryObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -3,6 +3,7 @@ package org.apache.hadoop.hive.serde2.ob
 import java.util.Arrays;
 
 import org.apache.hadoop.hive.serde2.lazy.LazyUtils;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 import org.apache.hadoop.io.BytesWritable;
 
 /**
@@ -27,7 +28,7 @@ public class JavaBinaryObjectInspector e
     SettableBinaryObjectInspector {
 
   JavaBinaryObjectInspector() {
-    super(PrimitiveObjectInspectorUtils.binaryTypeEntry);
+    super(TypeInfoFactory.binaryTypeInfo);
   }
 
   @Override

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBooleanObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBooleanObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBooleanObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBooleanObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -17,6 +17,7 @@
  */
 package org.apache.hadoop.hive.serde2.objectinspector.primitive;
 
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 import org.apache.hadoop.io.BooleanWritable;
 
 /**
@@ -27,7 +28,7 @@ public class JavaBooleanObjectInspector 
     SettableBooleanObjectInspector {
 
   JavaBooleanObjectInspector() {
-    super(PrimitiveObjectInspectorUtils.booleanTypeEntry);
+    super(TypeInfoFactory.booleanTypeInfo);
   }
 
   @Override

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaByteObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaByteObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaByteObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaByteObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -18,6 +18,7 @@
 package org.apache.hadoop.hive.serde2.objectinspector.primitive;
 
 import org.apache.hadoop.hive.serde2.io.ByteWritable;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 
 /**
  * A JavaByteObjectInspector inspects a Java Byte Object.
@@ -26,7 +27,7 @@ public class JavaByteObjectInspector ext
     AbstractPrimitiveJavaObjectInspector implements SettableByteObjectInspector {
 
   JavaByteObjectInspector() {
-    super(PrimitiveObjectInspectorUtils.byteTypeEntry);
+    super(TypeInfoFactory.byteTypeInfo);
   }
 
   @Override

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaDateObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaDateObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaDateObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaDateObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -20,6 +20,7 @@ package org.apache.hadoop.hive.serde2.ob
 import java.sql.Date;
 
 import org.apache.hadoop.hive.serde2.io.DateWritable;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 
 /**
  * A JavaDateObjectInspector inspects a Java Date Object.
@@ -29,7 +30,7 @@ public class JavaDateObjectInspector
     implements SettableDateObjectInspector {
 
   protected JavaDateObjectInspector() {
-    super(PrimitiveObjectInspectorUtils.dateTypeEntry);
+    super(TypeInfoFactory.dateTypeInfo);
   }
 
   public DateWritable getPrimitiveWritableObject(Object o) {

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaDoubleObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaDoubleObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaDoubleObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaDoubleObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -18,6 +18,7 @@
 package org.apache.hadoop.hive.serde2.objectinspector.primitive;
 
 import org.apache.hadoop.hive.serde2.io.DoubleWritable;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 
 /**
  * A JavaDoubleObjectInspector inspects a Java Double Object.
@@ -27,7 +28,7 @@ public class JavaDoubleObjectInspector e
     SettableDoubleObjectInspector {
 
   JavaDoubleObjectInspector() {
-    super(PrimitiveObjectInspectorUtils.doubleTypeEntry);
+    super(TypeInfoFactory.doubleTypeInfo);
   }
 
   @Override

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaFloatObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaFloatObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaFloatObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaFloatObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -17,6 +17,7 @@
  */
 package org.apache.hadoop.hive.serde2.objectinspector.primitive;
 
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 import org.apache.hadoop.io.FloatWritable;
 
 /**
@@ -27,7 +28,7 @@ public class JavaFloatObjectInspector ex
     SettableFloatObjectInspector {
 
   JavaFloatObjectInspector() {
-    super(PrimitiveObjectInspectorUtils.floatTypeEntry);
+    super(TypeInfoFactory.floatTypeInfo);
   }
 
   @Override

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaHiveDecimalObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaHiveDecimalObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaHiveDecimalObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaHiveDecimalObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -21,13 +21,14 @@ import java.math.BigInteger;
 
 import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 
 public class JavaHiveDecimalObjectInspector
     extends AbstractPrimitiveJavaObjectInspector
     implements SettableHiveDecimalObjectInspector {
 
   protected JavaHiveDecimalObjectInspector() {
-    super(PrimitiveObjectInspectorUtils.decimalTypeEntry);
+    super(TypeInfoFactory.decimalTypeInfo);
   }
 
   @Override

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaHiveVarcharObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaHiveVarcharObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaHiveVarcharObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaHiveVarcharObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -19,24 +19,18 @@ package org.apache.hadoop.hive.serde2.ob
 
 import org.apache.hadoop.hive.common.type.HiveVarchar;
 import org.apache.hadoop.hive.serde2.io.HiveVarcharWritable;
-import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.PrimitiveTypeEntry;
-import org.apache.hadoop.hive.serde2.typeinfo.ParameterizedPrimitiveTypeUtils;
-import org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeParams;
-
-public class JavaHiveVarcharObjectInspector
-    extends AbstractPrimitiveJavaObjectInspector
-    implements SettableHiveVarcharObjectInspector {
+import org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeInfo;
+import org.apache.hadoop.hive.serde2.typeinfo.VarcharUtils;
+
+public class JavaHiveVarcharObjectInspector extends AbstractPrimitiveJavaObjectInspector
+implements SettableHiveVarcharObjectInspector {
 
   // no-arg ctor required for Kyro serialization
   public JavaHiveVarcharObjectInspector() {
   }
 
-  public JavaHiveVarcharObjectInspector(PrimitiveTypeEntry typeEntry) {
-    super(typeEntry);
-    if (typeEntry.primitiveCategory != PrimitiveCategory.VARCHAR) {
-      throw new RuntimeException(
-          "TypeEntry of type varchar expected, got " + typeEntry.primitiveCategory);
-    }
+  public JavaHiveVarcharObjectInspector(VarcharTypeInfo typeInfo) {
+    super(typeInfo);
   }
 
   @Override
@@ -45,8 +39,8 @@ public class JavaHiveVarcharObjectInspec
       return null;
     }
     HiveVarchar value = (HiveVarchar)o;
-    if (ParameterizedPrimitiveTypeUtils.doesPrimitiveMatchTypeParams(
-        value, (VarcharTypeParams) getTypeParams())) {
+    if (VarcharUtils.doesPrimitiveMatchTypeParams(
+        value, (VarcharTypeInfo)typeInfo)) {
       return value;
     }
     // value needs to be converted to match the type params (length, etc).
@@ -75,8 +69,8 @@ public class JavaHiveVarcharObjectInspec
   @Override
   public Object set(Object o, HiveVarchar value) {
     HiveVarchar setValue = (HiveVarchar)o;
-    if (ParameterizedPrimitiveTypeUtils.doesPrimitiveMatchTypeParams(
-        value, (VarcharTypeParams) getTypeParams())) {
+    if (VarcharUtils.doesPrimitiveMatchTypeParams(
+        value, (VarcharTypeInfo)typeInfo)) {
       setValue.setValue(value);
     } else {
       // Otherwise value may be too long, convert to appropriate value based on params
@@ -100,7 +94,8 @@ public class JavaHiveVarcharObjectInspec
   }
 
   public int getMaxLength() {
-    VarcharTypeParams typeParams = (VarcharTypeParams)getTypeParams();
-    return typeParams != null ? typeParams.length : -1;
+    VarcharTypeInfo ti = (VarcharTypeInfo) typeInfo;
+    return ti.getLength();
   }
+
 }

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaIntObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaIntObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaIntObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaIntObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -17,6 +17,7 @@
  */
 package org.apache.hadoop.hive.serde2.objectinspector.primitive;
 
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 import org.apache.hadoop.io.IntWritable;
 
 /**
@@ -26,7 +27,7 @@ public class JavaIntObjectInspector exte
     AbstractPrimitiveJavaObjectInspector implements SettableIntObjectInspector {
 
   JavaIntObjectInspector() {
-    super(PrimitiveObjectInspectorUtils.intTypeEntry);
+    super(TypeInfoFactory.intTypeInfo);
   }
 
   @Override

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaLongObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaLongObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaLongObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaLongObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -17,6 +17,7 @@
  */
 package org.apache.hadoop.hive.serde2.objectinspector.primitive;
 
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 import org.apache.hadoop.io.LongWritable;
 
 /**
@@ -26,7 +27,7 @@ public class JavaLongObjectInspector ext
     AbstractPrimitiveJavaObjectInspector implements SettableLongObjectInspector {
 
   JavaLongObjectInspector() {
-    super(PrimitiveObjectInspectorUtils.longTypeEntry);
+    super(TypeInfoFactory.longTypeInfo);
   }
 
   @Override

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaShortObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaShortObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaShortObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaShortObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -18,6 +18,7 @@
 package org.apache.hadoop.hive.serde2.objectinspector.primitive;
 
 import org.apache.hadoop.hive.serde2.io.ShortWritable;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 
 /**
  * A JavaShortObjectInspector inspects a Java Short Object.
@@ -27,7 +28,7 @@ public class JavaShortObjectInspector ex
     SettableShortObjectInspector {
 
   JavaShortObjectInspector() {
-    super(PrimitiveObjectInspectorUtils.shortTypeEntry);
+    super(TypeInfoFactory.shortTypeInfo);
   }
 
   @Override

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaStringObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaStringObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaStringObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaStringObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -17,6 +17,7 @@
  */
 package org.apache.hadoop.hive.serde2.objectinspector.primitive;
 
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 import org.apache.hadoop.io.Text;
 
 /**
@@ -27,7 +28,7 @@ public class JavaStringObjectInspector e
     SettableStringObjectInspector {
 
   JavaStringObjectInspector() {
-    super(PrimitiveObjectInspectorUtils.stringTypeEntry);
+    super(TypeInfoFactory.stringTypeInfo);
   }
 
   @Override

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaTimestampObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaTimestampObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaTimestampObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaTimestampObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -20,13 +20,14 @@ package org.apache.hadoop.hive.serde2.ob
 import java.sql.Timestamp;
 
 import org.apache.hadoop.hive.serde2.io.TimestampWritable;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 
 public class JavaTimestampObjectInspector
     extends AbstractPrimitiveJavaObjectInspector
     implements SettableTimestampObjectInspector {
 
   protected JavaTimestampObjectInspector() {
-    super(PrimitiveObjectInspectorUtils.timestampTypeEntry);
+    super(TypeInfoFactory.timestampTypeInfo);
   }
 
   public TimestampWritable getPrimitiveWritableObject(Object o) {

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaVoidObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaVoidObjectInspector.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaVoidObjectInspector.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaVoidObjectInspector.java Mon Oct  7 06:39:52 2013
@@ -17,6 +17,7 @@
  */
 package org.apache.hadoop.hive.serde2.objectinspector.primitive;
 
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 import org.apache.hadoop.io.NullWritable;
 
 /**
@@ -26,7 +27,7 @@ public class JavaVoidObjectInspector ext
     AbstractPrimitiveJavaObjectInspector implements VoidObjectInspector {
 
   JavaVoidObjectInspector() {
-    super(PrimitiveObjectInspectorUtils.voidTypeEntry);
+    super(TypeInfoFactory.voidTypeInfo);
   }
 
   @Override

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorConverter.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorConverter.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorConverter.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorConverter.java Mon Oct  7 06:39:52 2013
@@ -29,7 +29,6 @@ import org.apache.hadoop.hive.serde2.laz
 import org.apache.hadoop.hive.serde2.lazy.LazyLong;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters.Converter;
 import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
-import org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeParams;
 import org.apache.hadoop.io.Text;
 
 /**
@@ -452,7 +451,6 @@ public class PrimitiveObjectInspectorCon
         SettableHiveVarcharObjectInspector outputOI) {
       this.inputOI = inputOI;
       this.outputOI = outputOI;
-      VarcharTypeParams typeParams = (VarcharTypeParams) outputOI.getTypeParams();
 
       // unfortunately we seem to get instances of varchar object inspectors without params
       // when an old-style UDF has an evaluate() method with varchar arguments.

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorFactory.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorFactory.java?rev=1529771&r1=1529770&r2=1529771&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorFactory.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorFactory.java Mon Oct  7 06:39:52 2013
@@ -18,8 +18,12 @@
 
 package org.apache.hadoop.hive.serde2.objectinspector.primitive;
 
+import java.util.EnumMap;
 import java.util.HashMap;
+import java.util.Map;
 
+import org.apache.hadoop.hive.common.type.HiveVarchar;
+import org.apache.hadoop.hive.serde.serdeConstants;
 import org.apache.hadoop.hive.serde2.io.ByteWritable;
 import org.apache.hadoop.hive.serde2.io.DateWritable;
 import org.apache.hadoop.hive.serde2.io.DoubleWritable;
@@ -30,11 +34,10 @@ import org.apache.hadoop.hive.serde2.io.
 import org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory;
-import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.ParameterizedObjectInspectorMap;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.PrimitiveTypeEntry;
-import org.apache.hadoop.hive.serde2.typeinfo.BaseTypeParams;
-import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeSpec;
-import org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeParams;
+import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
+import org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeInfo;
 import org.apache.hadoop.io.BooleanWritable;
 import org.apache.hadoop.io.BytesWritable;
 import org.apache.hadoop.io.FloatWritable;
@@ -54,35 +57,6 @@ import org.apache.hadoop.io.Writable;
  */
 public final class PrimitiveObjectInspectorFactory {
 
-  public static final JavaBooleanObjectInspector javaBooleanObjectInspector =
-      new JavaBooleanObjectInspector();
-  public static final JavaByteObjectInspector javaByteObjectInspector =
-      new JavaByteObjectInspector();
-  public static final JavaShortObjectInspector javaShortObjectInspector =
-      new JavaShortObjectInspector();
-  public static final JavaIntObjectInspector javaIntObjectInspector =
-      new JavaIntObjectInspector();
-  public static final JavaLongObjectInspector javaLongObjectInspector =
-      new JavaLongObjectInspector();
-  public static final JavaFloatObjectInspector javaFloatObjectInspector =
-      new JavaFloatObjectInspector();
-  public static final JavaDoubleObjectInspector javaDoubleObjectInspector =
-      new JavaDoubleObjectInspector();
-  public static final JavaStringObjectInspector javaStringObjectInspector =
-      new JavaStringObjectInspector();
-  public static final JavaHiveVarcharObjectInspector javaHiveVarcharObjectInspector =
-      new JavaHiveVarcharObjectInspector(PrimitiveObjectInspectorUtils.varcharTypeEntry);
-  public static final JavaVoidObjectInspector javaVoidObjectInspector =
-      new JavaVoidObjectInspector();
-  public static final JavaDateObjectInspector javaDateObjectInspector =
-      new JavaDateObjectInspector();
-  public static final JavaTimestampObjectInspector javaTimestampObjectInspector =
-      new JavaTimestampObjectInspector();
-  public static final JavaBinaryObjectInspector javaByteArrayObjectInspector =
-      new JavaBinaryObjectInspector();
-  public static final JavaHiveDecimalObjectInspector javaHiveDecimalObjectInspector =
-      new JavaHiveDecimalObjectInspector();
-
   public static final WritableBooleanObjectInspector writableBooleanObjectInspector =
       new WritableBooleanObjectInspector();
   public static final WritableByteObjectInspector writableByteObjectInspector =
@@ -99,8 +73,6 @@ public final class PrimitiveObjectInspec
       new WritableDoubleObjectInspector();
   public static final WritableStringObjectInspector writableStringObjectInspector =
       new WritableStringObjectInspector();
-  public static final WritableHiveVarcharObjectInspector writableHiveVarcharObjectInspector =
-      new WritableHiveVarcharObjectInspector(PrimitiveObjectInspectorUtils.varcharTypeEntry);
   public static final WritableVoidObjectInspector writableVoidObjectInspector =
       new WritableVoidObjectInspector();
   public static final WritableDateObjectInspector writableDateObjectInspector =
@@ -112,85 +84,132 @@ public final class PrimitiveObjectInspec
   public static final WritableHiveDecimalObjectInspector writableHiveDecimalObjectInspector =
       new WritableHiveDecimalObjectInspector();
 
-  private static HashMap<PrimitiveCategory, AbstractPrimitiveWritableObjectInspector> cachedPrimitiveWritableInspectorCache =
-      new HashMap<PrimitiveCategory, AbstractPrimitiveWritableObjectInspector>();
+  // Map from PrimitiveTypeInfo to AbstractPrimitiveWritableObjectInspector.
+  private static HashMap<PrimitiveTypeInfo, AbstractPrimitiveWritableObjectInspector> cachedPrimitiveWritableInspectorCache =
+      new HashMap<PrimitiveTypeInfo, AbstractPrimitiveWritableObjectInspector>();
   static {
-    cachedPrimitiveWritableInspectorCache.put(PrimitiveCategory.BOOLEAN,
+    cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.BOOLEAN_TYPE_NAME),
         writableBooleanObjectInspector);
-    cachedPrimitiveWritableInspectorCache.put(PrimitiveCategory.BYTE,
+    cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.TINYINT_TYPE_NAME),
         writableByteObjectInspector);
-    cachedPrimitiveWritableInspectorCache.put(PrimitiveCategory.SHORT,
+    cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.SMALLINT_TYPE_NAME),
         writableShortObjectInspector);
-    cachedPrimitiveWritableInspectorCache.put(PrimitiveCategory.INT,
+    cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.INT_TYPE_NAME),
         writableIntObjectInspector);
-    cachedPrimitiveWritableInspectorCache.put(PrimitiveCategory.LONG,
+    cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.BIGINT_TYPE_NAME),
         writableLongObjectInspector);
-    cachedPrimitiveWritableInspectorCache.put(PrimitiveCategory.FLOAT,
+    cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.FLOAT_TYPE_NAME),
         writableFloatObjectInspector);
-    cachedPrimitiveWritableInspectorCache.put(PrimitiveCategory.DOUBLE,
+    cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.DOUBLE_TYPE_NAME),
         writableDoubleObjectInspector);
-    cachedPrimitiveWritableInspectorCache.put(PrimitiveCategory.STRING,
+    cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.STRING_TYPE_NAME),
         writableStringObjectInspector);
-    cachedPrimitiveWritableInspectorCache.put(PrimitiveCategory.VARCHAR,
-        writableHiveVarcharObjectInspector);
-    cachedPrimitiveWritableInspectorCache.put(PrimitiveCategory.VOID,
+    cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.VOID_TYPE_NAME),
         writableVoidObjectInspector);
-    cachedPrimitiveWritableInspectorCache.put(PrimitiveCategory.DATE,
+    cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.DATE_TYPE_NAME),
         writableDateObjectInspector);
-    cachedPrimitiveWritableInspectorCache.put(PrimitiveCategory.TIMESTAMP,
+    cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.TIMESTAMP_TYPE_NAME),
         writableTimestampObjectInspector);
-    cachedPrimitiveWritableInspectorCache.put(PrimitiveCategory.BINARY,
+    cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.BINARY_TYPE_NAME),
         writableBinaryObjectInspector);
-    cachedPrimitiveWritableInspectorCache.put(PrimitiveCategory.DECIMAL,
+    cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.DECIMAL_TYPE_NAME),
         writableHiveDecimalObjectInspector);
   }
 
-  private static HashMap<PrimitiveCategory, AbstractPrimitiveJavaObjectInspector> cachedPrimitiveJavaInspectorCache =
-      new HashMap<PrimitiveCategory, AbstractPrimitiveJavaObjectInspector>();
+  private static Map<PrimitiveCategory, AbstractPrimitiveWritableObjectInspector> primitiveCategoryToWritableOI =
+      new EnumMap<PrimitiveCategory, AbstractPrimitiveWritableObjectInspector>(PrimitiveCategory.class);
+  static {
+    primitiveCategoryToWritableOI.put(PrimitiveCategory.BOOLEAN, writableBooleanObjectInspector);
+    primitiveCategoryToWritableOI.put(PrimitiveCategory.BYTE, writableByteObjectInspector);
+    primitiveCategoryToWritableOI.put(PrimitiveCategory.SHORT, writableShortObjectInspector);
+    primitiveCategoryToWritableOI.put(PrimitiveCategory.INT, writableIntObjectInspector);
+    primitiveCategoryToWritableOI.put(PrimitiveCategory.LONG, writableLongObjectInspector);
+    primitiveCategoryToWritableOI.put(PrimitiveCategory.FLOAT, writableFloatObjectInspector);
+    primitiveCategoryToWritableOI.put(PrimitiveCategory.DOUBLE, writableDoubleObjectInspector);
+    primitiveCategoryToWritableOI.put(PrimitiveCategory.STRING, writableStringObjectInspector);
+    primitiveCategoryToWritableOI.put(PrimitiveCategory.VOID, writableVoidObjectInspector);
+    primitiveCategoryToWritableOI.put(PrimitiveCategory.DATE, writableDateObjectInspector);
+    primitiveCategoryToWritableOI.put(PrimitiveCategory.TIMESTAMP, writableTimestampObjectInspector);
+    primitiveCategoryToWritableOI.put(PrimitiveCategory.BINARY, writableBinaryObjectInspector);
+    primitiveCategoryToWritableOI.put(PrimitiveCategory.DECIMAL, writableHiveDecimalObjectInspector);
+  }
+
+  public static final JavaBooleanObjectInspector javaBooleanObjectInspector =
+      new JavaBooleanObjectInspector();
+  public static final JavaByteObjectInspector javaByteObjectInspector =
+      new JavaByteObjectInspector();
+  public static final JavaShortObjectInspector javaShortObjectInspector =
+      new JavaShortObjectInspector();
+  public static final JavaIntObjectInspector javaIntObjectInspector =
+      new JavaIntObjectInspector();
+  public static final JavaLongObjectInspector javaLongObjectInspector =
+      new JavaLongObjectInspector();
+  public static final JavaFloatObjectInspector javaFloatObjectInspector =
+      new JavaFloatObjectInspector();
+  public static final JavaDoubleObjectInspector javaDoubleObjectInspector =
+      new JavaDoubleObjectInspector();
+  public static final JavaStringObjectInspector javaStringObjectInspector =
+      new JavaStringObjectInspector();
+  public static final JavaVoidObjectInspector javaVoidObjectInspector =
+      new JavaVoidObjectInspector();
+  public static final JavaDateObjectInspector javaDateObjectInspector =
+      new JavaDateObjectInspector();
+  public static final JavaTimestampObjectInspector javaTimestampObjectInspector =
+      new JavaTimestampObjectInspector();
+  public static final JavaBinaryObjectInspector javaByteArrayObjectInspector =
+      new JavaBinaryObjectInspector();
+  public static final JavaHiveDecimalObjectInspector javaHiveDecimalObjectInspector =
+      new JavaHiveDecimalObjectInspector();
+
+  // Map from PrimitiveTypeInfo to AbstractPrimitiveJavaObjectInspector.
+  private static HashMap<PrimitiveTypeInfo, AbstractPrimitiveJavaObjectInspector> cachedPrimitiveJavaInspectorCache =
+      new HashMap<PrimitiveTypeInfo, AbstractPrimitiveJavaObjectInspector>();
   static {
-    cachedPrimitiveJavaInspectorCache.put(PrimitiveCategory.BOOLEAN,
+    cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.BOOLEAN_TYPE_NAME),
         javaBooleanObjectInspector);
-    cachedPrimitiveJavaInspectorCache.put(PrimitiveCategory.BYTE,
+    cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.TINYINT_TYPE_NAME),
         javaByteObjectInspector);
-    cachedPrimitiveJavaInspectorCache.put(PrimitiveCategory.SHORT,
+    cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.SMALLINT_TYPE_NAME),
         javaShortObjectInspector);
-    cachedPrimitiveJavaInspectorCache.put(PrimitiveCategory.INT,
+    cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.INT_TYPE_NAME),
         javaIntObjectInspector);
-    cachedPrimitiveJavaInspectorCache.put(PrimitiveCategory.LONG,
+    cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.BIGINT_TYPE_NAME),
         javaLongObjectInspector);
-    cachedPrimitiveJavaInspectorCache.put(PrimitiveCategory.FLOAT,
+    cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.FLOAT_TYPE_NAME),
         javaFloatObjectInspector);
-    cachedPrimitiveJavaInspectorCache.put(PrimitiveCategory.DOUBLE,
+    cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.DOUBLE_TYPE_NAME),
         javaDoubleObjectInspector);
-    cachedPrimitiveJavaInspectorCache.put(PrimitiveCategory.STRING,
+    cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.STRING_TYPE_NAME),
         javaStringObjectInspector);
-    cachedPrimitiveJavaInspectorCache.put(PrimitiveCategory.VARCHAR,
-        javaHiveVarcharObjectInspector);
-    cachedPrimitiveJavaInspectorCache.put(PrimitiveCategory.VOID,
+    cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.VOID_TYPE_NAME),
         javaVoidObjectInspector);
-    cachedPrimitiveJavaInspectorCache.put(PrimitiveCategory.DATE,
+    cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.DATE_TYPE_NAME),
         javaDateObjectInspector);
-    cachedPrimitiveJavaInspectorCache.put(PrimitiveCategory.TIMESTAMP,
+    cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.TIMESTAMP_TYPE_NAME),
         javaTimestampObjectInspector);
-    cachedPrimitiveJavaInspectorCache.put(PrimitiveCategory.BINARY,
+    cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.BINARY_TYPE_NAME),
         javaByteArrayObjectInspector);
-    cachedPrimitiveJavaInspectorCache.put(PrimitiveCategory.DECIMAL,
+    cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.DECIMAL_TYPE_NAME),
         javaHiveDecimalObjectInspector);
   }
 
-  /**
-   * Cached Writable object inspectors for parameterized primitive types.
-   */
-  private static ParameterizedObjectInspectorMap
-      cachedParameterizedPrimitiveWritableObjectInspectorCache =
-          new ParameterizedObjectInspectorMap();
-
-  /**
-   * Cached Java object inspectors for parameterized primitive types.
-   */
-  private static ParameterizedObjectInspectorMap
-  cachedParameterizedPrimitiveJavaObjectInspectorCache =
-      new ParameterizedObjectInspectorMap();
+  private static Map<PrimitiveCategory, AbstractPrimitiveJavaObjectInspector> primitiveCategoryToJavaOI =
+      new EnumMap<PrimitiveCategory, AbstractPrimitiveJavaObjectInspector>(PrimitiveCategory.class);
+  static {
+    primitiveCategoryToJavaOI.put(PrimitiveCategory.BOOLEAN, javaBooleanObjectInspector);
+    primitiveCategoryToJavaOI.put(PrimitiveCategory.BYTE, javaByteObjectInspector);
+    primitiveCategoryToJavaOI.put(PrimitiveCategory.SHORT, javaShortObjectInspector);
+    primitiveCategoryToJavaOI.put(PrimitiveCategory.INT, javaIntObjectInspector);
+    primitiveCategoryToJavaOI.put(PrimitiveCategory.LONG, javaLongObjectInspector);
+    primitiveCategoryToJavaOI.put(PrimitiveCategory.FLOAT, javaFloatObjectInspector);
+    primitiveCategoryToJavaOI.put(PrimitiveCategory.DOUBLE, javaDoubleObjectInspector);
+    primitiveCategoryToJavaOI.put(PrimitiveCategory.STRING, javaStringObjectInspector);
+    primitiveCategoryToJavaOI.put(PrimitiveCategory.VOID, javaVoidObjectInspector);
+    primitiveCategoryToJavaOI.put(PrimitiveCategory.DATE, javaDateObjectInspector);
+    primitiveCategoryToJavaOI.put(PrimitiveCategory.TIMESTAMP, javaTimestampObjectInspector);
+    primitiveCategoryToJavaOI.put(PrimitiveCategory.BINARY, javaByteArrayObjectInspector);
+    primitiveCategoryToJavaOI.put(PrimitiveCategory.DECIMAL, javaHiveDecimalObjectInspector);
+  }
 
   /**
    * Returns the PrimitiveWritableObjectInspector for the PrimitiveCategory.
@@ -199,75 +218,38 @@ public final class PrimitiveObjectInspec
    */
   public static AbstractPrimitiveWritableObjectInspector getPrimitiveWritableObjectInspector(
       PrimitiveCategory primitiveCategory) {
-    AbstractPrimitiveWritableObjectInspector result =
-        cachedPrimitiveWritableInspectorCache.get(primitiveCategory);
+    AbstractPrimitiveWritableObjectInspector result = primitiveCategoryToWritableOI.get(primitiveCategory);
+
     if (result == null) {
       throw new RuntimeException("Internal error: Cannot find ObjectInspector "
           + " for " + primitiveCategory);
     }
+
     return result;
   }
 
   /**
-   * Returns the PrimitiveWritableObjectInspector for the PrimitiveCategory, with option to
-   * pass in parameters for the primitive type (such as char(10)).
-   * Ideally this method should be used over the method without type parameters,
-   * and the type parameters (or lack of parameters) can be determined from
-   * the input ObjectInspector, TypeInfo, or TypeEntry.
-   * However there are situations where it is not possible to get any information about
-   * type parameters, such as when getting an object inspector based on reflection from
-   * the java or primitive class.
-   * @param primitiveCategory    Primitve type category
-   * @param primitiveTypeParams  Type parameters for the primitve type.
-   *        Set to null if there are no type parameters
-   * @return
+   * Returns the PrimitiveWritableObjectInspector for the given type info
+   * @param PrimitiveTypeInfo    PrimitiveTypeInfo instance
+   * @return AbstractPrimitiveWritableObjectInspector instance
    */
   public static AbstractPrimitiveWritableObjectInspector getPrimitiveWritableObjectInspector(
-      PrimitiveTypeSpec typeSpec) {
-    PrimitiveCategory primitiveCategory = typeSpec.getPrimitiveCategory();
-    BaseTypeParams primitiveTypeParams = typeSpec.getTypeParams();
-
-    if (primitiveTypeParams == null) {
-      // No type params, just search the unparameterized types
-      return getPrimitiveWritableObjectInspector(primitiveCategory);
-    } else {
-      // Check our cached set of parameterized object inspectors for the primitive category,
-      // or create a new object inspector if one doesn't exist yet.
-      PrimitiveObjectInspector oi =
-          cachedParameterizedPrimitiveWritableObjectInspectorCache.getObjectInspector(
-              typeSpec);
-      if (oi == null) {
-        // Do a bit of validation - not all primitive types use parameters.
-        switch (primitiveCategory) {
-          case VARCHAR:
-            PrimitiveTypeEntry typeEntry = PrimitiveObjectInspectorUtils.getTypeEntryFromTypeSpecs(
-                primitiveCategory,
-                primitiveTypeParams);
-            oi = new WritableHiveVarcharObjectInspector(typeEntry);
-            oi.setTypeParams(primitiveTypeParams);
-            cachedParameterizedPrimitiveWritableObjectInspectorCache.setObjectInspector(oi);
-            break;
-          default:
-            throw new RuntimeException(
-                "Primitve type " + primitiveCategory + " should not take parameters");
-        }
-      }
-      return (AbstractPrimitiveWritableObjectInspector)oi;
+      PrimitiveTypeInfo typeInfo) {
+    AbstractPrimitiveWritableObjectInspector result = cachedPrimitiveWritableInspectorCache.get(typeInfo);
+    if (result != null) {
+      return result;
     }
-  }
 
-  /**
-   * Returns a PrimitiveWritableObjectInspector which implements ConstantObjectInspector
-   * for the PrimitiveCategory.
-   *
-   * @param primitiveCategory
-   * @param value
-   */
-  public static ConstantObjectInspector getPrimitiveWritableConstantObjectInspector(
-      PrimitiveCategory primitiveCategory, Object value) {
-    return getPrimitiveWritableConstantObjectInspector(
-        PrimitiveObjectInspectorUtils.getTypeEntryFromTypeSpecs(primitiveCategory, null),
-        value);
+    switch (typeInfo.getPrimitiveCategory()) {
+    case VARCHAR:
+      result = new WritableHiveVarcharObjectInspector((VarcharTypeInfo)typeInfo);
+      break;
+      default:
+        throw new RuntimeException("Failed to create WritableHiveVarcharObjectInspector for " + typeInfo );
+    }
+
+    cachedPrimitiveWritableInspectorCache.put(typeInfo, result);
+    return result;
   }
 
   /**
@@ -275,15 +257,11 @@ public final class PrimitiveObjectInspec
    * for the PrimitiveCategory.
    *
    * @param primitiveCategory
-   * @param typeParams  Type qualifiers for the type (if applicable)
    * @param value
    */
   public static ConstantObjectInspector getPrimitiveWritableConstantObjectInspector(
-      PrimitiveTypeSpec typeSpecs, Object value) {
-    PrimitiveCategory primitiveCategory = typeSpecs.getPrimitiveCategory();
-    BaseTypeParams typeParams = typeSpecs.getTypeParams();
-
-    switch (primitiveCategory) {
+      PrimitiveTypeInfo typeInfo, Object value) {
+    switch (typeInfo.getPrimitiveCategory()) {
     case BOOLEAN:
       return new WritableConstantBooleanObjectInspector((BooleanWritable)value);
     case BYTE:
@@ -301,8 +279,8 @@ public final class PrimitiveObjectInspec
     case STRING:
       return new WritableConstantStringObjectInspector((Text)value);
     case VARCHAR:
-      return new WritableConstantHiveVarcharObjectInspector((HiveVarcharWritable)value,
-          (VarcharTypeParams) typeParams);
+      return new WritableConstantHiveVarcharObjectInspector((VarcharTypeInfo)typeInfo,
+          (HiveVarcharWritable)value);
     case DATE:
       return new WritableConstantDateObjectInspector((DateWritable)value);
     case TIMESTAMP:
@@ -315,7 +293,7 @@ public final class PrimitiveObjectInspec
       return new WritableVoidObjectInspector();
     default:
       throw new RuntimeException("Internal error: Cannot find "
-        + "ConstantObjectInspector for " + primitiveCategory);
+        + "ConstantObjectInspector for " + typeInfo);
     }
   }
 
@@ -326,62 +304,40 @@ public final class PrimitiveObjectInspec
    */
   public static AbstractPrimitiveJavaObjectInspector getPrimitiveJavaObjectInspector(
       PrimitiveCategory primitiveCategory) {
-    AbstractPrimitiveJavaObjectInspector result =
-        cachedPrimitiveJavaInspectorCache.get(primitiveCategory);
+    AbstractPrimitiveJavaObjectInspector result = primitiveCategoryToJavaOI.get(primitiveCategory);
+
     if (result == null) {
       throw new RuntimeException("Internal error: Cannot find ObjectInspector "
           + " for " + primitiveCategory);
     }
+
     return result;
   }
 
   /**
-   * Returns the PrimitiveJavaObjectInspector for the PrimitiveCategory, with option to
-   * pass in parameters for the primitive type (such as char(10)).
-   * Ideally this method should be used over the method without type parameters,
-   * and the type parameters (or lack of parameters) can be determined from
-   * the input ObjectInspector, TypeInfo, or TypeEntry.
-   * However there are situations where it is not possible to get any information about
-   * type parameters, such as when getting an object inspector based on reflection from
-   * the java or primitive class.
-   * @param primitiveCategory    Primitve type category
-   * @param primitiveTypeParams  Type parameters for the primitve type.
-   *        Set to null if there are no type parameters
-   * @return
+   * Returns the PrimitiveJavaObjectInspector for the given PrimitiveTypeInfo instance,
+   * @param PrimitiveTypeInfo    PrimitiveTypeInfo instance
+   * @return AbstractPrimitiveJavaObjectInspector instance
    */
   public static AbstractPrimitiveJavaObjectInspector getPrimitiveJavaObjectInspector(
-        PrimitiveTypeSpec typeSpec) {
-    PrimitiveCategory primitiveCategory = typeSpec.getPrimitiveCategory();
-    BaseTypeParams primitiveTypeParams = typeSpec.getTypeParams();
-
-    if (primitiveTypeParams == null) {
-      // No type params, just search the unparameterized types
-      return getPrimitiveJavaObjectInspector(primitiveCategory);
-    } else {
-      // Check our cached set of parameterized object inspectors for the primitive category,
-      // or create a new object inspector if one doesn't exist yet.
-      PrimitiveObjectInspector oi =
-          cachedParameterizedPrimitiveJavaObjectInspectorCache.getObjectInspector(
-              typeSpec);
-      if (oi == null) {
-        // Do a bit of validation - not all primitive types use parameters.
-        switch (primitiveCategory) {
-          case VARCHAR:
-            PrimitiveTypeEntry typeEntry = PrimitiveObjectInspectorUtils.getTypeEntryFromTypeSpecs(
-                primitiveCategory,
-                primitiveTypeParams);
-            oi = new JavaHiveVarcharObjectInspector(typeEntry);
-            oi.setTypeParams(primitiveTypeParams);
-            cachedParameterizedPrimitiveJavaObjectInspectorCache.setObjectInspector(oi);
-            break;
-          default:
-            throw new RuntimeException(
-                "Primitve type " + primitiveCategory + " should not take parameters");
-        }
-      }
-      return (AbstractPrimitiveJavaObjectInspector)oi;
+        PrimitiveTypeInfo typeInfo) {
+    AbstractPrimitiveJavaObjectInspector result = cachedPrimitiveJavaInspectorCache.get(typeInfo);
+    if (result != null) {
+      return result;
     }
+
+    switch (typeInfo.getPrimitiveCategory()) {
+    case VARCHAR:
+      result = new JavaHiveVarcharObjectInspector((VarcharTypeInfo)typeInfo);
+      break;
+      default:
+        throw new RuntimeException("Failed to create JavaHiveVarcharObjectInspector for " + typeInfo );
+    }
+
+    cachedPrimitiveJavaInspectorCache.put(typeInfo, result);
+    return result;
   }
+
   /**
    * Returns an ObjectInspector for a primitive Class. The Class can be a Hive
    * Writable class, or a Java Primitive Class.



Mime
View raw message