hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1526603 - in /hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2: lazy/objectinspector/primitive/ objectinspector/primitive/
Date Thu, 26 Sep 2013 16:56:12 GMT
Author: hashutosh
Date: Thu Sep 26 16:56:12 2013
New Revision: 1526603

URL: http://svn.apache.org/r1526603
Log:
HIVE-5366 : Refactor a few object inspector class to eliminate redundant information (Xuefu
Zhang via Ashutosh Chauhan)

Modified:
    hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyHiveVarcharObjectInspector.java
    hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveObjectInspector.java
    hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaHiveVarcharObjectInspector.java
    hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveVarcharObjectInspector.java

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyHiveVarcharObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyHiveVarcharObjectInspector.java?rev=1526603&r1=1526602&r2=1526603&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyHiveVarcharObjectInspector.java
(original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyHiveVarcharObjectInspector.java
Thu Sep 26 16:56:12 2013
@@ -22,11 +22,9 @@ import org.apache.hadoop.hive.common.typ
 import org.apache.hadoop.hive.serde2.io.HiveVarcharWritable;
 import org.apache.hadoop.hive.serde2.lazy.LazyHiveVarchar;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.HiveVarcharObjectInspector;
-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.VarcharTypeParams;
 import org.apache.hadoop.hive.serde2.typeinfo.ParameterizedPrimitiveTypeUtils;
+import org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeParams;
 
 public class LazyHiveVarcharObjectInspector
     extends AbstractPrimitiveLazyObjectInspector<HiveVarcharWritable>
@@ -62,14 +60,16 @@ public class LazyHiveVarcharObjectInspec
     }
 
     HiveVarchar ret = ((LazyHiveVarchar) o).getWritableObject().getHiveVarchar();
+    VarcharTypeParams typeParams = (VarcharTypeParams)getTypeParams();
     if (!ParameterizedPrimitiveTypeUtils.doesPrimitiveMatchTypeParams(
-        ret, (VarcharTypeParams) typeParams)) {
-      HiveVarchar newValue = new HiveVarchar(ret, ((VarcharTypeParams) typeParams).length);
+        ret, typeParams)) {
+      HiveVarchar newValue = new HiveVarchar(ret, typeParams.length);
       return newValue;
     }
     return ret;
   }
 
+  @Override
   public String toString() {
     return getTypeName();
   }

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=1526603&r1=1526602&r2=1526603&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
Thu Sep 26 16:56:12 2013
@@ -29,7 +29,6 @@ public abstract class AbstractPrimitiveO
     PrimitiveObjectInspector {
 
   protected PrimitiveTypeEntry typeEntry;
-  protected BaseTypeParams typeParams;
 
   protected AbstractPrimitiveObjectInspector() {
     super();
@@ -85,14 +84,15 @@ public abstract class AbstractPrimitiveO
   }
 
   public BaseTypeParams getTypeParams() {
-    return typeParams;
+    return typeEntry.typeParams;
   }
 
   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());
     }
-    this.typeParams = newParams;
+    typeEntry.typeParams = newParams;
   }
 }

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=1526603&r1=1526602&r2=1526603&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
Thu Sep 26 16:56:12 2013
@@ -18,11 +18,8 @@
 package org.apache.hadoop.hive.serde2.objectinspector.primitive;
 
 import org.apache.hadoop.hive.common.type.HiveVarchar;
-import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.serde2.io.HiveVarcharWritable;
-import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory;
 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.ParameterizedPrimitiveTypeUtils;
 import org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeParams;
 
@@ -42,13 +39,14 @@ public class JavaHiveVarcharObjectInspec
     }
   }
 
+  @Override
   public HiveVarchar getPrimitiveJavaObject(Object o) {
     if (o == null) {
       return null;
     }
     HiveVarchar value = (HiveVarchar)o;
     if (ParameterizedPrimitiveTypeUtils.doesPrimitiveMatchTypeParams(
-        value, (VarcharTypeParams) typeParams)) {
+        value, (VarcharTypeParams) getTypeParams())) {
       return value;
     }
     // value needs to be converted to match the type params (length, etc).
@@ -78,7 +76,7 @@ public class JavaHiveVarcharObjectInspec
   public Object set(Object o, HiveVarchar value) {
     HiveVarchar setValue = (HiveVarchar)o;
     if (ParameterizedPrimitiveTypeUtils.doesPrimitiveMatchTypeParams(
-        value, (VarcharTypeParams) typeParams)) {
+        value, (VarcharTypeParams) getTypeParams())) {
       setValue.setValue(value);
     } else {
       // Otherwise value may be too long, convert to appropriate value based on params
@@ -102,6 +100,7 @@ public class JavaHiveVarcharObjectInspec
   }
 
   public int getMaxLength() {
-    return typeParams != null ? ((VarcharTypeParams) typeParams).length : -1;
+    VarcharTypeParams typeParams = (VarcharTypeParams)getTypeParams();
+    return typeParams != null ? typeParams.length : -1;
   }
 }

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveVarcharObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveVarcharObjectInspector.java?rev=1526603&r1=1526602&r2=1526603&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveVarcharObjectInspector.java
(original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveVarcharObjectInspector.java
Thu Sep 26 16:56:12 2013
@@ -21,11 +21,9 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hive.common.type.HiveVarchar;
 import org.apache.hadoop.hive.serde2.io.HiveVarcharWritable;
-import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory;
 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.VarcharTypeParams;
 import org.apache.hadoop.hive.serde2.typeinfo.ParameterizedPrimitiveTypeUtils;
+import org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeParams;
 
 public class WritableHiveVarcharObjectInspector
     extends AbstractPrimitiveWritableObjectInspector
@@ -59,6 +57,7 @@ public class WritableHiveVarcharObjectIn
     return getPrimitiveWithParams(writable);
   }
 
+  @Override
   public HiveVarcharWritable getPrimitiveWritableObject(Object o) {
     // check input object's length, if it doesn't match
     // then output new writable with correct params.
@@ -87,12 +86,7 @@ public class WritableHiveVarcharObjectIn
 
   private boolean doesWritableMatchTypeParams(HiveVarcharWritable writable) {
     return ParameterizedPrimitiveTypeUtils.doesWritableMatchTypeParams(
-        writable, (VarcharTypeParams) typeParams);
-  }
-
-  private boolean doesPrimitiveMatchTypeParams(HiveVarchar value) {
-    return ParameterizedPrimitiveTypeUtils.doesPrimitiveMatchTypeParams(
-        value, (VarcharTypeParams) typeParams);
+        writable, (VarcharTypeParams)getTypeParams());
   }
 
   @Override
@@ -130,6 +124,8 @@ public class WritableHiveVarcharObjectIn
   }
 
   public int getMaxLength() {
-    return typeParams != null ? ((VarcharTypeParams) typeParams).length : -1;
+    VarcharTypeParams typeParams = (VarcharTypeParams)getTypeParams();
+    return typeParams != null ? typeParams.length : -1;
   }
+
 }



Mime
View raw message