kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liy...@apache.org
Subject [28/34] incubator-kylin git commit: revert some problematic code refactors in previous commit
Date Fri, 10 Apr 2015 22:48:05 GMT
revert some problematic code refactors in previous commit


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

Branch: refs/heads/streaming-localdict
Commit: b1d787c7431616f82437d71d16be13aa2757a7c8
Parents: 7eebef6
Author: honma <honma@ebay.com>
Authored: Fri Apr 10 10:09:31 2015 +0800
Committer: honma <honma@ebay.com>
Committed: Fri Apr 10 10:09:31 2015 +0800

----------------------------------------------------------------------
 .../endpoint/EndpointAggregators.java           | 44 ++++++++++----------
 1 file changed, 21 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/b1d787c7/storage/src/main/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/EndpointAggregators.java
----------------------------------------------------------------------
diff --git a/storage/src/main/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/EndpointAggregators.java
b/storage/src/main/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/EndpointAggregators.java
index 19d8fd1..19726e2 100644
--- a/storage/src/main/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/EndpointAggregators.java
+++ b/storage/src/main/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/EndpointAggregators.java
@@ -70,36 +70,34 @@ public class EndpointAggregators {
 
     }
 
-    private static MetricInfo generateMetricInfo(int index, FunctionDesc functionDesc) {
-        if (functionDesc.isCount()) {
-            return new MetricInfo(MetricType.Count);
-        } else if (functionDesc.isDimensionAsMetric()) {
-            return new MetricInfo(MetricType.DimensionAsMetric);
-        } else {
-            Preconditions.checkState(index >= 0, "Column " + functionDesc.getParameter().getValue()
+ " is not found in II");
-            if (functionDesc.isCountDistinct()) {
-                return new MetricInfo(MetricType.DistinctCount, index, functionDesc.getReturnDataType().getPrecision());
-            } else {
-                return new MetricInfo(MetricType.Normal, index);
-            }
-        }
-    }
-
-
     public static EndpointAggregators fromFunctions(TableRecordInfo tableInfo, List<FunctionDesc>
metrics) {
-        final int metricSize = metrics.size();
-        String[] funcNames = new String[metricSize];
-        String[] dataTypes = new String[metricSize];
-        MetricInfo[] metricInfos = new MetricInfo[metricSize];
+        String[] funcNames = new String[metrics.size()];
+        String[] dataTypes = new String[metrics.size()];
+        MetricInfo[] metricInfos = new MetricInfo[metrics.size()];
 
-        for (int i = 0; i < metricSize; i++) {
+        for (int i = 0; i < metrics.size(); i++) {
             FunctionDesc functionDesc = metrics.get(i);
 
             //TODO: what if funcionDesc's type is different from tablDesc? cause scale difference
             funcNames[i] = functionDesc.getExpression();
             dataTypes[i] = functionDesc.getReturnType();
-            int index = tableInfo.findFactTableColumn(functionDesc.getParameter().getValue());
-            metricInfos[i] = generateMetricInfo(index, functionDesc);
+
+            if (functionDesc.isCount()) {
+                metricInfos[i] = new MetricInfo(MetricType.Count);
+            } else if (functionDesc.isDimensionAsMetric()) {
+                metricInfos[i] = new MetricInfo(MetricType.DimensionAsMetric);
+            } else {
+                int index = tableInfo.findFactTableColumn(functionDesc.getParameter().getValue());
+                if (index < 0) {
+                    throw new IllegalStateException("Column " + functionDesc.getParameter().getValue()
+ " is not found in II");
+                }
+
+                if (functionDesc.isCountDistinct()) {
+                    metricInfos[i] = new MetricInfo(MetricType.DistinctCount, index, functionDesc.getReturnDataType().getPrecision());
+                } else {
+                    metricInfos[i] = new MetricInfo(MetricType.Normal, index);
+                }
+            }
         }
 
         return new EndpointAggregators(funcNames, dataTypes, metricInfos, tableInfo.getDigest());


Mime
View raw message