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/08/14 02:26:07 UTC

kylin git commit: minor, refine a UT case

Repository: kylin
Updated Branches:
  refs/heads/master e82b62136 -> bebe9dc56


minor, refine a UT case


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

Branch: refs/heads/master
Commit: bebe9dc567f752288462f11002387da11c1261b2
Parents: e82b621
Author: lidongsjtu <li...@apache.org>
Authored: Sun Aug 14 10:25:20 2016 +0800
Committer: lidongsjtu <li...@apache.org>
Committed: Sun Aug 14 10:25:20 2016 +0800

----------------------------------------------------------------------
 .../hbase/cube/CubeStorageQueryTest.java        | 154 -------------------
 .../cube/MeasureTypeOnlyAggrInBaseTest.java     | 149 ++++++++++++++++++
 2 files changed, 149 insertions(+), 154 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/bebe9dc5/storage-hbase/src/test/java/org/apache/kylin/storage/hbase/cube/CubeStorageQueryTest.java
----------------------------------------------------------------------
diff --git a/storage-hbase/src/test/java/org/apache/kylin/storage/hbase/cube/CubeStorageQueryTest.java b/storage-hbase/src/test/java/org/apache/kylin/storage/hbase/cube/CubeStorageQueryTest.java
deleted file mode 100644
index 71f751b..0000000
--- a/storage-hbase/src/test/java/org/apache/kylin/storage/hbase/cube/CubeStorageQueryTest.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.kylin.storage.hbase.cube;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.kylin.common.util.LocalFileMetadataTestCase;
-import org.apache.kylin.cube.CubeInstance;
-import org.apache.kylin.cube.CubeManager;
-import org.apache.kylin.cube.cuboid.Cuboid;
-import org.apache.kylin.cube.model.CubeDesc;
-import org.apache.kylin.measure.MeasureAggregator;
-import org.apache.kylin.measure.MeasureIngester;
-import org.apache.kylin.measure.MeasureType;
-import org.apache.kylin.metadata.MetadataManager;
-import org.apache.kylin.metadata.model.FunctionDesc;
-import org.apache.kylin.metadata.model.MeasureDesc;
-import org.apache.kylin.metadata.model.TblColRef;
-import org.apache.kylin.storage.IStorageQuery;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-
-/**
- * Created by dongli on 12/28/15.
- */
-public class CubeStorageQueryTest extends LocalFileMetadataTestCase {
-
-    private CubeInstance cube;
-
-    public CubeManager getCubeManager() {
-        return CubeManager.getInstance(getTestConfig());
-    }
-
-    private CubeInstance getTestKylinCubeWithSeller() {
-        return getCubeManager().getCube("test_kylin_cube_with_slr_empty");
-    }
-
-    @Before
-    public void setUp() throws Exception {
-        this.createTestMetadata();
-        MetadataManager.clearCache();
-
-        cube = getTestKylinCubeWithSeller();
-    }
-
-    @After
-    public void after() throws Exception {
-        this.cleanupTestMetadata();
-    }
-
-    private void validateIdentifyCuboidOnStorageQnery(CubeDesc cubeDesc, IStorageQuery query) {
-        long baseCuboidId = cubeDesc.getRowkey().getFullMask();
-
-        try {
-            Method method = query.getClass().getDeclaredMethod("identifyCuboid", Set.class, Collection.class);
-            method.setAccessible(true);
-
-            Set<TblColRef> dimensions = Sets.newHashSet();
-            List<FunctionDesc> metrics = Lists.newArrayList();
-
-            Object ret = method.invoke(query, dimensions, metrics);
-
-            assertTrue(ret instanceof Cuboid);
-            assertNotEquals(baseCuboidId, ((Cuboid) ret).getId());
-
-            for (MeasureDesc measureDesc : cubeDesc.getMeasures()) {
-                Collections.addAll(metrics, measureDesc.getFunction());
-            }
-
-            FunctionDesc mockUpFuncDesc = new FunctionDesc();
-            Field field = FunctionDesc.class.getDeclaredField("measureType");
-            field.setAccessible(true);
-            field.set(mockUpFuncDesc, new MockUpMeasureType());
-            metrics.add(mockUpFuncDesc);
-
-            ret = method.invoke(query, dimensions, metrics);
-            assertEquals(baseCuboidId, ((Cuboid) ret).getId());
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    @Test
-    public void testIdentifyCuboidV1() {
-        CubeDesc cubeDesc = cube.getDescriptor();
-        IStorageQuery query = new org.apache.kylin.storage.hbase.cube.v1.CubeStorageQuery(cube);
-        validateIdentifyCuboidOnStorageQnery(cubeDesc, query);
-    }
-
-    @Test
-    public void testIdentifyCuboidV2() {
-        CubeDesc cubeDesc = cube.getDescriptor();
-        IStorageQuery query = new org.apache.kylin.storage.hbase.cube.v2.CubeStorageQuery(cube);
-        validateIdentifyCuboidOnStorageQnery(cubeDesc, query);
-    }
-
-    class MockUpMeasureType extends MeasureType<String> {
-
-        @Override
-        public MeasureIngester<String> newIngester() {
-            return null;
-        }
-
-        @Override
-        public MeasureAggregator<String> newAggregator() {
-            return null;
-        }
-
-        @Override
-        public boolean needRewrite() {
-            return false;
-        }
-
-        @Override
-        public Class<?> getRewriteCalciteAggrFunctionClass() {
-            return null;
-        }
-
-        @Override
-        public boolean onlyAggrInBaseCuboid() {
-            return true;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/kylin/blob/bebe9dc5/storage-hbase/src/test/java/org/apache/kylin/storage/hbase/cube/MeasureTypeOnlyAggrInBaseTest.java
----------------------------------------------------------------------
diff --git a/storage-hbase/src/test/java/org/apache/kylin/storage/hbase/cube/MeasureTypeOnlyAggrInBaseTest.java b/storage-hbase/src/test/java/org/apache/kylin/storage/hbase/cube/MeasureTypeOnlyAggrInBaseTest.java
new file mode 100644
index 0000000..1353862
--- /dev/null
+++ b/storage-hbase/src/test/java/org/apache/kylin/storage/hbase/cube/MeasureTypeOnlyAggrInBaseTest.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kylin.storage.hbase.cube;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.kylin.common.util.LocalFileMetadataTestCase;
+import org.apache.kylin.cube.CubeInstance;
+import org.apache.kylin.cube.CubeManager;
+import org.apache.kylin.cube.cuboid.Cuboid;
+import org.apache.kylin.cube.model.CubeDesc;
+import org.apache.kylin.measure.MeasureAggregator;
+import org.apache.kylin.measure.MeasureIngester;
+import org.apache.kylin.measure.MeasureType;
+import org.apache.kylin.metadata.MetadataManager;
+import org.apache.kylin.metadata.model.FunctionDesc;
+import org.apache.kylin.metadata.model.MeasureDesc;
+import org.apache.kylin.metadata.model.TblColRef;
+import org.apache.kylin.storage.IStorageQuery;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+public class MeasureTypeOnlyAggrInBaseTest extends LocalFileMetadataTestCase {
+
+    private CubeInstance cube;
+    private CubeDesc cubeDesc;
+
+    private Set<TblColRef> dimensions;
+    private List<FunctionDesc> metrics;
+
+    public CubeManager getCubeManager() {
+        return CubeManager.getInstance(getTestConfig());
+    }
+
+    private CubeInstance getTestKylinCubeWithSeller() {
+        return getCubeManager().getCube("test_kylin_cube_with_slr_empty");
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        this.createTestMetadata();
+        MetadataManager.clearCache();
+
+        cube = getTestKylinCubeWithSeller();
+        cubeDesc = cube.getDescriptor();
+
+        dimensions = Sets.newHashSet();
+        metrics = Lists.newArrayList();
+        for (MeasureDesc measureDesc : cubeDesc.getMeasures()) {
+            Collections.addAll(metrics, measureDesc.getFunction());
+        }
+
+        FunctionDesc mockUpFuncDesc = new FunctionDesc();
+        Field field = FunctionDesc.class.getDeclaredField("measureType");
+        field.setAccessible(true);
+        field.set(mockUpFuncDesc, new MockUpMeasureType());
+        metrics.add(mockUpFuncDesc);
+    }
+
+    @After
+    public void after() throws Exception {
+        this.cleanupTestMetadata();
+    }
+
+    @Test
+    public void testIdentifyCuboidV1() throws InvocationTargetException, NoSuchMethodException, IllegalAccessException, NoSuchFieldException {
+        IStorageQuery query = new org.apache.kylin.storage.hbase.cube.v1.CubeStorageQuery(cube);
+        long baseCuboidId = cubeDesc.getRowkey().getFullMask();
+
+        Method method = query.getClass().getDeclaredMethod("identifyCuboid", Set.class, Collection.class);
+        method.setAccessible(true);
+
+        Object ret = method.invoke(query, Sets.newHashSet(), Lists.newArrayList());
+
+        assertTrue(ret instanceof Cuboid);
+        assertNotEquals(baseCuboidId, ((Cuboid) ret).getId());
+
+        ret = method.invoke(query, dimensions, metrics);
+        assertEquals(baseCuboidId, ((Cuboid) ret).getId());
+    }
+
+    @Test
+    public void testIdentifyCuboidV2() throws InvocationTargetException, NoSuchMethodException, IllegalAccessException, NoSuchFieldException {
+        CubeDesc cubeDesc = cube.getDescriptor();
+        Cuboid ret = Cuboid.identifyCuboid(cubeDesc, Sets.<TblColRef> newHashSet(), Lists.<FunctionDesc> newArrayList());
+        long baseCuboidId = cubeDesc.getRowkey().getFullMask();
+        assertNotEquals(baseCuboidId, ret.getId());
+        ret = Cuboid.identifyCuboid(cubeDesc, dimensions, metrics);
+        assertEquals(baseCuboidId, ret.getId());
+    }
+
+    class MockUpMeasureType extends MeasureType<String> {
+
+        @Override
+        public MeasureIngester<String> newIngester() {
+            return null;
+        }
+
+        @Override
+        public MeasureAggregator<String> newAggregator() {
+            return null;
+        }
+
+        @Override
+        public boolean needRewrite() {
+            return false;
+        }
+
+        @Override
+        public Class<?> getRewriteCalciteAggrFunctionClass() {
+            return null;
+        }
+
+        @Override
+        public boolean onlyAggrInBaseCuboid() {
+            return true;
+        }
+    }
+}