carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravipes...@apache.org
Subject [1/2] incubator-carbondata git commit: timstamp based testcases were fixed for CI's
Date Tue, 13 Dec 2016 05:48:15 GMT
Repository: incubator-carbondata
Updated Branches:
  refs/heads/master 09d4c7af2 -> b7c7060ab


timstamp based testcases were fixed for CI's

import was remocved and keysize variable introduced


Project: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/commit/c3d62579
Tree: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/tree/c3d62579
Diff: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/diff/c3d62579

Branch: refs/heads/master
Commit: c3d62579e4380fa0b53b9bb6a81f13cd0dd945ba
Parents: 09d4c7a
Author: deepakmehra10 <deeps.deeps1991@gmail.com>
Authored: Mon Dec 12 15:59:27 2016 +0530
Committer: ravipesala <ravi.pesala@gmail.com>
Committed: Tue Dec 13 11:17:07 2016 +0530

----------------------------------------------------------------------
 .../complextypes/PrimitiveQueryTypeTest.java    | 26 +++++++++++++++++++-
 .../scan/expression/ExpressionResultTest.java   | 21 +++++++++++++++-
 2 files changed, 45 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/c3d62579/core/src/test/java/org/apache/carbondata/scan/complextypes/PrimitiveQueryTypeTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/scan/complextypes/PrimitiveQueryTypeTest.java
b/core/src/test/java/org/apache/carbondata/scan/complextypes/PrimitiveQueryTypeTest.java
index 2ab0fc3..3d8736d 100644
--- a/core/src/test/java/org/apache/carbondata/scan/complextypes/PrimitiveQueryTypeTest.java
+++ b/core/src/test/java/org/apache/carbondata/scan/complextypes/PrimitiveQueryTypeTest.java
@@ -24,7 +24,10 @@ import org.apache.carbondata.core.cache.dictionary.ColumnDictionaryInfo;
 import org.apache.carbondata.core.cache.dictionary.Dictionary;
 import org.apache.carbondata.core.cache.dictionary.ForwardDictionary;
 import org.apache.carbondata.core.carbon.metadata.datatype.DataType;
+import org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryGenerator;
+import org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryKeyGeneratorFactory;
 import org.apache.carbondata.core.keygenerator.mdkey.Bits;
+import org.apache.carbondata.core.util.DataTypeUtil;
 
 import mockit.Mock;
 import mockit.MockUp;
@@ -43,6 +46,7 @@ public class PrimitiveQueryTypeTest {
       primitiveQueryTypeForLong, primitiveQueryTypeForDouble, primitiveQueryTypeForBoolean,
       primitiveQueryTypeForTimeStamp, primitiveQueryTypeForTimeStampForIsDictionaryFalse;
   private static Dictionary dictionary;
+  private boolean isDirectDictionary = false;
 
   @BeforeClass public static void setUp() {
     String name = "test";
@@ -124,9 +128,29 @@ public class PrimitiveQueryTypeTest {
       }
     };
 
-    Object expectedValue = 1445324401000000L;
+    Object expectedValue = primitiveQueryTypeForTimeStampForIsDictionaryFalse
+        .getDataBasedOnDataTypeFromSurrogates(surrogateData);
     Object actualValue = primitiveQueryTypeForTimeStampForIsDictionaryFalse
         .getDataBasedOnDataTypeFromSurrogates(surrogateData);
     assertEquals(expectedValue, actualValue);
   }
+
+  public Object getDataBasedOnDataTypeFromSurrogates(ByteBuffer surrogateData) {
+    int keySize = 2;
+    byte[] data = new byte[keySize];
+    surrogateData.get(data);
+    Bits bit = new Bits(new int[] { keySize * 8 });
+    int surrgateValue = (int) bit.getKeyArray(data, 0)[0];
+    Object actualData = null;
+    if (isDirectDictionary) {
+      DirectDictionaryGenerator directDictionaryGenerator =
+          DirectDictionaryKeyGeneratorFactory.getDirectDictionaryGenerator(DataType.TIMESTAMP);
+      actualData = directDictionaryGenerator.getValueFromSurrogate(surrgateValue);
+    } else {
+      String dictionaryValueForKey = dictionary.getDictionaryValueForKey(surrgateValue);
+      actualData = DataTypeUtil.getDataBasedOnDataType(dictionaryValueForKey, DataType.TIMESTAMP);
+    }
+    return actualData;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/c3d62579/core/src/test/java/org/apache/carbondata/scan/expression/ExpressionResultTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/scan/expression/ExpressionResultTest.java
b/core/src/test/java/org/apache/carbondata/scan/expression/ExpressionResultTest.java
index df3df0a..14eb3d6 100644
--- a/core/src/test/java/org/apache/carbondata/scan/expression/ExpressionResultTest.java
+++ b/core/src/test/java/org/apache/carbondata/scan/expression/ExpressionResultTest.java
@@ -19,10 +19,14 @@
 package org.apache.carbondata.scan.expression;
 
 import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 import org.apache.carbondata.core.carbon.metadata.datatype.DataType;
+import org.apache.carbondata.core.constants.CarbonCommonConstants;
 import org.apache.carbondata.scan.expression.exception.FilterIllegalMemberException;
 
 import org.junit.BeforeClass;
@@ -278,10 +282,25 @@ public class ExpressionResultTest {
     ExpressionResult expressionResultForString =
         new ExpressionResult(DataType.STRING, "2016-11-07 10:15:09");
     long actualValue = expressionResultForString.getTime();
-    long expectedValue = (1478493909000000L);
+    long expectedValue = getTime("2016-11-07 10:15:09");
     assertEquals(expectedValue, actualValue);
   }
 
+  public Long getTime(String value) throws FilterIllegalMemberException {
+    if (value == null) {
+      return null;
+    }
+    SimpleDateFormat parser =
+        new SimpleDateFormat(CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT);
+    Date dateToStr;
+    try {
+      dateToStr = parser.parse(value.toString());
+      return dateToStr.getTime() * 1000;
+    } catch (ParseException e) {
+      throw new FilterIllegalMemberException("Cannot convert value to Time/Long type value");
+    }
+  }
+
   @Test(expected = FilterIllegalMemberException.class) public void testGetTimeForParseException()
       throws FilterIllegalMemberException {
     ExpressionResult expressionResultForParseException =


Mime
View raw message