Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 9D70C200CA8 for ; Wed, 31 May 2017 18:49:55 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 9BC38160BDB; Wed, 31 May 2017 16:49:55 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C4B73160BC2 for ; Wed, 31 May 2017 18:49:54 +0200 (CEST) Received: (qmail 91398 invoked by uid 500); 31 May 2017 16:49:53 -0000 Mailing-List: contact commits-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hive-dev@hive.apache.org Delivered-To: mailing list commits@hive.apache.org Received: (qmail 91045 invoked by uid 99); 31 May 2017 16:49:53 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 May 2017 16:49:53 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 47395DFC2E; Wed, 31 May 2017 16:49:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: omalley@apache.org To: commits@hive.apache.org Date: Wed, 31 May 2017 16:49:55 -0000 Message-Id: <388c7e670dd74382a98ddd845810af37@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [3/8] hive git commit: HIVE-14595. Addendum fixing up backport. archived-at: Wed, 31 May 2017 16:49:55 -0000 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 Authored: Fri May 19 13:11:49 2017 -0700 Committer: Owen O'Malley 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 } 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);