kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liy...@apache.org
Subject [20/21] kylin git commit: KYLIN-976 bug fix
Date Fri, 04 Dec 2015 23:10:01 GMT
KYLIN-976 bug fix


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

Branch: refs/heads/2.x-staging
Commit: b0643f91cd06d5a051b021add2b6d759abbfa82c
Parents: 7f50c17
Author: Li, Yang <yangli9@ebay.com>
Authored: Fri Dec 4 18:24:06 2015 +0800
Committer: Yang Li <liyang@apache.org>
Committed: Sat Dec 5 06:55:39 2015 +0800

----------------------------------------------------------------------
 .../apache/kylin/cube/CubeCapabilityChecker.java   |  2 +-
 .../apache/kylin/measure/MeasureTypeFactory.java   |  7 +++----
 .../apache/kylin/measure/hllc/HLLCMeasureType.java | 15 +++++++++------
 .../apache/kylin/measure/topn/TopNMeasureType.java | 17 ++++++++++-------
 .../apache/kylin/metadata/datatype/DataType.java   |  4 +++-
 5 files changed, 26 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/b0643f91/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java b/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java
index 28252a3..90a3656 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java
@@ -186,7 +186,7 @@ public class CubeCapabilityChecker {
             if (unmatchedDimensions.isEmpty() && unmatchedAggregations.isEmpty())
                 break;
             
-            MeasureType measureType = measure.getFunction().getMeasureType();
+            MeasureType<?> measureType = measure.getFunction().getMeasureType();
             if (measureType instanceof BasicMeasureType)
                 continue;
             

http://git-wip-us.apache.org/repos/asf/kylin/blob/b0643f91/core-metadata/src/main/java/org/apache/kylin/measure/MeasureTypeFactory.java
----------------------------------------------------------------------
diff --git a/core-metadata/src/main/java/org/apache/kylin/measure/MeasureTypeFactory.java
b/core-metadata/src/main/java/org/apache/kylin/measure/MeasureTypeFactory.java
index 48eddb2..13cc74a 100644
--- a/core-metadata/src/main/java/org/apache/kylin/measure/MeasureTypeFactory.java
+++ b/core-metadata/src/main/java/org/apache/kylin/measure/MeasureTypeFactory.java
@@ -23,7 +23,6 @@ import java.util.Map;
 
 import org.apache.kylin.common.KylinConfig;
 import org.apache.kylin.common.util.ClassUtil;
-import org.apache.kylin.common.util.Pair;
 import org.apache.kylin.measure.basic.BasicMeasureType;
 import org.apache.kylin.measure.hllc.HLLCMeasureType;
 import org.apache.kylin.measure.topn.TopNMeasureType;
@@ -43,7 +42,7 @@ abstract public class MeasureTypeFactory<T> {
     
     // ============================================================================
     
-    private static Map<Pair<String, String>, MeasureTypeFactory<?>> factories
= Maps.newHashMap();
+    private static Map<String, MeasureTypeFactory<?>> factories = Maps.newHashMap();
     private static MeasureTypeFactory<?> defaultFactory = new BasicMeasureType.Factory();
     
     public static synchronized void init(KylinConfig config) {
@@ -69,7 +68,7 @@ abstract public class MeasureTypeFactory<T> {
             
             DataType.register(dataTypeName);
             DataTypeSerializer.register(dataTypeName, serializer);
-            factories.put(Pair.newPair(funcName, dataTypeName), factory);
+            factories.put(funcName, factory);
         }
     }
     
@@ -80,7 +79,7 @@ abstract public class MeasureTypeFactory<T> {
     public static MeasureType<?> create(String funcName, DataType dataType) {
         funcName = funcName.toUpperCase();
         
-        MeasureTypeFactory<?> factory = factories.get(Pair.newPair(funcName, dataType.getName()));
+        MeasureTypeFactory<?> factory = factories.get(funcName);
         if (factory == null)
             factory = defaultFactory;
         

http://git-wip-us.apache.org/repos/asf/kylin/blob/b0643f91/core-metadata/src/main/java/org/apache/kylin/measure/hllc/HLLCMeasureType.java
----------------------------------------------------------------------
diff --git a/core-metadata/src/main/java/org/apache/kylin/measure/hllc/HLLCMeasureType.java
b/core-metadata/src/main/java/org/apache/kylin/measure/hllc/HLLCMeasureType.java
index 073de6d..4a80d9b 100644
--- a/core-metadata/src/main/java/org/apache/kylin/measure/hllc/HLLCMeasureType.java
+++ b/core-metadata/src/main/java/org/apache/kylin/measure/hllc/HLLCMeasureType.java
@@ -36,7 +36,7 @@ public class HLLCMeasureType extends MeasureType<HyperLogLogPlusCounter>
{
 
     public static final String FUNC_COUNT_DISTINCT = "COUNT_DISTINCT";
     public static final String DATATYPE_HLLC = "hllc";
-    
+
     public static class Factory extends MeasureTypeFactory<HyperLogLogPlusCounter>
{
 
         @Override
@@ -59,7 +59,7 @@ public class HLLCMeasureType extends MeasureType<HyperLogLogPlusCounter>
{
             return HLLCSerializer.class;
         }
     }
-    
+
     // ============================================================================
 
     private final DataType dataType;
@@ -77,11 +77,14 @@ public class HLLCMeasureType extends MeasureType<HyperLogLogPlusCounter>
{
         if (FUNC_COUNT_DISTINCT.equals(funcName) == false)
             throw new IllegalArgumentException();
 
-        if (DATATYPE_HLLC.equals(dataType.getName()) == false)
-            throw new IllegalArgumentException();
+        // data type could be null at query layer, because only function and parameters are
known at that stage
+        if (dataType != null) {
+            if (DATATYPE_HLLC.equals(dataType.getName()) == false)
+                throw new IllegalArgumentException();
 
-        if (dataType.getPrecision() < 1 || dataType.getPrecision() > 5000)
-            throw new IllegalArgumentException();
+            if (dataType.getPrecision() < 1 || dataType.getPrecision() > 5000)
+                throw new IllegalArgumentException();
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/kylin/blob/b0643f91/core-metadata/src/main/java/org/apache/kylin/measure/topn/TopNMeasureType.java
----------------------------------------------------------------------
diff --git a/core-metadata/src/main/java/org/apache/kylin/measure/topn/TopNMeasureType.java
b/core-metadata/src/main/java/org/apache/kylin/measure/topn/TopNMeasureType.java
index c3d36ca..74c6d10 100644
--- a/core-metadata/src/main/java/org/apache/kylin/measure/topn/TopNMeasureType.java
+++ b/core-metadata/src/main/java/org/apache/kylin/measure/topn/TopNMeasureType.java
@@ -53,7 +53,7 @@ public class TopNMeasureType extends MeasureType<TopNCounter<ByteArray>>
{
 
     public static final String FUNC_TOP_N = "TOP_N";
     public static final String DATATYPE_TOPN = "topn";
-    
+
     public static class Factory extends MeasureTypeFactory<TopNCounter<ByteArray>>
{
 
         @Override
@@ -76,7 +76,7 @@ public class TopNMeasureType extends MeasureType<TopNCounter<ByteArray>>
{
             return TopNCounterSerializer.class;
         }
     }
-    
+
     // ============================================================================
 
     private final DataType dataType;
@@ -93,12 +93,15 @@ public class TopNMeasureType extends MeasureType<TopNCounter<ByteArray>>
{
     private void validate(String funcName, DataType dataType) {
         if (FUNC_TOP_N.equals(funcName) == false)
             throw new IllegalArgumentException();
-        
-        if (DATATYPE_TOPN.equals(dataType.getName()) == false)
-            throw new IllegalArgumentException();
 
-        if (dataType.getPrecision() < 1 || dataType.getPrecision() > 5000)
-            throw new IllegalArgumentException();
+        // data type could be null at query layer, because only function and parameters are
known at that stage
+        if (dataType != null) {
+            if (DATATYPE_TOPN.equals(dataType.getName()) == false)
+                throw new IllegalArgumentException();
+
+            if (dataType.getPrecision() < 1 || dataType.getPrecision() > 5000)
+                throw new IllegalArgumentException();
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/kylin/blob/b0643f91/core-metadata/src/main/java/org/apache/kylin/metadata/datatype/DataType.java
----------------------------------------------------------------------
diff --git a/core-metadata/src/main/java/org/apache/kylin/metadata/datatype/DataType.java
b/core-metadata/src/main/java/org/apache/kylin/metadata/datatype/DataType.java
index 05e6744..f5231e5 100644
--- a/core-metadata/src/main/java/org/apache/kylin/metadata/datatype/DataType.java
+++ b/core-metadata/src/main/java/org/apache/kylin/metadata/datatype/DataType.java
@@ -30,6 +30,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.kylin.metadata.model.TblColRef.InnerDataTypeEnum;
 
 /**
  */
@@ -58,7 +59,8 @@ public class DataType implements Serializable {
                 "boolean", "byte", "binary", //
                 "int", "short", "long", "integer", "tinyint", "smallint", "bigint", //
                 "float", "real", "double", "decimal", "numeric", //
-                "date", "time", "datetime", "timestamp");
+                "date", "time", "datetime", "timestamp", //
+                InnerDataTypeEnum.LITERAL.getDataType(), InnerDataTypeEnum.DERIVED.getDataType());
     }
 
     public static final Set<String> INTEGER_FAMILY = new HashSet<String>();


Mime
View raw message