From c33e5b29f196a7f409a993a0c489950e91747cd9 Mon Sep 17 00:00:00 2001 From: kumarvishal Date: Fri, 20 Jan 2017 21:19:36 +0800 Subject: [PATCH] Fixed Date issue when date is less the 1970 --- .../timestamp/DateDirectDictionaryGenerator.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/apache/carbondata/core/keygenerator/directdictionary/timestamp/DateDirectDictionaryGenerator.java b/core/src/main/java/org/apache/carbondata/core/keygenerator/directdictionary/timestamp/DateDirectDictionaryGenerator.java index 5572f70eba4..8db42b07789 100644 --- a/core/src/main/java/org/apache/carbondata/core/keygenerator/directdictionary/timestamp/DateDirectDictionaryGenerator.java +++ b/core/src/main/java/org/apache/carbondata/core/keygenerator/directdictionary/timestamp/DateDirectDictionaryGenerator.java @@ -35,6 +35,7 @@ */ public class DateDirectDictionaryGenerator implements DirectDictionaryGenerator { + private static final int cutOffDate = Integer.MAX_VALUE >> 1; private static final long SECONDS_PER_DAY = 60 * 60 * 24L; private static final long MILLIS_PER_DAY = SECONDS_PER_DAY * 1000L; @@ -131,7 +132,7 @@ private int getDirectSurrogateForMember(String memberStr) { if (key == 1) { return null; } - return key; + return key - cutOffDate; } private int generateDirectSurrogateKeyForNonTimestampType(String memberStr) { @@ -151,7 +152,7 @@ private int generateDirectSurrogateKeyForNonTimestampType(String memberStr) { private int generateKey(long timeValue) { long milli = timeValue + threadLocalLocalTimeZone.get().getOffset(timeValue); - int key = (int) Math.floor((double) milli / MILLIS_PER_DAY); + int key = (int) Math.floor((double) milli / MILLIS_PER_DAY) + cutOffDate; return key; }