hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1630512 - /hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/io/parquet/timestamp/NanoTime.java
Date Thu, 09 Oct 2014 15:42:24 GMT
Author: brock
Date: Thu Oct  9 15:42:22 2014
New Revision: 1630512

URL: http://svn.apache.org/r1630512
Log:
HIVE-8380 - NanoTime class serializes and deserializes Timestamp incorrectly (Brock reviewed
by Szehon)

Modified:
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/io/parquet/timestamp/NanoTime.java

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/io/parquet/timestamp/NanoTime.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/io/parquet/timestamp/NanoTime.java?rev=1630512&r1=1630511&r2=1630512&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/io/parquet/timestamp/NanoTime.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/io/parquet/timestamp/NanoTime.java Thu
Oct  9 15:42:22 2014
@@ -14,6 +14,7 @@
 package org.apache.hadoop.hive.ql.io.parquet.timestamp;
 
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 import parquet.Preconditions;
 import parquet.io.api.Binary;
@@ -28,7 +29,10 @@ public class NanoTime {
   public static NanoTime fromBinary(Binary bytes) {
     Preconditions.checkArgument(bytes.length() == 12, "Must be 12 bytes");
     ByteBuffer buf = bytes.toByteBuffer();
-    return new NanoTime(buf.getInt(), buf.getLong());
+    buf.order(ByteOrder.LITTLE_ENDIAN);
+    long timeOfDayNanos = buf.getLong();
+    int julianDay = buf.getInt();
+    return new NanoTime(julianDay, timeOfDayNanos);
   }
 
   public NanoTime(int julianDay, long timeOfDayNanos) {
@@ -46,8 +50,9 @@ public class NanoTime {
 
   public Binary toBinary() {
     ByteBuffer buf = ByteBuffer.allocate(12);
-    buf.putInt(julianDay);
+    buf.order(ByteOrder.LITTLE_ENDIAN);
     buf.putLong(timeOfDayNanos);
+    buf.putInt(julianDay);
     buf.flip();
     return Binary.fromByteBuffer(buf);
   }
@@ -60,4 +65,4 @@ public class NanoTime {
   public String toString() {
     return "NanoTime{julianDay="+julianDay+", timeOfDayNanos="+timeOfDayNanos+"}";
   }
-}
\ No newline at end of file
+}



Mime
View raw message