hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject [3/8] hive git commit: HIVE-14595. Addendum fixing up backport.
Date Wed, 31 May 2017 16:49:55 GMT
HIVE-14595. Addendum fixing up backport.


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/8e09edc4
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/8e09edc4
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/8e09edc4

Branch: refs/heads/branch-2.2
Commit: 8e09edc442b3a831815f78684934b51202b26ca4
Parents: b775698
Author: Owen O'Malley <omalley@apache.org>
Authored: Fri May 19 13:11:49 2017 -0700
Committer: Owen O'Malley <omalley@apache.org>
Committed: Wed May 31 09:41:32 2017 -0700

----------------------------------------------------------------------
 .../hadoop/hive/serde2/io/TimestampWritable.java   | 17 ++---------------
 .../hive/serde2/io/TestTimestampWritable.java      | 17 ++---------------
 2 files changed, 4 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/8e09edc4/serde/src/java/org/apache/hadoop/hive/serde2/io/TimestampWritable.java
----------------------------------------------------------------------
diff --git a/serde/src/java/org/apache/hadoop/hive/serde2/io/TimestampWritable.java b/serde/src/java/org/apache/hadoop/hive/serde2/io/TimestampWritable.java
index bda8a7f..463d32c 100644
--- a/serde/src/java/org/apache/hadoop/hive/serde2/io/TimestampWritable.java
+++ b/serde/src/java/org/apache/hadoop/hive/serde2/io/TimestampWritable.java
@@ -556,22 +556,9 @@ public class TimestampWritable implements WritableComparable<TimestampWritable>
   }
 
   public static void setTimestamp(Timestamp t, byte[] bytes, int offset) {
-    boolean hasDecimalOrSecondVInt = hasDecimalOrSecondVInt(bytes[offset]);
-    long seconds = (long) TimestampWritable.getSeconds(bytes, offset);
-    int nanos = 0;
-    if (hasDecimalOrSecondVInt) {
-      nanos = TimestampWritable.getNanos(bytes, offset + 4);
-      if (hasSecondVInt(bytes[offset + 4])) {
-        seconds += LazyBinaryUtils.readVLongFromByteArray(bytes,
-            offset + 4 + WritableUtils.decodeVIntSize(bytes[offset + 4]));
-      }
-    }
+    long seconds = getSeconds(bytes, offset);
     t.setTime(seconds * 1000);
-    if (hasDecimalOrSecondVInt(bytes[offset])) {
-      t.setNanos(getNanos(bytes, offset + 4));
-    } else {
-      t.setNanos(0);
-    }
+    t.setNanos(getNanos(bytes, offset + 4));
   }
 
   public static Timestamp createTimestamp(byte[] bytes, int offset) {

http://git-wip-us.apache.org/repos/asf/hive/blob/8e09edc4/serde/src/test/org/apache/hadoop/hive/serde2/io/TestTimestampWritable.java
----------------------------------------------------------------------
diff --git a/serde/src/test/org/apache/hadoop/hive/serde2/io/TestTimestampWritable.java b/serde/src/test/org/apache/hadoop/hive/serde2/io/TestTimestampWritable.java
index 3c483cc..cd7a1b9 100644
--- a/serde/src/test/org/apache/hadoop/hive/serde2/io/TestTimestampWritable.java
+++ b/serde/src/test/org/apache/hadoop/hive/serde2/io/TestTimestampWritable.java
@@ -495,21 +495,8 @@ public class TestTimestampWritable {
 
   @Test
   public void testSetTimestamp() {
-    // one VInt without nanos
-    verifySetTimestamp(1000);
-
-    // one VInt with nanos
-    verifySetTimestamp(1001);
-
-    // two VInt without nanos
-    verifySetTimestamp((long) Integer.MAX_VALUE * 1000 + 1000);
-
-    // two VInt with nanos
-    verifySetTimestamp((long) Integer.MAX_VALUE * 1000 + 1234);
-  }
-
-  private static void verifySetTimestamp(long time) {
-    Timestamp t1 = new Timestamp(time);
+    // make sure we need a 2nd VInt
+    Timestamp t1 = new Timestamp((long) Integer.MAX_VALUE * 1000 + 1234);
     TimestampWritable writable = new TimestampWritable(t1);
     byte[] bytes = writable.getBytes();
     Timestamp t2 = new Timestamp(0);


Mime
View raw message