hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1667850 [4/4] - in /hive/trunk: common/src/java/org/apache/hadoop/hive/common/type/ common/src/java/org/apache/hive/common/util/ common/src/test/org/apache/hadoop/hive/common/type/ common/src/test/org/apache/hive/common/util/ ql/src/java/o...
Date Thu, 19 Mar 2015 19:05:29 GMT
Added: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryHiveIntervalYearMonth.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryHiveIntervalYearMonth.java?rev=1667850&view=auto
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryHiveIntervalYearMonth.java (added)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryHiveIntervalYearMonth.java Thu Mar 19 19:05:28 2015
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.serde2.lazybinary;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable;
+import org.apache.hadoop.hive.serde2.lazy.ByteArrayRef;
+import org.apache.hadoop.hive.serde2.lazybinary.LazyBinaryUtils.VInt;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableHiveIntervalYearMonthObjectInspector;
+
+/**
+ * LazyBinaryHiveIntervalYearMonth
+ * A LazyBinaryObject that encodes a HiveIntervalYearMonth
+ */
+public class LazyBinaryHiveIntervalYearMonth extends
+    LazyBinaryPrimitive<WritableHiveIntervalYearMonthObjectInspector, HiveIntervalYearMonthWritable>{
+  static final Log LOG = LogFactory.getLog(LazyBinaryHiveIntervalYearMonth.class);
+
+  /**
+   * Reusable member for decoding integer.
+   */
+  VInt vInt = new LazyBinaryUtils.VInt();
+
+  LazyBinaryHiveIntervalYearMonth(WritableHiveIntervalYearMonthObjectInspector oi) {
+    super(oi);
+    data = new HiveIntervalYearMonthWritable();
+  }
+
+  LazyBinaryHiveIntervalYearMonth(LazyBinaryHiveIntervalYearMonth copy) {
+    super(copy);
+    data = new HiveIntervalYearMonthWritable(copy.data);
+  }
+
+  @Override
+  public void init(ByteArrayRef bytes, int start, int length) {
+    data.setFromBytes(bytes.getData(), start, length, vInt);
+  }
+}

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinarySerDe.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinarySerDe.java?rev=1667850&r1=1667849&r2=1667850&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinarySerDe.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinarySerDe.java Thu Mar 19 19:05:28 2015
@@ -36,6 +36,8 @@ import org.apache.hadoop.hive.serde2.Ser
 import org.apache.hadoop.hive.serde2.SerDeStats;
 import org.apache.hadoop.hive.serde2.io.DateWritable;
 import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable;
 import org.apache.hadoop.hive.serde2.io.TimestampWritable;
 import org.apache.hadoop.hive.serde2.lazy.ByteArrayRef;
 import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector;
@@ -54,6 +56,8 @@ import org.apache.hadoop.hive.serde2.obj
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.FloatObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.HiveCharObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.HiveDecimalObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.HiveIntervalDayTimeObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.HiveIntervalYearMonthObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.HiveVarcharObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.IntObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.LongObjectInspector;
@@ -428,6 +432,20 @@ public class LazyBinarySerDe extends Abs
         return;
       }
 
+      case INTERVAL_YEAR_MONTH: {
+        HiveIntervalYearMonthWritable intervalYearMonth =
+            ((HiveIntervalYearMonthObjectInspector) poi).getPrimitiveWritableObject(obj);
+        intervalYearMonth.writeToByteStream(byteStream);
+        return;
+      }
+
+      case INTERVAL_DAY_TIME: {
+        HiveIntervalDayTimeWritable intervalDayTime =
+            ((HiveIntervalDayTimeObjectInspector) poi).getPrimitiveWritableObject(obj);
+        intervalDayTime.writeToByteStream(byteStream);
+        return;
+      }
+
       case DECIMAL: {
         HiveDecimalObjectInspector bdoi = (HiveDecimalObjectInspector) poi;
         HiveDecimalWritable t = bdoi.getPrimitiveWritableObject(obj);

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryUtils.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryUtils.java?rev=1667850&r1=1667849&r2=1667850&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryUtils.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryUtils.java Thu Mar 19 19:05:28 2015
@@ -210,6 +210,16 @@ public final class LazyBinaryUtils {
         recordInfo.elementOffset = 0;
         recordInfo.elementSize = TimestampWritable.getTotalLength(bytes, offset);
         break;
+      case INTERVAL_YEAR_MONTH:
+        recordInfo.elementOffset = 0;
+        recordInfo.elementSize = WritableUtils.decodeVIntSize(bytes[offset]);
+        break;
+      case INTERVAL_DAY_TIME:
+        recordInfo.elementOffset = 0;
+        int secondsSize = WritableUtils.decodeVIntSize(bytes[offset]);
+        int nanosSize = WritableUtils.decodeVIntSize(bytes[offset + secondsSize]);
+        recordInfo.elementSize = secondsSize + nanosSize;
+        break;
       case DECIMAL:
         // using vint instead of 4 bytes
         LazyBinaryUtils.readVInt(bytes, offset, vInt);

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=1667850&r1=1667849&r2=1667850&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 Thu Mar 19 19:05:28 2015
@@ -33,6 +33,8 @@ import org.apache.hadoop.hive.serde2.obj
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableFloatObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableHiveCharObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableHiveDecimalObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableHiveIntervalDayTimeObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableHiveIntervalYearMonthObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableHiveVarcharObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableIntObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableLongObjectInspector;
@@ -120,6 +122,14 @@ public final class ObjectInspectorConver
       return new PrimitiveObjectInspectorConverter.TimestampConverter(
           inputOI,
           (SettableTimestampObjectInspector) outputOI);
+    case INTERVAL_YEAR_MONTH:
+      return new PrimitiveObjectInspectorConverter.HiveIntervalYearMonthConverter(
+          inputOI,
+          (SettableHiveIntervalYearMonthObjectInspector) outputOI);
+    case INTERVAL_DAY_TIME:
+      return new PrimitiveObjectInspectorConverter.HiveIntervalDayTimeConverter(
+          inputOI,
+          (SettableHiveIntervalDayTimeObjectInspector) outputOI);
     case BINARY:
       return new PrimitiveObjectInspectorConverter.BinaryConverter(
           inputOI,

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=1667850&r1=1667849&r2=1667850&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 Thu Mar 19 19:05:28 2015
@@ -34,6 +34,8 @@ import org.apache.hadoop.hive.serde2.Ser
 import org.apache.hadoop.hive.serde2.io.DateWritable;
 import org.apache.hadoop.hive.serde2.io.HiveCharWritable;
 import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable;
 import org.apache.hadoop.hive.serde2.io.HiveVarcharWritable;
 import org.apache.hadoop.hive.serde2.io.TimestampWritable;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector.Category;
@@ -47,6 +49,8 @@ import org.apache.hadoop.hive.serde2.obj
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.FloatObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.HiveCharObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.HiveDecimalObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.HiveIntervalDayTimeObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.HiveIntervalYearMonthObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.HiveVarcharObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.IntObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.JavaStringObjectInspector;
@@ -60,6 +64,8 @@ import org.apache.hadoop.hive.serde2.obj
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableFloatObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableHiveCharObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableHiveDecimalObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableHiveIntervalDayTimeObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableHiveIntervalYearMonthObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableHiveVarcharObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableIntObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableLongObjectInspector;
@@ -542,6 +548,14 @@ public final class ObjectInspectorUtils
         TimestampWritable t = ((TimestampObjectInspector) poi)
             .getPrimitiveWritableObject(o);
         return t.hashCode();
+      case INTERVAL_YEAR_MONTH:
+        HiveIntervalYearMonthWritable intervalYearMonth = ((HiveIntervalYearMonthObjectInspector) poi)
+            .getPrimitiveWritableObject(o);
+        return intervalYearMonth.hashCode();
+      case INTERVAL_DAY_TIME:
+        HiveIntervalDayTimeWritable intervalDayTime = ((HiveIntervalDayTimeObjectInspector) poi)
+            .getPrimitiveWritableObject(o);
+        return intervalDayTime.hashCode();
       case DECIMAL:
         return ((HiveDecimalObjectInspector) poi).getPrimitiveWritableObject(o).hashCode();
 
@@ -758,6 +772,20 @@ public final class ObjectInspectorUtils
             .getPrimitiveWritableObject(o2);
         return t1.compareTo(t2);
       }
+      case INTERVAL_YEAR_MONTH: {
+        HiveIntervalYearMonthWritable i1 = ((HiveIntervalYearMonthObjectInspector) poi1)
+            .getPrimitiveWritableObject(o1);
+        HiveIntervalYearMonthWritable i2 = ((HiveIntervalYearMonthObjectInspector) poi2)
+            .getPrimitiveWritableObject(o2);
+        return i1.compareTo(i2);
+      }
+      case INTERVAL_DAY_TIME: {
+        HiveIntervalDayTimeWritable i1 = ((HiveIntervalDayTimeObjectInspector) poi1)
+            .getPrimitiveWritableObject(o1);
+        HiveIntervalDayTimeWritable i2 = ((HiveIntervalDayTimeObjectInspector) poi2)
+            .getPrimitiveWritableObject(o2);
+        return i1.compareTo(i2);
+      }
       case DECIMAL: {
         HiveDecimalWritable t1 = ((HiveDecimalObjectInspector) poi1)
             .getPrimitiveWritableObject(o1);
@@ -1092,6 +1120,10 @@ public final class ObjectInspectorUtils
       return oi instanceof SettableDateObjectInspector;
     case TIMESTAMP:
       return oi instanceof SettableTimestampObjectInspector;
+    case INTERVAL_YEAR_MONTH:
+      return oi instanceof SettableHiveIntervalYearMonthObjectInspector;
+    case INTERVAL_DAY_TIME:
+      return oi instanceof SettableHiveIntervalDayTimeObjectInspector;
     case BINARY:
       return oi instanceof SettableBinaryObjectInspector;
     case DECIMAL:

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=1667850&r1=1667849&r2=1667850&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 Thu Mar 19 19:05:28 2015
@@ -31,7 +31,8 @@ public interface PrimitiveObjectInspecto
    */
   public static enum PrimitiveCategory {
     VOID, BOOLEAN, BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, STRING,
-    DATE, TIMESTAMP, BINARY, DECIMAL, VARCHAR, CHAR, UNKNOWN
+    DATE, TIMESTAMP, BINARY, DECIMAL, VARCHAR, CHAR, INTERVAL_YEAR_MONTH, INTERVAL_DAY_TIME,
+    UNKNOWN
   };
 
   public PrimitiveTypeInfo getTypeInfo();

Added: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/HiveIntervalDayTimeObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/HiveIntervalDayTimeObjectInspector.java?rev=1667850&view=auto
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/HiveIntervalDayTimeObjectInspector.java (added)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/HiveIntervalDayTimeObjectInspector.java Thu Mar 19 19:05:28 2015
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.common.type.HiveIntervalDayTime;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable;
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
+
+/**
+ * A HiveIntervalObjectInspector inspects an Object representing an Interval.
+ */
+public interface HiveIntervalDayTimeObjectInspector extends PrimitiveObjectInspector {
+
+  HiveIntervalDayTimeWritable getPrimitiveWritableObject(Object o);
+
+  HiveIntervalDayTime getPrimitiveJavaObject(Object o);
+}

Added: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/HiveIntervalYearMonthObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/HiveIntervalYearMonthObjectInspector.java?rev=1667850&view=auto
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/HiveIntervalYearMonthObjectInspector.java (added)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/HiveIntervalYearMonthObjectInspector.java Thu Mar 19 19:05:28 2015
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.common.type.HiveIntervalYearMonth;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable;
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
+
+/**
+ * A HiveIntervalObjectInspector inspects an Object representing a year-month Interval.
+ */
+public interface HiveIntervalYearMonthObjectInspector extends PrimitiveObjectInspector {
+
+  HiveIntervalYearMonthWritable getPrimitiveWritableObject(Object o);
+
+  HiveIntervalYearMonth getPrimitiveJavaObject(Object o);
+}

Added: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaHiveIntervalDayTimeObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaHiveIntervalDayTimeObjectInspector.java?rev=1667850&view=auto
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaHiveIntervalDayTimeObjectInspector.java (added)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaHiveIntervalDayTimeObjectInspector.java Thu Mar 19 19:05:28 2015
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.common.type.HiveIntervalDayTime;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
+
+public class JavaHiveIntervalDayTimeObjectInspector
+    extends AbstractPrimitiveJavaObjectInspector
+    implements SettableHiveIntervalDayTimeObjectInspector{
+
+  public JavaHiveIntervalDayTimeObjectInspector() {
+    super(TypeInfoFactory.intervalDayTimeTypeInfo);
+  }
+
+  @Override
+  public HiveIntervalDayTime getPrimitiveJavaObject(Object o) {
+    return o == null ? null : (HiveIntervalDayTime) o;
+  }
+
+  @Override
+  public HiveIntervalDayTimeWritable getPrimitiveWritableObject(Object o) {
+    return o == null ? null : new HiveIntervalDayTimeWritable((HiveIntervalDayTime) o);
+  }
+
+  @Override
+  public Object set(Object o, HiveIntervalDayTime i) {
+    return i == null ? null : new HiveIntervalDayTime(i);
+  }
+
+  @Override
+  public Object set(Object o, HiveIntervalDayTimeWritable i) {
+    return i == null ? null : i.getHiveIntervalDayTime();
+  }
+
+  @Override
+  public Object create(HiveIntervalDayTime i) {
+    return i == null ? null : new HiveIntervalDayTime(i);
+  }
+}

Added: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaHiveIntervalYearMonthObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaHiveIntervalYearMonthObjectInspector.java?rev=1667850&view=auto
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaHiveIntervalYearMonthObjectInspector.java (added)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaHiveIntervalYearMonthObjectInspector.java Thu Mar 19 19:05:28 2015
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.common.type.HiveIntervalYearMonth;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
+
+public class JavaHiveIntervalYearMonthObjectInspector
+    extends AbstractPrimitiveJavaObjectInspector
+    implements SettableHiveIntervalYearMonthObjectInspector{
+
+  public JavaHiveIntervalYearMonthObjectInspector() {
+    super(TypeInfoFactory.intervalYearMonthTypeInfo);
+  }
+
+  @Override
+  public HiveIntervalYearMonth getPrimitiveJavaObject(Object o) {
+    return o == null ? null : (HiveIntervalYearMonth) o;
+  }
+
+  @Override
+  public HiveIntervalYearMonthWritable getPrimitiveWritableObject(Object o) {
+    return o == null ? null : new HiveIntervalYearMonthWritable((HiveIntervalYearMonth) o);
+  }
+
+  @Override
+  public Object set(Object o, HiveIntervalYearMonth i) {
+    return i == null ? null : new HiveIntervalYearMonth(i);
+  }
+
+  @Override
+  public Object set(Object o, HiveIntervalYearMonthWritable i) {
+    return i == null ? null : i.getHiveIntervalYearMonth();
+  }
+
+  @Override
+  public Object create(HiveIntervalYearMonth i) {
+    return i == null ? null : new HiveIntervalYearMonth(i);
+  }
+}

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=1667850&r1=1667849&r2=1667850&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 Thu Mar 19 19:05:28 2015
@@ -23,6 +23,8 @@ import java.sql.Timestamp;
 
 import org.apache.hadoop.hive.common.type.HiveChar;
 import org.apache.hadoop.hive.common.type.HiveDecimal;
+import org.apache.hadoop.hive.common.type.HiveIntervalYearMonth;
+import org.apache.hadoop.hive.common.type.HiveIntervalDayTime;
 import org.apache.hadoop.hive.common.type.HiveVarchar;
 import org.apache.hadoop.hive.serde2.ByteStream;
 import org.apache.hadoop.hive.serde2.io.HiveCharWritable;
@@ -285,6 +287,46 @@ public class PrimitiveObjectInspectorCon
     }
   }
 
+  public static class HiveIntervalYearMonthConverter implements Converter {
+    PrimitiveObjectInspector inputOI;
+    SettableHiveIntervalYearMonthObjectInspector outputOI;
+    Object r;
+
+    public HiveIntervalYearMonthConverter(PrimitiveObjectInspector inputOI,
+        SettableHiveIntervalYearMonthObjectInspector outputOI) {
+      this.inputOI = inputOI;
+      this.outputOI = outputOI;
+      r = outputOI.create(new HiveIntervalYearMonth());
+    }
+
+    public Object convert(Object input) {
+      if (input == null) {
+        return null;
+      }
+      return outputOI.set(r, PrimitiveObjectInspectorUtils.getHiveIntervalYearMonth(input, inputOI));
+    }
+  }
+
+  public static class HiveIntervalDayTimeConverter implements Converter {
+    PrimitiveObjectInspector inputOI;
+    SettableHiveIntervalDayTimeObjectInspector outputOI;
+    Object r;
+
+    public HiveIntervalDayTimeConverter(PrimitiveObjectInspector inputOI,
+        SettableHiveIntervalDayTimeObjectInspector outputOI) {
+      this.inputOI = inputOI;
+      this.outputOI = outputOI;
+      r = outputOI.create(new HiveIntervalDayTime());
+    }
+
+    public Object convert(Object input) {
+      if (input == null) {
+        return null;
+      }
+      return outputOI.set(r, PrimitiveObjectInspectorUtils.getHiveIntervalDayTime(input, inputOI));
+    }
+  }
+
   public static class HiveDecimalConverter implements Converter {
 
     PrimitiveObjectInspector inputOI;
@@ -419,6 +461,14 @@ public class PrimitiveObjectInspectorCon
         t.set(((TimestampObjectInspector) inputOI)
             .getPrimitiveWritableObject(input).toString());
         return t;
+      case INTERVAL_YEAR_MONTH:
+        t.set(((HiveIntervalYearMonthObjectInspector) inputOI)
+            .getPrimitiveWritableObject(input).toString());
+        return t;
+      case INTERVAL_DAY_TIME:
+        t.set(((HiveIntervalDayTimeObjectInspector) inputOI)
+            .getPrimitiveWritableObject(input).toString());
+        return t;
       case BINARY:
         BinaryObjectInspector binaryOI = (BinaryObjectInspector) inputOI;
         if (binaryOI.preferWritable()) {

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=1667850&r1=1667849&r2=1667850&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 Thu Mar 19 19:05:28 2015
@@ -28,6 +28,8 @@ import org.apache.hadoop.hive.serde2.io.
 import org.apache.hadoop.hive.serde2.io.DoubleWritable;
 import org.apache.hadoop.hive.serde2.io.HiveCharWritable;
 import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable;
 import org.apache.hadoop.hive.serde2.io.HiveVarcharWritable;
 import org.apache.hadoop.hive.serde2.io.ShortWritable;
 import org.apache.hadoop.hive.serde2.io.TimestampWritable;
@@ -85,6 +87,10 @@ public final class PrimitiveObjectInspec
       new WritableDateObjectInspector();
   public static final WritableTimestampObjectInspector writableTimestampObjectInspector =
       new WritableTimestampObjectInspector();
+  public static final WritableHiveIntervalYearMonthObjectInspector writableHiveIntervalYearMonthObjectInspector =
+      new WritableHiveIntervalYearMonthObjectInspector();
+  public static final WritableHiveIntervalDayTimeObjectInspector writableHiveIntervalDayTimeObjectInspector =
+      new WritableHiveIntervalDayTimeObjectInspector();
   public static final WritableBinaryObjectInspector writableBinaryObjectInspector =
       new WritableBinaryObjectInspector();
   public static final WritableHiveDecimalObjectInspector writableHiveDecimalObjectInspector =
@@ -118,6 +124,10 @@ public final class PrimitiveObjectInspec
         writableDateObjectInspector);
     cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.TIMESTAMP_TYPE_NAME),
         writableTimestampObjectInspector);
+    cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.INTERVAL_YEAR_MONTH_TYPE_NAME),
+        writableHiveIntervalYearMonthObjectInspector);
+    cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.INTERVAL_DAY_TIME_TYPE_NAME),
+        writableHiveIntervalDayTimeObjectInspector);
     cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.BINARY_TYPE_NAME),
         writableBinaryObjectInspector);
     cachedPrimitiveWritableInspectorCache.put(TypeInfoFactory.decimalTypeInfo, writableHiveDecimalObjectInspector);
@@ -139,6 +149,8 @@ public final class PrimitiveObjectInspec
     primitiveCategoryToWritableOI.put(PrimitiveCategory.VOID, writableVoidObjectInspector);
     primitiveCategoryToWritableOI.put(PrimitiveCategory.DATE, writableDateObjectInspector);
     primitiveCategoryToWritableOI.put(PrimitiveCategory.TIMESTAMP, writableTimestampObjectInspector);
+    primitiveCategoryToWritableOI.put(PrimitiveCategory.INTERVAL_YEAR_MONTH, writableHiveIntervalYearMonthObjectInspector);
+    primitiveCategoryToWritableOI.put(PrimitiveCategory.INTERVAL_DAY_TIME, writableHiveIntervalDayTimeObjectInspector);
     primitiveCategoryToWritableOI.put(PrimitiveCategory.BINARY, writableBinaryObjectInspector);
     primitiveCategoryToWritableOI.put(PrimitiveCategory.DECIMAL, writableHiveDecimalObjectInspector);
   }
@@ -169,6 +181,10 @@ public final class PrimitiveObjectInspec
       new JavaDateObjectInspector();
   public static final JavaTimestampObjectInspector javaTimestampObjectInspector =
       new JavaTimestampObjectInspector();
+  public static final JavaHiveIntervalYearMonthObjectInspector javaHiveIntervalYearMonthObjectInspector =
+      new JavaHiveIntervalYearMonthObjectInspector();
+  public static final JavaHiveIntervalDayTimeObjectInspector javaHiveIntervalDayTimeObjectInspector =
+      new JavaHiveIntervalDayTimeObjectInspector();
   public static final JavaBinaryObjectInspector javaByteArrayObjectInspector =
       new JavaBinaryObjectInspector();
   public static final JavaHiveDecimalObjectInspector javaHiveDecimalObjectInspector =
@@ -202,6 +218,10 @@ public final class PrimitiveObjectInspec
         javaDateObjectInspector);
     cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.TIMESTAMP_TYPE_NAME),
         javaTimestampObjectInspector);
+    cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.INTERVAL_YEAR_MONTH_TYPE_NAME),
+        javaHiveIntervalYearMonthObjectInspector);
+    cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.INTERVAL_DAY_TIME_TYPE_NAME),
+        javaHiveIntervalDayTimeObjectInspector);
     cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.getPrimitiveTypeInfo(serdeConstants.BINARY_TYPE_NAME),
         javaByteArrayObjectInspector);
     cachedPrimitiveJavaInspectorCache.put(TypeInfoFactory.decimalTypeInfo, javaHiveDecimalObjectInspector);
@@ -223,6 +243,8 @@ public final class PrimitiveObjectInspec
     primitiveCategoryToJavaOI.put(PrimitiveCategory.VOID, javaVoidObjectInspector);
     primitiveCategoryToJavaOI.put(PrimitiveCategory.DATE, javaDateObjectInspector);
     primitiveCategoryToJavaOI.put(PrimitiveCategory.TIMESTAMP, javaTimestampObjectInspector);
+    primitiveCategoryToJavaOI.put(PrimitiveCategory.INTERVAL_YEAR_MONTH, javaHiveIntervalYearMonthObjectInspector);
+    primitiveCategoryToJavaOI.put(PrimitiveCategory.INTERVAL_DAY_TIME, javaHiveIntervalDayTimeObjectInspector);
     primitiveCategoryToJavaOI.put(PrimitiveCategory.BINARY, javaByteArrayObjectInspector);
     primitiveCategoryToJavaOI.put(PrimitiveCategory.DECIMAL, javaHiveDecimalObjectInspector);
   }
@@ -310,6 +332,10 @@ public final class PrimitiveObjectInspec
       return new WritableConstantDateObjectInspector((DateWritable)value);
     case TIMESTAMP:
       return new WritableConstantTimestampObjectInspector((TimestampWritable)value);
+    case INTERVAL_YEAR_MONTH:
+      return new WritableConstantHiveIntervalYearMonthObjectInspector((HiveIntervalYearMonthWritable) value);
+    case INTERVAL_DAY_TIME:
+      return new WritableConstantHiveIntervalDayTimeObjectInspector((HiveIntervalDayTimeWritable) value);
     case DECIMAL:
       return new WritableConstantHiveDecimalObjectInspector((DecimalTypeInfo)typeInfo, (HiveDecimalWritable)value);
     case BINARY:

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java?rev=1667850&r1=1667849&r2=1667850&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java Thu Mar 19 19:05:28 2015
@@ -31,6 +31,8 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hive.common.type.HiveChar;
 import org.apache.hadoop.hive.common.type.HiveDecimal;
+import org.apache.hadoop.hive.common.type.HiveIntervalYearMonth;
+import org.apache.hadoop.hive.common.type.HiveIntervalDayTime;
 import org.apache.hadoop.hive.common.type.HiveVarchar;
 import org.apache.hadoop.hive.serde.serdeConstants;
 import org.apache.hadoop.hive.serde2.io.ByteWritable;
@@ -38,6 +40,8 @@ import org.apache.hadoop.hive.serde2.io.
 import org.apache.hadoop.hive.serde2.io.DoubleWritable;
 import org.apache.hadoop.hive.serde2.io.HiveCharWritable;
 import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable;
 import org.apache.hadoop.hive.serde2.io.HiveVarcharWritable;
 import org.apache.hadoop.hive.serde2.io.ShortWritable;
 import org.apache.hadoop.hive.serde2.io.TimestampWritable;
@@ -221,6 +225,12 @@ public final class PrimitiveObjectInspec
   public static final PrimitiveTypeEntry timestampTypeEntry = new PrimitiveTypeEntry(
       PrimitiveCategory.TIMESTAMP, serdeConstants.TIMESTAMP_TYPE_NAME, null,
       Timestamp.class, TimestampWritable.class);
+  public static final PrimitiveTypeEntry intervalYearMonthTypeEntry = new PrimitiveTypeEntry(
+      PrimitiveCategory.INTERVAL_YEAR_MONTH, serdeConstants.INTERVAL_YEAR_MONTH_TYPE_NAME, null,
+      HiveIntervalYearMonth.class, HiveIntervalYearMonthWritable.class);
+  public static final PrimitiveTypeEntry intervalDayTimeTypeEntry = new PrimitiveTypeEntry(
+      PrimitiveCategory.INTERVAL_DAY_TIME, serdeConstants.INTERVAL_DAY_TIME_TYPE_NAME, null,
+      HiveIntervalDayTime.class, HiveIntervalDayTimeWritable.class);
   public static final PrimitiveTypeEntry decimalTypeEntry = new PrimitiveTypeEntry(
       PrimitiveCategory.DECIMAL, serdeConstants.DECIMAL_TYPE_NAME, null,
       HiveDecimal.class, HiveDecimalWritable.class);
@@ -250,6 +260,8 @@ public final class PrimitiveObjectInspec
     registerType(shortTypeEntry);
     registerType(dateTypeEntry);
     registerType(timestampTypeEntry);
+    registerType(intervalYearMonthTypeEntry);
+    registerType(intervalDayTimeTypeEntry);
     registerType(decimalTypeEntry);
     registerType(unknownTypeEntry);
   }
@@ -426,6 +438,14 @@ public final class PrimitiveObjectInspec
       return ((TimestampObjectInspector) oi1).getPrimitiveWritableObject(o1)
           .equals(((TimestampObjectInspector) oi2).getPrimitiveWritableObject(o2));
     }
+    case INTERVAL_YEAR_MONTH: {
+      return ((HiveIntervalYearMonthObjectInspector) oi1).getPrimitiveWritableObject(o1)
+          .equals(((HiveIntervalYearMonthObjectInspector) oi2).getPrimitiveWritableObject(o2));
+    }
+    case INTERVAL_DAY_TIME: {
+      return ((HiveIntervalDayTimeObjectInspector) oi1).getPrimitiveWritableObject(o1)
+          .equals(((HiveIntervalDayTimeObjectInspector) oi2).getPrimitiveWritableObject(o2));
+    }
     case BINARY: {
       return ((BinaryObjectInspector) oi1).getPrimitiveWritableObject(o1).
           equals(((BinaryObjectInspector) oi2).getPrimitiveWritableObject(o2));
@@ -836,6 +856,12 @@ public final class PrimitiveObjectInspec
     case TIMESTAMP:
       result = ((TimestampObjectInspector) oi).getPrimitiveWritableObject(o).toString();
       break;
+    case INTERVAL_YEAR_MONTH:
+      result = ((HiveIntervalYearMonthObjectInspector) oi).getPrimitiveWritableObject(o).toString();
+      break;
+    case INTERVAL_DAY_TIME:
+      result = ((HiveIntervalDayTimeObjectInspector) oi).getPrimitiveWritableObject(o).toString();
+      break;
     case DECIMAL:
       result = ((HiveDecimalObjectInspector) oi)
           .getPrimitiveJavaObject(o).toString();
@@ -1103,6 +1129,71 @@ public final class PrimitiveObjectInspec
     return result;
   }
 
+  public static HiveIntervalYearMonth getHiveIntervalYearMonth(Object o, PrimitiveObjectInspector oi) {
+    if (o == null) {
+      return null;
+    }
+
+    HiveIntervalYearMonth result = null;
+    switch (oi.getPrimitiveCategory()) {
+      case VOID:
+        result = null;
+        break;
+      case STRING:
+      case CHAR:
+      case VARCHAR: {
+        try {
+          String val = getString(o, oi).trim();
+          result = HiveIntervalYearMonth.valueOf(val);
+        } catch (IllegalArgumentException e) {
+          result = null;
+        }
+        break;
+      }
+      case INTERVAL_YEAR_MONTH:
+        result = ((HiveIntervalYearMonthObjectInspector) oi).getPrimitiveJavaObject(o);
+        break;
+
+      default:
+        throw new RuntimeException("Cannot convert to IntervalYearMonth from: " + oi.getTypeName());
+    }
+
+    return result;
+  }
+
+
+  public static HiveIntervalDayTime getHiveIntervalDayTime(Object o, PrimitiveObjectInspector oi) {
+    if (o == null) {
+      return null;
+    }
+
+    HiveIntervalDayTime result = null;
+    switch (oi.getPrimitiveCategory()) {
+      case VOID:
+        result = null;
+        break;
+      case STRING:
+      case CHAR:
+      case VARCHAR: {
+        try {
+          String val = getString(o, oi).trim();
+          result = HiveIntervalDayTime.valueOf(val);
+        } catch (IllegalArgumentException e) {
+          result = null;
+        }
+        break;
+      }
+      case INTERVAL_DAY_TIME:
+        result = ((HiveIntervalDayTimeObjectInspector) oi).getPrimitiveJavaObject(o);
+        break;
+
+      default:
+        throw new RuntimeException("Cannot convert to IntervalDayTime from: " + oi.getTypeName());
+    }
+
+    return result;
+  }
+
   public static Class<?> getJavaPrimitiveClassFromObjectInspector(ObjectInspector oi) {
     if (oi.getCategory() != Category.PRIMITIVE) {
       return null;
@@ -1117,7 +1208,7 @@ public final class PrimitiveObjectInspec
    * Provide a general grouping for each primitive data type.
    */
   public static enum PrimitiveGrouping {
-    NUMERIC_GROUP, STRING_GROUP, BOOLEAN_GROUP, DATE_GROUP, BINARY_GROUP,
+    NUMERIC_GROUP, STRING_GROUP, BOOLEAN_GROUP, DATE_GROUP, INTERVAL_GROUP, BINARY_GROUP,
     VOID_GROUP, UNKNOWN_GROUP
   };
 
@@ -1147,6 +1238,9 @@ public final class PrimitiveObjectInspec
       case TIMESTAMP:
       case DATE:
         return PrimitiveGrouping.DATE_GROUP;
+      case INTERVAL_YEAR_MONTH:
+      case INTERVAL_DAY_TIME:
+        return PrimitiveGrouping.INTERVAL_GROUP;
       case BINARY:
         return PrimitiveGrouping.BINARY_GROUP;
       case VOID:

Added: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableHiveIntervalDayTimeObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableHiveIntervalDayTimeObjectInspector.java?rev=1667850&view=auto
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableHiveIntervalDayTimeObjectInspector.java (added)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableHiveIntervalDayTimeObjectInspector.java Thu Mar 19 19:05:28 2015
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.common.type.HiveIntervalDayTime;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable;
+
+
+/**
+ * A SettableHiveIntervalDayTimeObjectInspector can set a IntervalDayTime value to an object.
+ */
+public interface SettableHiveIntervalDayTimeObjectInspector
+    extends HiveIntervalDayTimeObjectInspector {
+  Object set(Object o, HiveIntervalDayTime i);
+
+  Object set(Object o, HiveIntervalDayTimeWritable i);
+
+  Object create(HiveIntervalDayTime i);
+}

Added: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableHiveIntervalYearMonthObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableHiveIntervalYearMonthObjectInspector.java?rev=1667850&view=auto
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableHiveIntervalYearMonthObjectInspector.java (added)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableHiveIntervalYearMonthObjectInspector.java Thu Mar 19 19:05:28 2015
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.common.type.HiveIntervalYearMonth;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable;
+
+
+/**
+ * A SettableHiveIntervalYearMonthObjectInspector can set a IntervalYearMonth value to an object.
+ */
+public interface SettableHiveIntervalYearMonthObjectInspector
+    extends HiveIntervalYearMonthObjectInspector {
+  Object set(Object o, HiveIntervalYearMonth i);
+
+  Object set(Object o, HiveIntervalYearMonthWritable i);
+
+  Object create(HiveIntervalYearMonth i);
+}

Added: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantHiveIntervalDayTimeObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantHiveIntervalDayTimeObjectInspector.java?rev=1667850&view=auto
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantHiveIntervalDayTimeObjectInspector.java (added)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantHiveIntervalDayTimeObjectInspector.java Thu Mar 19 19:05:28 2015
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable;
+import org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector;
+
+public class WritableConstantHiveIntervalDayTimeObjectInspector
+    extends WritableHiveIntervalDayTimeObjectInspector
+    implements ConstantObjectInspector {
+
+  private HiveIntervalDayTimeWritable value;
+
+  protected WritableConstantHiveIntervalDayTimeObjectInspector() {
+    super();
+  }
+
+  WritableConstantHiveIntervalDayTimeObjectInspector(HiveIntervalDayTimeWritable value) {
+    super();
+    this.value = value;
+  }
+
+  @Override
+  public Object getWritableConstantValue() {
+    return value;
+  }
+}

Added: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantHiveIntervalYearMonthObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantHiveIntervalYearMonthObjectInspector.java?rev=1667850&view=auto
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantHiveIntervalYearMonthObjectInspector.java (added)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantHiveIntervalYearMonthObjectInspector.java Thu Mar 19 19:05:28 2015
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable;
+import org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector;
+
+public class WritableConstantHiveIntervalYearMonthObjectInspector
+    extends WritableHiveIntervalYearMonthObjectInspector
+    implements ConstantObjectInspector {
+
+  private HiveIntervalYearMonthWritable value;
+
+  protected WritableConstantHiveIntervalYearMonthObjectInspector() {
+    super();
+  }
+
+  WritableConstantHiveIntervalYearMonthObjectInspector(HiveIntervalYearMonthWritable value) {
+    super();
+    this.value = value;
+  }
+
+  @Override
+  public Object getWritableConstantValue() {
+    return value;
+  }
+}

Added: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveIntervalDayTimeObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveIntervalDayTimeObjectInspector.java?rev=1667850&view=auto
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveIntervalDayTimeObjectInspector.java (added)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveIntervalDayTimeObjectInspector.java Thu Mar 19 19:05:28 2015
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.common.type.HiveIntervalDayTime;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
+
+public class WritableHiveIntervalDayTimeObjectInspector
+    extends AbstractPrimitiveWritableObjectInspector
+    implements SettableHiveIntervalDayTimeObjectInspector{
+
+  public WritableHiveIntervalDayTimeObjectInspector() {
+    super(TypeInfoFactory.intervalDayTimeTypeInfo);
+  }
+
+  @Override
+  public HiveIntervalDayTime getPrimitiveJavaObject(Object o) {
+    return o == null ? null : ((HiveIntervalDayTimeWritable) o).getHiveIntervalDayTime();
+  }
+
+  @Override
+  public HiveIntervalDayTimeWritable getPrimitiveWritableObject(Object o) {
+    return o == null ? null : (HiveIntervalDayTimeWritable) o;
+  }
+
+  @Override
+  public Object copyObject(Object o) {
+    return o == null ? null : new HiveIntervalDayTimeWritable((HiveIntervalDayTimeWritable) o);
+  }
+
+  @Override
+  public Object set(Object o, HiveIntervalDayTime i) {
+    if (i == null) {
+      return null;
+    }
+    ((HiveIntervalDayTimeWritable) o).set(i);
+    return o;
+  }
+
+  @Override
+  public Object set(Object o, HiveIntervalDayTimeWritable i) {
+    if (i == null) {
+      return null;
+    }
+    ((HiveIntervalDayTimeWritable) o).set(i);
+    return o;
+  }
+
+  @Override
+  public Object create(HiveIntervalDayTime i) {
+    return i == null ? null : new HiveIntervalDayTimeWritable(i);
+  }
+}

Added: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveIntervalYearMonthObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveIntervalYearMonthObjectInspector.java?rev=1667850&view=auto
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveIntervalYearMonthObjectInspector.java (added)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableHiveIntervalYearMonthObjectInspector.java Thu Mar 19 19:05:28 2015
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.common.type.HiveIntervalYearMonth;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
+
+public class WritableHiveIntervalYearMonthObjectInspector
+    extends AbstractPrimitiveWritableObjectInspector
+    implements SettableHiveIntervalYearMonthObjectInspector{
+
+  public WritableHiveIntervalYearMonthObjectInspector() {
+    super(TypeInfoFactory.intervalYearMonthTypeInfo);
+  }
+
+  @Override
+  public HiveIntervalYearMonth getPrimitiveJavaObject(Object o) {
+    return o == null ? null : ((HiveIntervalYearMonthWritable) o).getHiveIntervalYearMonth();
+  }
+
+  @Override
+  public HiveIntervalYearMonthWritable getPrimitiveWritableObject(Object o) {
+    return o == null ? null : (HiveIntervalYearMonthWritable) o;
+  }
+
+  @Override
+  public Object copyObject(Object o) {
+    return o == null ? null : new HiveIntervalYearMonthWritable((HiveIntervalYearMonthWritable) o);
+  }
+
+  @Override
+  public Object set(Object o, HiveIntervalYearMonth i) {
+    if (i == null) {
+      return null;
+    }
+    ((HiveIntervalYearMonthWritable) o).set(i);
+    return o;
+  }
+
+  @Override
+  public Object set(Object o, HiveIntervalYearMonthWritable i) {
+    if (i == null) {
+      return null;
+    }
+    ((HiveIntervalYearMonthWritable) o).set(i);
+    return o;
+  }
+
+  @Override
+  public Object create(HiveIntervalYearMonth i) {
+    return i == null ? null : new HiveIntervalYearMonthWritable(i);
+  }
+}

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/typeinfo/TypeInfoFactory.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/typeinfo/TypeInfoFactory.java?rev=1667850&r1=1667849&r2=1667850&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/typeinfo/TypeInfoFactory.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/typeinfo/TypeInfoFactory.java Thu Mar 19 19:05:28 2015
@@ -59,6 +59,8 @@ public final class TypeInfoFactory {
   public static final PrimitiveTypeInfo shortTypeInfo = new PrimitiveTypeInfo(serdeConstants.SMALLINT_TYPE_NAME);
   public static final PrimitiveTypeInfo dateTypeInfo = new PrimitiveTypeInfo(serdeConstants.DATE_TYPE_NAME);
   public static final PrimitiveTypeInfo timestampTypeInfo = new PrimitiveTypeInfo(serdeConstants.TIMESTAMP_TYPE_NAME);
+  public static final PrimitiveTypeInfo intervalYearMonthTypeInfo = new PrimitiveTypeInfo(serdeConstants.INTERVAL_YEAR_MONTH_TYPE_NAME);
+  public static final PrimitiveTypeInfo intervalDayTimeTypeInfo = new PrimitiveTypeInfo(serdeConstants.INTERVAL_DAY_TIME_TYPE_NAME);
   public static final PrimitiveTypeInfo binaryTypeInfo = new PrimitiveTypeInfo(serdeConstants.BINARY_TYPE_NAME);
 
   /**
@@ -87,6 +89,8 @@ public final class TypeInfoFactory {
     cachedPrimitiveTypeInfo.put(serdeConstants.SMALLINT_TYPE_NAME, shortTypeInfo);
     cachedPrimitiveTypeInfo.put(serdeConstants.DATE_TYPE_NAME, dateTypeInfo);
     cachedPrimitiveTypeInfo.put(serdeConstants.TIMESTAMP_TYPE_NAME, timestampTypeInfo);
+    cachedPrimitiveTypeInfo.put(serdeConstants.INTERVAL_YEAR_MONTH_TYPE_NAME, intervalYearMonthTypeInfo);
+    cachedPrimitiveTypeInfo.put(serdeConstants.INTERVAL_DAY_TIME_TYPE_NAME, intervalDayTimeTypeInfo);
     cachedPrimitiveTypeInfo.put(serdeConstants.BINARY_TYPE_NAME, binaryTypeInfo);
     cachedPrimitiveTypeInfo.put(decimalTypeInfo.getQualifiedName(), decimalTypeInfo);
     cachedPrimitiveTypeInfo.put("unknown", unknownTypeInfo);

Added: hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveIntervalDayTimeWritable.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveIntervalDayTimeWritable.java?rev=1667850&view=auto
==============================================================================
--- hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveIntervalDayTimeWritable.java (added)
+++ hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveIntervalDayTimeWritable.java Thu Mar 19 19:05:28 2015
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.serde2.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutput;
+import java.io.DataOutputStream;
+
+import com.google.code.tempusfugit.concurrency.annotations.*;
+import com.google.code.tempusfugit.concurrency.*;
+
+import org.apache.hadoop.hive.common.type.HiveIntervalDayTime;
+import org.junit.*;
+
+import static org.junit.Assert.*;
+
+public class TestHiveIntervalDayTimeWritable {
+  @Rule public ConcurrentRule concurrentRule = new ConcurrentRule();
+  @Rule public RepeatingRule repeatingRule = new RepeatingRule();
+
+  @Test
+  @Concurrent(count=4)
+  @Repeating(repetition=100)
+  public void testConstructor() throws Exception {
+    HiveIntervalDayTime hi1 = HiveIntervalDayTime.valueOf("3 4:5:6.12345");
+    HiveIntervalDayTimeWritable hiw1 = new HiveIntervalDayTimeWritable(hi1);
+    HiveIntervalDayTimeWritable hiw2 = new HiveIntervalDayTimeWritable(hiw1);
+    assertEquals(hiw1, hiw2);
+  }
+
+  @Test
+  @Concurrent(count=4)
+  @Repeating(repetition=100)
+  public void testComparison() throws Exception {
+    HiveIntervalDayTimeWritable hiw0 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 2:2:2.22222"));
+    HiveIntervalDayTimeWritable hiw1 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 2:2:2.22222"));
+    HiveIntervalDayTimeWritable hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("3 2:2:2.22222"));
+
+    assertTrue(hiw1 + " equals " + hiw1, hiw1.equals(hiw1));
+    assertTrue(hiw1 + " equals " + hiw0, hiw1.equals(hiw0));
+    assertFalse(hiw1 + " equals " + hiw2, hiw1.equals(hiw2));
+
+    assertTrue(hiw1 + " compare " + hiw1, 0 ==  hiw1.compareTo(hiw1));
+    assertTrue(hiw1 + " compare " + hiw0, 0 ==  hiw1.compareTo(hiw0));
+    assertTrue(hiw1 + " compare " + hiw2, 0 > hiw1.compareTo(hiw2));
+
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("3 2:2:2.22222"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 > hiw1.compareTo(hiw2));
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("1 2:2:2.22222"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 < hiw1.compareTo(hiw2));
+
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 3:2:2.22222"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 > hiw1.compareTo(hiw2));
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 1:2:2.22222"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 < hiw1.compareTo(hiw2));
+
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 2:3:2.22222"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 > hiw1.compareTo(hiw2));
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 2:1:2.22222"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 < hiw1.compareTo(hiw2));
+
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 2:2:3.22222"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 > hiw1.compareTo(hiw2));
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 2:2:1.22222"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 < hiw1.compareTo(hiw2));
+
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 2:2:2.33333"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 > hiw1.compareTo(hiw2));
+    hiw2 = new HiveIntervalDayTimeWritable(
+        HiveIntervalDayTime.valueOf("2 2:2:2.11111"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 < hiw1.compareTo(hiw2));
+
+    // Also check hashCode()
+    assertEquals(hiw0.hashCode(), hiw1.hashCode());
+  }
+
+  @Test
+  @Concurrent(count=4)
+  @Repeating(repetition=100)
+  public void testGettersSetters() throws Exception {
+    HiveIntervalDayTimeWritable hiw1 = new HiveIntervalDayTimeWritable();
+
+    hiw1.set(3, 4, 5, 6, 7);
+
+    HiveIntervalDayTime hi1 = hiw1.getHiveIntervalDayTime();
+    assertEquals(3, hi1.getDays());
+    assertEquals(4, hi1.getHours());
+    assertEquals(5, hi1.getMinutes());
+    assertEquals(6, hi1.getSeconds());
+    assertEquals(7, hi1.getNanos());
+  }
+
+  @Test
+  @Concurrent(count=4)
+  @Repeating(repetition=100)
+  public void testWritableMethods() throws Exception {
+    HiveIntervalDayTimeWritable hiw1 = new HiveIntervalDayTimeWritable();
+    HiveIntervalDayTimeWritable hiw2 = new HiveIntervalDayTimeWritable();
+
+    hiw1.set(3, 4, 5, 6, 7);
+    hiw2.set(5, 4, 3, 2, 1);
+    assertFalse(hiw1.equals(hiw2));
+
+    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+    DataOutput out = new DataOutputStream(byteStream);
+
+    hiw1.write(out);
+    hiw2.readFields(new DataInputStream(new ByteArrayInputStream(byteStream.toByteArray())));
+    assertEquals(hiw1, hiw2);
+  }
+}

Added: hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveIntervalYearMonthWritable.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveIntervalYearMonthWritable.java?rev=1667850&view=auto
==============================================================================
--- hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveIntervalYearMonthWritable.java (added)
+++ hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveIntervalYearMonthWritable.java Thu Mar 19 19:05:28 2015
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.serde2.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutput;
+import java.io.DataOutputStream;
+
+import com.google.code.tempusfugit.concurrency.annotations.*;
+import com.google.code.tempusfugit.concurrency.*;
+
+import org.apache.hadoop.hive.common.type.HiveIntervalYearMonth;
+import org.junit.*;
+
+import static org.junit.Assert.*;
+
+public class TestHiveIntervalYearMonthWritable {
+  @Rule public ConcurrentRule concurrentRule = new ConcurrentRule();
+  @Rule public RepeatingRule repeatingRule = new RepeatingRule();
+
+  @Test
+  @Concurrent(count=4)
+  @Repeating(repetition=100)
+  public void testConstructor() throws Exception {
+    HiveIntervalYearMonth hi1 = HiveIntervalYearMonth.valueOf("1-2");
+    HiveIntervalYearMonthWritable hiw1 = new HiveIntervalYearMonthWritable(hi1);
+    HiveIntervalYearMonthWritable hiw2 = new HiveIntervalYearMonthWritable(hiw1);
+    assertEquals(hiw1, hiw2);
+  }
+
+  @Test
+  @Concurrent(count=4)
+  @Repeating(repetition=100)
+  public void testComparison() throws Exception {
+    HiveIntervalYearMonthWritable hiw0 = new HiveIntervalYearMonthWritable(
+        HiveIntervalYearMonth.valueOf("2-2"));
+    HiveIntervalYearMonthWritable hiw1 = new HiveIntervalYearMonthWritable(
+        HiveIntervalYearMonth.valueOf("2-2"));
+    HiveIntervalYearMonthWritable hiw2 = new HiveIntervalYearMonthWritable(
+        HiveIntervalYearMonth.valueOf("3-2"));
+
+    assertTrue(hiw1 + " equals " + hiw1, hiw1.equals(hiw1));
+    assertTrue(hiw1 + " equals " + hiw0, hiw1.equals(hiw0));
+    assertFalse(hiw1 + " equals " + hiw2, hiw1.equals(hiw2));
+
+    assertTrue(hiw1 + " compare " + hiw1, 0 ==  hiw1.compareTo(hiw1));
+    assertTrue(hiw1 + " compare " + hiw0, 0 ==  hiw1.compareTo(hiw0));
+    assertTrue(hiw1 + " compare " + hiw2, 0 > hiw1.compareTo(hiw2));
+    hiw2 = new HiveIntervalYearMonthWritable(
+        HiveIntervalYearMonth.valueOf("1-2"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 < hiw1.compareTo(hiw2));
+
+    hiw2 = new HiveIntervalYearMonthWritable(
+        HiveIntervalYearMonth.valueOf("2-3"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 > hiw1.compareTo(hiw2));
+    hiw2 = new HiveIntervalYearMonthWritable(
+        HiveIntervalYearMonth.valueOf("2-1"));
+    assertTrue(hiw1 + " compare " + hiw2, 0 < hiw1.compareTo(hiw2));
+
+    // Also check hashCode()
+    assertEquals(hiw0.hashCode(), hiw1.hashCode());
+  }
+
+  @Test
+  @Concurrent(count=4)
+  @Repeating(repetition=100)
+  public void testGettersSetters() throws Exception {
+    HiveIntervalYearMonthWritable hiw1 = new HiveIntervalYearMonthWritable();
+
+    hiw1.set(1, 2);
+    HiveIntervalYearMonth hi1 = hiw1.getHiveIntervalYearMonth();
+    assertEquals(1, hi1.getYears());
+    assertEquals(2, hi1.getMonths());
+
+    hiw1.set(new HiveIntervalYearMonth(3,4));
+    hi1 = hiw1.getHiveIntervalYearMonth();
+    assertEquals(3, hi1.getYears());
+    assertEquals(4, hi1.getMonths());
+
+    hiw1.set(new HiveIntervalYearMonthWritable(new HiveIntervalYearMonth(5,6)));
+    hi1 = hiw1.getHiveIntervalYearMonth();
+    assertEquals(5, hi1.getYears());
+    assertEquals(6, hi1.getMonths());
+  }
+
+  @Test
+  @Concurrent(count=4)
+  @Repeating(repetition=100)
+  public void testWritableMethods() throws Exception {
+    HiveIntervalYearMonthWritable hiw1 = new HiveIntervalYearMonthWritable();
+    HiveIntervalYearMonthWritable hiw2 = new HiveIntervalYearMonthWritable();
+
+    hiw1.set(1, 2);
+    hiw2.set(7, 6);
+    assertFalse(hiw1.equals(hiw2));
+
+    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+    DataOutput out = new DataOutputStream(byteStream);
+
+    hiw1.write(out);
+    hiw2.readFields(new DataInputStream(new ByteArrayInputStream(byteStream.toByteArray())));
+    assertEquals(hiw1, hiw2);
+  }
+}



Mime
View raw message