kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mahong...@apache.org
Subject [2/2] kylin git commit: KYLIN-1483 Command tool to visualize all cuboids in a cube/segment
Date Thu, 10 Mar 2016 06:22:17 GMT
KYLIN-1483 Command tool to visualize all cuboids in a cube/segment


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

Branch: refs/heads/2.x-staging
Commit: c4be5461f070b073c12388d0ad9d8d9d3b7519f0
Parents: ed57c3b
Author: Hongbin Ma <mahongbin@apache.org>
Authored: Thu Mar 10 14:21:57 2016 +0800
Committer: Hongbin Ma <mahongbin@apache.org>
Committed: Thu Mar 10 14:21:57 2016 +0800

----------------------------------------------------------------------
 .../org/apache/kylin/cube/cuboid/Cuboid.java    | 39 +++++++++++---------
 .../kylin/engine/mr/common/CubeStatsReader.java |  7 ++--
 2 files changed, 25 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/c4be5461/core-cube/src/main/java/org/apache/kylin/cube/cuboid/Cuboid.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/Cuboid.java b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/Cuboid.java
index 513513c..2cd96a6 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/Cuboid.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/Cuboid.java
@@ -18,14 +18,11 @@
 
 package org.apache.kylin.cube.cuboid;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
+import com.google.common.base.Function;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.ComparisonChain;
+import com.google.common.collect.Lists;
+import org.apache.commons.lang.StringUtils;
 import org.apache.kylin.common.util.Bytes;
 import org.apache.kylin.cube.gridtable.CuboidToGridTableMapping;
 import org.apache.kylin.cube.model.AggregationGroup;
@@ -34,10 +31,13 @@ import org.apache.kylin.cube.model.CubeDesc;
 import org.apache.kylin.cube.model.RowKeyColDesc;
 import org.apache.kylin.metadata.model.TblColRef;
 
-import com.google.common.base.Function;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.ComparisonChain;
-import com.google.common.collect.Lists;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 public class Cuboid implements Comparable<Cuboid> {
 
@@ -222,7 +222,8 @@ public class Cuboid implements Comparable<Cuboid> {
             return true;
         }
 
-        hier: for (HierarchyMask hierarchyMasks : hierarchyMaskList) {
+        hier:
+        for (HierarchyMask hierarchyMasks : hierarchyMaskList) {
             long result = cuboidID & hierarchyMasks.fullMask;
             if (result > 0) {
                 // if match one of the hierarchy constrains, return true;
@@ -385,11 +386,13 @@ public class Cuboid implements Comparable<Cuboid> {
 
     public static String getDisplayName(long cuboidID, int dimensionCount) {
         StringBuilder sb = new StringBuilder();
-        String temp = Long.toString(cuboidID);
-        for (int i = 0; i < dimensionCount - temp.length(); i++) {
-            sb.append("0");
+        for (int i = 0; i < dimensionCount; ++i) {
+            if ((cuboidID & (1L << i)) == 0) {
+                sb.append('0');
+            } else {
+                sb.append('1');
+            }
         }
-        sb.append(temp);
-        return sb.toString();
+        return StringUtils.reverse(sb.toString());
     }
 }

http://git-wip-us.apache.org/repos/asf/kylin/blob/c4be5461/engine-mr/src/main/java/org/apache/kylin/engine/mr/common/CubeStatsReader.java
----------------------------------------------------------------------
diff --git a/engine-mr/src/main/java/org/apache/kylin/engine/mr/common/CubeStatsReader.java
b/engine-mr/src/main/java/org/apache/kylin/engine/mr/common/CubeStatsReader.java
index e842c01..57e93c3 100644
--- a/engine-mr/src/main/java/org/apache/kylin/engine/mr/common/CubeStatsReader.java
+++ b/engine-mr/src/main/java/org/apache/kylin/engine/mr/common/CubeStatsReader.java
@@ -241,7 +241,7 @@ public class CubeStatsReader {
         CuboidScheduler scheduler = new CuboidScheduler(cubeDesc);
         long baseCuboid = Cuboid.getBaseCuboidId(cubeDesc);
         int dimensionCount = Long.bitCount(baseCuboid);
-        printCuboidInfoTree(0L, baseCuboid, scheduler, cuboidRows, cuboidSizes, dimensionCount,
0, out);
+        printCuboidInfoTree(-1L, baseCuboid, scheduler, cuboidRows, cuboidSizes, dimensionCount,
0, out);
     }
 
     private static void printCuboidInfoTree(long parent, long cuboidID, final CuboidScheduler
scheduler, Map<Long, Long> cuboidRows, Map<Long, Double> cuboidSizes, int dimensionCount,
int depth, PrintWriter out) {
@@ -251,7 +251,7 @@ public class CubeStatsReader {
         Collections.sort(children);
 
         for (Long child : children) {
-            printCuboidInfoTree(parent, child, scheduler, cuboidRows, cuboidSizes, dimensionCount,
depth + 1, out);
+            printCuboidInfoTree(cuboidID, child, scheduler, cuboidRows, cuboidSizes, dimensionCount,
depth + 1, out);
         }
     }
 
@@ -268,7 +268,7 @@ public class CubeStatsReader {
         sb.append(", est row: ").append(rowCount).append(", est MB: ").append(formatDouble(size));
 
         if (parent != -1) {
-            sb.append(", shrink: ").append(formatDouble(1.0 * cuboidRows.get(cuboidID) /
cuboidRows.get(parent))).append("%");
+            sb.append(", shrink: ").append(formatDouble(100.0 * cuboidRows.get(cuboidID)
/ cuboidRows.get(parent))).append("%");
         }
 
         out.println(sb.toString());
@@ -279,6 +279,7 @@ public class CubeStatsReader {
     }
 
     public static void main(String[] args) throws IOException {
+        System.out.println("CubeStatsReader is used to read cube statistic saved in metadata
store");
         KylinConfig config = KylinConfig.getInstanceFromEnv();
         CubeInstance cube = CubeManager.getInstance(config).getCube(args[0]);
         List<CubeSegment> segments = cube.getSegments(SegmentStatusEnum.READY);


Mime
View raw message