You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by om...@apache.org on 2019/10/22 23:33:09 UTC

[orc] branch branch-1.4 updated: Revert "ORC-546. Fix reading timestamps with duplicated millis within a second."

This is an automated email from the ASF dual-hosted git repository.

omalley pushed a commit to branch branch-1.4
in repository https://gitbox.apache.org/repos/asf/orc.git


The following commit(s) were added to refs/heads/branch-1.4 by this push:
     new bc575a3  Revert "ORC-546. Fix reading timestamps with duplicated millis within a second."
bc575a3 is described below

commit bc575a3f7cac20001cb3afaed3522968c942d1e1
Author: Owen O'Malley <om...@apache.org>
AuthorDate: Tue Oct 22 16:32:20 2019 -0700

    Revert "ORC-546. Fix reading timestamps with duplicated millis within a second."
    
    This reverts commit 37245bbfb526c978118e2f1c1dded557a7f029fd.
    
    Signed-off-by: Owen O'Malley <om...@apache.org>
---
 .../src/java/org/apache/orc/impl/TreeReaderFactory.java    |  4 ++--
 java/core/src/test/org/apache/orc/TestVectorOrcFile.java   | 14 ++++++--------
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/java/core/src/java/org/apache/orc/impl/TreeReaderFactory.java b/java/core/src/java/org/apache/orc/impl/TreeReaderFactory.java
index 2ac9fb4..08a4359 100644
--- a/java/core/src/java/org/apache/orc/impl/TreeReaderFactory.java
+++ b/java/core/src/java/org/apache/orc/impl/TreeReaderFactory.java
@@ -975,9 +975,9 @@ public class TreeReaderFactory {
 
       for (int i = 0; i < batchSize; i++) {
         if (result.noNulls || !result.isNull[i]) {
-          int newNanos = parseNanos(nanos.next());
+          final int newNanos = parseNanos(nanos.next());
           long millis = (data.next() + base_timestamp)
-              * WriterImpl.MILLIS_PER_SECOND;
+              * WriterImpl.MILLIS_PER_SECOND + newNanos / 1_000_000;
           if (millis < 0 && newNanos > 999_999) {
             millis -= WriterImpl.MILLIS_PER_SECOND;
           }
diff --git a/java/core/src/test/org/apache/orc/TestVectorOrcFile.java b/java/core/src/test/org/apache/orc/TestVectorOrcFile.java
index 5611bb0..182f969 100644
--- a/java/core/src/test/org/apache/orc/TestVectorOrcFile.java
+++ b/java/core/src/test/org/apache/orc/TestVectorOrcFile.java
@@ -67,7 +67,6 @@ import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
 import java.sql.Date;
 import java.sql.Timestamp;
-import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -1397,17 +1396,16 @@ public class TestVectorOrcFile {
     batch = reader.getSchema().createRowBatch(1000);
     TimestampColumnVector times = (TimestampColumnVector) batch.cols[0];
     LongColumnVector dates = (LongColumnVector) batch.cols[1];
-    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSS");
     for (int year = minYear; year < maxYear; ++year) {
       rows.nextBatch(batch);
       assertEquals(1000, batch.size);
       for(int row = 0; row < 1000; ++row) {
-        String expectedStr = String.format("%04d-05-05 12:34:56.%04d", year, 2*row);
-        assertEquals("row " + row, expectedStr,
-            formatter.format(times.asScratchTimestamp(row).toLocalDateTime()));
-        assertEquals(0, times.time[row] % 1000);
-        assertTrue("nano " + row + " = " + times.nanos[row],
-            times.nanos[row] >= 0 && times.nanos[row] < 1_000_000_000);
+        Timestamp expected = Timestamp.valueOf(
+            String.format("%04d-05-05 12:34:56.%04d", year, 2*row));
+        assertEquals("ms row " + row + " " + expected, expected.getTime(),
+            times.time[row]);
+        assertEquals("nanos row " + row + " " + expected, expected.getNanos(),
+            times.nanos[row]);
         assertEquals("year " + year + " row " + row,
             Integer.toString(year) + "-12-25",
             new DateWritable((int) dates.vector[row]).toString());