You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2016/09/03 06:37:15 UTC

[08/50] [abbrv] kylin git commit: KYLIN-1904 Fix DictionaryDesc checking rule

KYLIN-1904 Fix DictionaryDesc checking rule


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

Branch: refs/heads/1.5.x-HBase1.x
Commit: 03c6cf3dab0e3a40f663e083348cb3e4cdc59a49
Parents: 4c897dd
Author: Li Yang <li...@apache.org>
Authored: Wed Aug 24 16:59:47 2016 +0800
Committer: Li Yang <li...@apache.org>
Committed: Wed Aug 24 16:59:47 2016 +0800

----------------------------------------------------------------------
 .../org/apache/kylin/cube/model/CubeDesc.java   |  5 +--
 .../model/validation/rule/DictionaryRule.java   | 43 ++++++--------------
 2 files changed, 15 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/03c6cf3d/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java b/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
index 30290cd..2d9945a 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
@@ -1104,9 +1104,8 @@ public class CubeDesc extends RootPersistentEntity implements IEngineAware {
 
         for (DictionaryDesc desc : dictionaries) {
             if (desc.getBuilderClass() != null) {
-                if (col.equals(desc.getResuseColumnRef())) {
-                    return desc.getBuilderClass();
-                } else if (col.equals(desc.getColumnRef())) {
+                // column that reuses other's dict need not be built, thus should not reach here
+                if (col.equals(desc.getColumnRef())) {
                     return desc.getBuilderClass();
                 }
             }

http://git-wip-us.apache.org/repos/asf/kylin/blob/03c6cf3d/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/DictionaryRule.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/DictionaryRule.java b/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/DictionaryRule.java
index 2368105..9e6b600 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/DictionaryRule.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/DictionaryRule.java
@@ -23,11 +23,9 @@ import java.util.List;
 
 import org.apache.kylin.cube.model.CubeDesc;
 import org.apache.kylin.cube.model.DictionaryDesc;
-import org.apache.kylin.cube.model.RowKeyColDesc;
 import org.apache.kylin.cube.model.validation.IValidatorRule;
 import org.apache.kylin.cube.model.validation.ResultLevel;
 import org.apache.kylin.cube.model.validation.ValidateContext;
-import org.apache.kylin.dict.GlobalDictionaryBuilder;
 import org.apache.kylin.metadata.model.TblColRef;
 
 /**
@@ -45,43 +43,28 @@ public class DictionaryRule implements IValidatorRule<CubeDesc> {
         HashMap<TblColRef, String> colToBuilderMap = new HashMap<>();
         HashMap<TblColRef, TblColRef> colToReuseColMap = new HashMap<>();
         for (DictionaryDesc dictDesc : dictDescs) {
-            // Make sure the same column associate with same builder class, check the reuse column by default
-            TblColRef dictCol = dictDesc.getResuseColumnRef();
-            if (dictCol == null) {
-                dictCol = dictDesc.getColumnRef();
-            }
+            TblColRef dictCol = dictDesc.getColumnRef();
             if (dictCol == null) {
                 context.addResult(ResultLevel.ERROR, "Some column in dictionaries not found");
                 return;
             }
-            String builder = dictDesc.getBuilderClass();
-            String oldBuilder = colToBuilderMap.put(dictCol, builder);
-            if (oldBuilder != null && !oldBuilder.equals(builder)) {
-                context.addResult(ResultLevel.ERROR, "Column " + dictCol + " has inconsistent builders " + builder + " and " + oldBuilder);
-                return;
-            }
-
-            // Make sure one column only reuse another one column
-            if (dictDesc.getResuseColumnRef() != null) {
-                TblColRef oldReuseCol = colToReuseColMap.put(dictDesc.getColumnRef(), dictDesc.getResuseColumnRef());
-                if (oldReuseCol != null && !dictDesc.getResuseColumnRef().equals(oldReuseCol)) {
-                    context.addResult(ResultLevel.ERROR, "Column " + dictDesc.getColumnRef() + " reuse inconsistent column " + dictDesc.getResuseColumnRef() + " and " + oldReuseCol);
+            TblColRef reuseCol = dictDesc.getResuseColumnRef();
+            if (reuseCol == null) {
+                // Make sure the same column associate with same builder class
+                String builder = dictDesc.getBuilderClass();
+                String oldBuilder = colToBuilderMap.put(dictCol, builder);
+                if (oldBuilder != null && !oldBuilder.equals(builder)) {
+                    context.addResult(ResultLevel.ERROR, "Column " + dictCol + " has inconsistent builders " + builder + " and " + oldBuilder);
                     return;
                 }
-            }
-        }
-
-        // Make sure one column do not use GlobalDictBuilder and DimensionDictEncoding together
-        RowKeyColDesc[] rowKeyColDescs = cubeDesc.getRowkey().getRowKeyColumns();
-        for (RowKeyColDesc desc : rowKeyColDescs) {
-            if (desc.isUsingDictionary()) {
-                String builder = colToBuilderMap.get(desc.getColRef());
-                if (builder != null && builder.equals(GlobalDictionaryBuilder.class.getName())) {
-                    context.addResult(ResultLevel.ERROR, "Column " + desc.getColRef() + " used as dimension and conflict with GlobalDictBuilder");
+            } else {
+                // Make sure one column only reuse another one column
+                TblColRef oldReuseCol = colToReuseColMap.put(dictCol, reuseCol);
+                if (oldReuseCol != null && !reuseCol.equals(oldReuseCol)) {
+                    context.addResult(ResultLevel.ERROR, "Column " + dictCol + " reuse inconsistent column " + reuseCol + " and " + oldReuseCol);
                     return;
                 }
             }
         }
-
     }
 }