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/11/27 10:28:32 UTC

[35/50] [abbrv] kylin git commit: minor, refactor AggregationGroup.calculateCuboidCombination()

minor, refactor AggregationGroup.calculateCuboidCombination()


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

Branch: refs/heads/KYLIN-1875
Commit: 873f903f3d95afa2cec5e1d6d3027f1b62f3ec54
Parents: 798f03e
Author: Li Yang <li...@apache.org>
Authored: Thu Nov 24 13:00:42 2016 +0800
Committer: Li Yang <li...@apache.org>
Committed: Thu Nov 24 13:00:42 2016 +0800

----------------------------------------------------------------------
 .../common/util/LocalFileMetadataTestCase.java  |  4 +-
 .../kylin/cube/model/AggregationGroup.java      | 88 ++++++++++++++----
 .../validation/rule/AggregationGroupRule.java   | 12 +--
 .../kylin/cube/AggregationGroupRuleTest.java    |  3 -
 .../org/apache/kylin/cube/CubeDescTest.java     | 97 +++++++++++++-------
 .../kylin/cube/cuboid/CuboidSchedulerTest.java  |  5 +-
 6 files changed, 141 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/873f903f/core-common/src/test/java/org/apache/kylin/common/util/LocalFileMetadataTestCase.java
----------------------------------------------------------------------
diff --git a/core-common/src/test/java/org/apache/kylin/common/util/LocalFileMetadataTestCase.java b/core-common/src/test/java/org/apache/kylin/common/util/LocalFileMetadataTestCase.java
index d351041..26e1e86 100644
--- a/core-common/src/test/java/org/apache/kylin/common/util/LocalFileMetadataTestCase.java
+++ b/core-common/src/test/java/org/apache/kylin/common/util/LocalFileMetadataTestCase.java
@@ -46,7 +46,7 @@ public class LocalFileMetadataTestCase extends AbstractKylinTestCase {
     public static void staticCreateTestMetadata(String testDataFolder) {
         KylinConfig.destroyInstance();
 
-        String tempTestMetadataUrl = "../examples/test_metadata";
+        String tempTestMetadataUrl = LOCALMETA_TEMP_DATA;
         try {
             FileUtils.deleteDirectory(new File(tempTestMetadataUrl));
             FileUtils.copyDirectory(new File(testDataFolder), new File(tempTestMetadataUrl));
@@ -61,7 +61,7 @@ public class LocalFileMetadataTestCase extends AbstractKylinTestCase {
     }
 
     public static void cleanAfterClass() {
-        String tempTestMetadataUrl = "../examples/test_metadata";
+        String tempTestMetadataUrl = LOCALMETA_TEMP_DATA;
         try {
             FileUtils.deleteDirectory(new File(tempTestMetadataUrl));
         } catch (IOException e) {

http://git-wip-us.apache.org/repos/asf/kylin/blob/873f903f/core-cube/src/main/java/org/apache/kylin/cube/model/AggregationGroup.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/model/AggregationGroup.java b/core-cube/src/main/java/org/apache/kylin/cube/model/AggregationGroup.java
index ab63c00..12c0574 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/model/AggregationGroup.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/model/AggregationGroup.java
@@ -19,9 +19,12 @@
 package org.apache.kylin.cube.model;
 
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
 
-import org.apache.kylin.common.util.StringUtil;
 import org.apache.kylin.cube.cuboid.Cuboid;
 import org.apache.kylin.metadata.model.TblColRef;
 
@@ -34,9 +37,9 @@ import com.google.common.collect.Lists;
 @JsonAutoDetect(fieldVisibility = Visibility.NONE, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
 public class AggregationGroup {
     public static class HierarchyMask {
-        public long fullMask;// 00000111
-        public long[] allMasks;// 00000100,00000110,00000111
-        public long[] dims;// 00000100,00000010,00000001
+        public long fullMask; // 00000111
+        public long[] allMasks; // 00000100,00000110,00000111
+        public long[] dims; // 00000100,00000010,00000001
     }
 
     @JsonProperty("includes")
@@ -64,7 +67,7 @@ public class AggregationGroup {
             throw new IllegalStateException("AggregationGroup incomplete");
         }
 
-        columnNamesToUpperCase();
+        normalizeColumnNames();
         
         buildPartialCubeFullMask(rowKeyDesc);
         buildMandatoryColumnMask(rowKeyDesc);
@@ -76,19 +79,41 @@ public class AggregationGroup {
 
     }
 
-    private void columnNamesToUpperCase() {
-        StringUtil.toUpperCaseArray(includes, includes);
-        StringUtil.toUpperCaseArray(selectRule.mandatory_dims, selectRule.mandatory_dims);
-        if (selectRule.hierarchy_dims != null) {
-            for (String[] cols : selectRule.hierarchy_dims) {
-                StringUtil.toUpperCaseArray(cols, cols);
-            }
+    private void normalizeColumnNames() {
+        Preconditions.checkNotNull(includes);
+        normalizeColumnNames(includes);
+        
+        Preconditions.checkNotNull(selectRule.mandatory_dims);
+        normalizeColumnNames(selectRule.mandatory_dims);
+        
+        if (selectRule.hierarchy_dims == null)
+            selectRule.hierarchy_dims = new String[0][];
+        for (String[] cols : selectRule.hierarchy_dims) {
+            Preconditions.checkNotNull(cols);
+            normalizeColumnNames(cols);
         }
-        if (selectRule.joint_dims != null) {
-            for (String[] cols : selectRule.joint_dims) {
-                StringUtil.toUpperCaseArray(cols, cols);
-            }
+            
+        if (selectRule.joint_dims == null)
+            selectRule.joint_dims = new String[0][];
+        for (String[] cols : selectRule.joint_dims) {
+            Preconditions.checkNotNull(cols);
+            normalizeColumnNames(cols);
+        }
+    }
+
+    private void normalizeColumnNames(String[] names) {
+        if (names == null)
+            return;
+        
+        for (int i = 0; i < names.length; i++) {
+            TblColRef col = cubeDesc.getModel().findColumn(names[i]);
+            names[i] = col.getTableAlias() + "." + col.getName();
         }
+        
+        // check no dup
+        Set<String> set = new HashSet<>(Arrays.asList(names));
+        if (set.size() < names.length)
+            throw new IllegalStateException("Columns in aggrgroup must not contain duplication: " + Arrays.asList(names));
     }
 
     private void buildPartialCubeFullMask(RowKeyDesc rowKeyDesc) {
@@ -250,6 +275,36 @@ public class AggregationGroup {
         return ret;
     }
 
+    /** Compute cuboid combination for aggregation group */
+    public long calculateCuboidCombination() {
+        long combination = 1;
+        
+        Set<String> includeDims = new TreeSet<>(Arrays.asList(includes));
+        Set<String> mandatoryDims = new TreeSet<>(Arrays.asList(selectRule.mandatory_dims));
+        
+        Set<String> hierarchyDims = new TreeSet<>();
+        for (String[] ss : selectRule.hierarchy_dims) {
+            hierarchyDims.addAll(Arrays.asList(ss));
+            combination = combination * (ss.length + 1);
+        }
+
+        Set<String> jointDims = new TreeSet<>();
+        for (String[] ss : selectRule.joint_dims) {
+            jointDims.addAll(Arrays.asList(ss));
+            combination = combination * 2;
+        }
+
+        Set<String> normalDims = new TreeSet<>();
+        normalDims.addAll(includeDims);
+        normalDims.removeAll(mandatoryDims);
+        normalDims.removeAll(hierarchyDims);
+        normalDims.removeAll(jointDims);
+
+        combination = combination * (1L << normalDims.size());
+
+        return combination;
+    }
+    
     public void setIncludes(String[] includes) {
         this.includes = includes;
     }
@@ -297,4 +352,5 @@ public class AggregationGroup {
     public CubeDesc getCubeDesc() {
         return cubeDesc;
     }
+
 }

http://git-wip-us.apache.org/repos/asf/kylin/blob/873f903f/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/AggregationGroupRule.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/AggregationGroupRule.java b/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/AggregationGroupRule.java
index c73f5ca..3f865ea 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/AggregationGroupRule.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/AggregationGroupRule.java
@@ -62,7 +62,6 @@ public class AggregationGroupRule implements IValidatorRule<CubeDesc> {
                 continue;
             }
 
-            long combination = 1;
             Set<String> includeDims = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
             if (agg.getIncludes() != null) {
                 for (String include : agg.getIncludes()) {
@@ -83,7 +82,6 @@ public class AggregationGroupRule implements IValidatorRule<CubeDesc> {
                     for (String s : ss) {
                         hierarchyDims.add(s);
                     }
-                    combination = combination * (ss.length + 1);
                 }
             }
 
@@ -93,7 +91,6 @@ public class AggregationGroupRule implements IValidatorRule<CubeDesc> {
                     for (String s : ss) {
                         jointDims.add(s);
                     }
-                    combination = combination * 2;
                 }
             }
 
@@ -109,14 +106,6 @@ public class AggregationGroupRule implements IValidatorRule<CubeDesc> {
                 continue;
             }
 
-            Set<String> normalDims = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
-            normalDims.addAll(includeDims);
-            normalDims.removeAll(mandatoryDims);
-            normalDims.removeAll(hierarchyDims);
-            normalDims.removeAll(jointDims);
-
-            combination = combination * (1L << normalDims.size());
-
             if (CollectionUtils.containsAny(mandatoryDims, hierarchyDims)) {
                 Set<String> intersection = new HashSet<>(mandatoryDims);
                 intersection.retainAll(hierarchyDims);
@@ -186,6 +175,7 @@ public class AggregationGroupRule implements IValidatorRule<CubeDesc> {
                 }
             }
 
+            long combination = agg.calculateCuboidCombination();
             if (combination > getMaxCombinations(cube)) {
                 String msg = "Aggregation group " + index + " has too many combinations, current combination is " + combination + ", max allowed combination is " + getMaxCombinations(cube) + "; use 'mandatory'/'hierarchy'/'joint' to optimize; or update 'kylin.cube.aggrgroup.max-combination' to a bigger value.";
                 context.addResult(ResultLevel.ERROR, msg);

http://git-wip-us.apache.org/repos/asf/kylin/blob/873f903f/core-cube/src/test/java/org/apache/kylin/cube/AggregationGroupRuleTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/cube/AggregationGroupRuleTest.java b/core-cube/src/test/java/org/apache/kylin/cube/AggregationGroupRuleTest.java
index 3deeb34..9bb5aea 100644
--- a/core-cube/src/test/java/org/apache/kylin/cube/AggregationGroupRuleTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/cube/AggregationGroupRuleTest.java
@@ -23,7 +23,6 @@ import static org.junit.Assert.assertTrue;
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.Arrays;
 
@@ -111,8 +110,6 @@ public class AggregationGroupRuleTest extends LocalFileMetadataTestCase {
         IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
         rule.validate(desc, vContext);
         vContext.print(System.out);
-        //        System.out.println(vContext.getResults().length);
-        //        System.out.println(vContext.getResults()[0].getMessage());
         assertEquals(1, vContext.getResults().length);
         assertEquals("Aggregation group 0 'includes' dimensions not include all the dimensions:[seller_id, META_CATEG_NAME, lstg_format_name, lstg_site_id, slr_segment_cd]", (vContext.getResults()[0].getMessage()));
     }

http://git-wip-us.apache.org/repos/asf/kylin/blob/873f903f/core-cube/src/test/java/org/apache/kylin/cube/CubeDescTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/cube/CubeDescTest.java b/core-cube/src/test/java/org/apache/kylin/cube/CubeDescTest.java
index 840d11f..27c154b 100644
--- a/core-cube/src/test/java/org/apache/kylin/cube/CubeDescTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/cube/CubeDescTest.java
@@ -19,8 +19,6 @@
 package org.apache.kylin.cube;
 
 import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
@@ -30,6 +28,7 @@ import java.util.TreeSet;
 
 import org.apache.kylin.common.util.JsonUtil;
 import org.apache.kylin.common.util.LocalFileMetadataTestCase;
+import org.apache.kylin.cube.model.AggregationGroup;
 import org.apache.kylin.cube.model.CubeDesc;
 import org.apache.kylin.cube.model.SelectRule;
 import org.junit.After;
@@ -46,12 +45,42 @@ import com.google.common.collect.Maps;
  */
 public class CubeDescTest extends LocalFileMetadataTestCase {
 
+    private static final String CUBE_WITH_SLR_DESC = "test_kylin_cube_with_slr_desc";
+    
+    private String SELLER_ID;
+    private String SLR_SEGMENT_CD;
+    private String LSTG_FORMAT_NAME;
+    private String LSTG_SITE_ID;
+    private String META_CATEG_NAME;
+    private String CATEG_LVL2_NAME;
+    private String CATEG_LVL3_NAME;
+    private String LEAF_CATEG_ID;
+    
     @Rule
     public ExpectedException thrown = ExpectedException.none();
 
     @Before
     public void setUp() throws Exception {
         this.createTestMetadata();
+        
+        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC);
+        AggregationGroup g = cubeDesc.getAggregationGroups().get(0);
+        SELLER_ID = getColInAggrGroup(g, "SELLER_ID");
+        SLR_SEGMENT_CD = getColInAggrGroup(g, "SLR_SEGMENT_CD");
+        LSTG_FORMAT_NAME = getColInAggrGroup(g, "LSTG_FORMAT_NAME");
+        LSTG_SITE_ID = getColInAggrGroup(g, "LSTG_SITE_ID");
+        META_CATEG_NAME = getColInAggrGroup(g, "META_CATEG_NAME");
+        CATEG_LVL2_NAME = getColInAggrGroup(g, "CATEG_LVL2_NAME");
+        CATEG_LVL3_NAME = getColInAggrGroup(g, "CATEG_LVL3_NAME");
+        LEAF_CATEG_ID = getColInAggrGroup(g, "LEAF_CATEG_ID");
+    }
+
+    private String getColInAggrGroup(AggregationGroup g, String name) {
+        for (String c : g.getIncludes()) {
+            if (c.toLowerCase().contains(name.toLowerCase()))
+                return c;
+        }
+        throw new IllegalStateException();
     }
 
     @After
@@ -61,7 +90,7 @@ public class CubeDescTest extends LocalFileMetadataTestCase {
 
     @Test
     public void testGoodInit() throws Exception {
-        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
+        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC);
         cubeDesc.init(getTestConfig());
     }
 
@@ -70,7 +99,7 @@ public class CubeDescTest extends LocalFileMetadataTestCase {
         thrown.expect(IllegalStateException.class);
         thrown.expectMessage("Aggregation group 0 includes field not set");
 
-        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
+        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC);
         String[] temp = null;
         cubeDesc.getAggregationGroups().get(0).setIncludes(temp);
 
@@ -82,7 +111,7 @@ public class CubeDescTest extends LocalFileMetadataTestCase {
         thrown.expect(IllegalStateException.class);
         thrown.expectMessage("Aggregation group 0 select rule field not set");
 
-        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
+        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC);
         SelectRule temp = null;
         cubeDesc.getAggregationGroups().get(0).setSelectRule(temp);
 
@@ -92,8 +121,8 @@ public class CubeDescTest extends LocalFileMetadataTestCase {
     @Test
     public void testBadInit3() throws Exception {
         thrown.expect(IllegalStateException.class);
-        thrown.expectMessage("Aggregation group 0 'includes' dimensions not include all the dimensions:" + sortStrs(new String[] { "SELLER_ID", "META_CATEG_NAME", "LSTG_FORMAT_NAME", "LSTG_SITE_ID", "SLR_SEGMENT_CD" }));
-        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
+        thrown.expectMessage("Aggregation group 0 'includes' dimensions not include all the dimensions:");
+        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC);
         String[] temp = Arrays.asList(cubeDesc.getAggregationGroups().get(0).getIncludes()).subList(0, 3).toArray(new String[3]);
         cubeDesc.getAggregationGroups().get(0).setIncludes(temp);
 
@@ -105,7 +134,7 @@ public class CubeDescTest extends LocalFileMetadataTestCase {
         thrown.expect(IllegalStateException.class);
         thrown.expectMessage("Aggregation group 0 has too many combinations, use 'mandatory'/'hierarchy'/'joint' to optimize; or update 'kylin.cube.aggrgroup.max-combination' to a bigger value.");
 
-        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
+        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC);
         try {
             System.setProperty("kylin.cube.aggrgroup.max-combination", "8");
             cubeDesc.validateAggregationGroups();
@@ -116,16 +145,16 @@ public class CubeDescTest extends LocalFileMetadataTestCase {
 
     @Test
     public void testBadInit5() throws Exception {
-        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
-        cubeDesc.getAggregationGroups().get(0).getSelectRule().mandatory_dims = new String[] { "seller_id", "META_CATEG_NAME" };
+        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC);
+        cubeDesc.getAggregationGroups().get(0).getSelectRule().mandatory_dims = new String[] { SELLER_ID, META_CATEG_NAME };
 
         cubeDesc.init(getTestConfig());
     }
 
     @Test
     public void testBadInit6() throws Exception {
-        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
-        cubeDesc.getAggregationGroups().get(0).getSelectRule().mandatory_dims = new String[] { "seller_id", "lstg_format_name" };
+        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC);
+        cubeDesc.getAggregationGroups().get(0).getSelectRule().mandatory_dims = new String[] { SELLER_ID, LSTG_FORMAT_NAME };
 
         cubeDesc.init(getTestConfig());
     }
@@ -135,44 +164,44 @@ public class CubeDescTest extends LocalFileMetadataTestCase {
         thrown.expect(IllegalStateException.class);
         thrown.expectMessage("Aggregation group 0 require at least 2 dimensions in a joint");
 
-        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
-        cubeDesc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] { new String[] { "lstg_format_name" } };
+        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC);
+        cubeDesc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] { new String[] { LSTG_FORMAT_NAME } };
 
         cubeDesc.init(getTestConfig());
     }
 
     @Test
     public void testBadInit8() throws Exception {
-        String[] strs = new String[] { "CATEG_LVL2_NAME", "META_CATEG_NAME" };
+        String[] strs = new String[] { CATEG_LVL2_NAME, META_CATEG_NAME };
         thrown.expect(IllegalStateException.class);
         thrown.expectMessage("Aggregation group 0 hierarchy dimensions overlap with joint dimensions: " + sortStrs(strs));
 
-        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
-        cubeDesc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] { new String[] { "META_CATEG_NAME", "CATEG_LVL2_NAME" } };
+        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC);
+        cubeDesc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] { new String[] { META_CATEG_NAME, CATEG_LVL2_NAME } };
 
         cubeDesc.init(getTestConfig());
     }
 
     @Test
     public void testBadInit9() throws Exception {
-        String[] strs = new String[] { "lstg_format_name", "META_CATEG_NAME" };
+        String[] strs = new String[] { LSTG_FORMAT_NAME, META_CATEG_NAME };
         thrown.expect(IllegalStateException.class);
         thrown.expectMessage("Aggregation group 0 hierarchy dimensions overlap with joint dimensions: " + sortStrs(strs));
-        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
-        cubeDesc.getAggregationGroups().get(0).getSelectRule().hierarchy_dims = new String[][] { new String[] { "META_CATEG_NAME", "CATEG_LVL2_NAME", "CATEG_LVL3_NAME" }, new String[] { "lstg_format_name", "lstg_site_id" } };
-        cubeDesc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] { new String[] { "META_CATEG_NAME", "lstg_format_name" } };
+        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC);
+        cubeDesc.getAggregationGroups().get(0).getSelectRule().hierarchy_dims = new String[][] { new String[] { META_CATEG_NAME, CATEG_LVL2_NAME, CATEG_LVL3_NAME }, new String[] { LSTG_FORMAT_NAME, LSTG_SITE_ID } };
+        cubeDesc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] { new String[] { META_CATEG_NAME, LSTG_FORMAT_NAME } };
 
         cubeDesc.init(getTestConfig());
     }
 
     @Test
     public void testBadInit10() throws Exception {
-        String[] strs = new String[] { "lstg_format_name", "lstg_site_id" };
+        String[] strs = new String[] { LSTG_FORMAT_NAME, LSTG_SITE_ID };
         thrown.expect(IllegalStateException.class);
         thrown.expectMessage("Aggregation group 0 a dimension exist in more than one joint: " + sortStrs(strs));
 
-        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
-        cubeDesc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] { new String[] { "lstg_format_name", "lstg_site_id", "slr_segment_cd" }, new String[] { "lstg_format_name", "lstg_site_id", "leaf_categ_id" } };
+        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC);
+        cubeDesc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] { new String[] { LSTG_FORMAT_NAME, LSTG_SITE_ID, SLR_SEGMENT_CD }, new String[] { LSTG_FORMAT_NAME, LSTG_SITE_ID, LEAF_CATEG_ID } };
 
         cubeDesc.init(getTestConfig());
     }
@@ -182,42 +211,42 @@ public class CubeDescTest extends LocalFileMetadataTestCase {
         thrown.expect(IllegalStateException.class);
         thrown.expectMessage("Aggregation group 0 require at least 2 dimensions in a hierarchy.");
 
-        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
-        cubeDesc.getAggregationGroups().get(0).getSelectRule().hierarchy_dims = new String[][] { new String[] { "META_CATEG_NAME" } };
+        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC);
+        cubeDesc.getAggregationGroups().get(0).getSelectRule().hierarchy_dims = new String[][] { new String[] { META_CATEG_NAME } };
 
         cubeDesc.init(getTestConfig());
     }
 
     @Test
     public void testBadInit12() throws Exception {
-        String[] strs = new String[] { "CATEG_LVL2_NAME", "META_CATEG_NAME" };
+        String[] strs = new String[] { CATEG_LVL2_NAME, META_CATEG_NAME };
         thrown.expect(IllegalStateException.class);
         thrown.expectMessage("Aggregation group 0 a dimension exist in more than one hierarchy: " + sortStrs(strs));
 
-        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
-        cubeDesc.getAggregationGroups().get(0).getSelectRule().hierarchy_dims = new String[][] { new String[] { "META_CATEG_NAME", "CATEG_LVL2_NAME", "CATEG_LVL3_NAME" }, new String[] { "META_CATEG_NAME", "CATEG_LVL2_NAME" } };
+        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC);
+        cubeDesc.getAggregationGroups().get(0).getSelectRule().hierarchy_dims = new String[][] { new String[] { META_CATEG_NAME, CATEG_LVL2_NAME, CATEG_LVL3_NAME }, new String[] { META_CATEG_NAME, CATEG_LVL2_NAME } };
 
         cubeDesc.init(getTestConfig());
     }
 
     @Test
     public void testCombinationIntOverflow() throws  Exception {
-        for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA +  "/cube_desc/").listFiles()) {
-            if (f.getName().endsWith("bad")) {
+        for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA, "cube_desc").listFiles()) {
+            if (f.getName().endsWith(".bad")) {
                 String path = f.getPath();
                 f.renameTo(new File(path.substring(0, path.length() - 4)));
             }
         }
 
         thrown.expect(IllegalStateException.class);
-        getTestConfig();
+        CubeDescManager.clearCache();
         CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("ut_cube_desc_combination_int_overflow");
         cubeDesc.init(getTestConfig());
     }
 
     @Test
     public void testSerialize() throws Exception {
-        CubeDesc desc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
+        CubeDesc desc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC);
         String str = JsonUtil.writeValueAsIndentString(desc);
         System.out.println(str);
         @SuppressWarnings("unused")
@@ -226,7 +255,7 @@ public class CubeDescTest extends LocalFileMetadataTestCase {
 
     @Test
     public void testGetCubeDesc() throws Exception {
-        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
+        CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC);
         Assert.assertNotNull(cubeDesc);
     }
 

http://git-wip-us.apache.org/repos/asf/kylin/blob/873f903f/core-cube/src/test/java/org/apache/kylin/cube/cuboid/CuboidSchedulerTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/cube/cuboid/CuboidSchedulerTest.java b/core-cube/src/test/java/org/apache/kylin/cube/cuboid/CuboidSchedulerTest.java
index 63a8211..7db616e 100644
--- a/core-cube/src/test/java/org/apache/kylin/cube/cuboid/CuboidSchedulerTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/cube/cuboid/CuboidSchedulerTest.java
@@ -287,12 +287,13 @@ public class CuboidSchedulerTest extends LocalFileMetadataTestCase {
 
     @Test
     public void testCuboid_onlyBaseCuboid() {
-        for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/").listFiles()) {
-            if (f.getName().endsWith("bad")) {
+        for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA, "cube_desc").listFiles()) {
+            if (f.getName().endsWith(".bad")) {
                 String path = f.getPath();
                 f.renameTo(new File(path.substring(0, path.length() - 4)));
             }
         }
+        CubeDescManager.clearCache();
         CubeDesc cube = getCubeDescManager().getCubeDesc("ut_large_dimension_number");
         CuboidScheduler scheduler = new CuboidScheduler(cube);