You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by om...@apache.org on 2017/05/19 20:12:39 UTC
hive git commit: HIVE-14595. Addendum fixing up backport.
Repository: hive
Updated Branches:
refs/heads/branch-2.2 b9eee0bbd -> f7280d02f
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/f7280d02
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/f7280d02
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/f7280d02
Branch: refs/heads/branch-2.2
Commit: f7280d02f70be9a2c2859d96412496c053467ce5
Parents: b9eee0b
Author: Owen O'Malley <om...@apache.org>
Authored: Fri May 19 13:11:49 2017 -0700
Committer: Owen O'Malley <om...@apache.org>
Committed: Fri May 19 13:11:49 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/f7280d02/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/f7280d02/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);