This is an automated email from the ASF dual-hosted git repository.

shaofengshi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git


The following commit(s) were added to refs/heads/master by this push:
     new 3b9c5a5  KYLIN-3597 fix sonar issues
3b9c5a5 is described below

commit 3b9c5a55139ca85e60e45bb5c748f480178a93d5
Author: whuwb <[email protected]>
AuthorDate: Mon Dec 17 23:06:04 2018 +0800

    KYLIN-3597 fix sonar issues
---
 .../cube/cuboid/algorithm/CuboidStatsUtil.java     | 31 +++++++++++-----------
 .../cuboid/algorithm/greedy/GreedyAlgorithm.java   |  4 +--
 .../storage/gtrecord/CubeScanRangePlanner.java     |  3 ++-
 3 files changed, 20 insertions(+), 18 deletions(-)

diff --git 
a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/CuboidStatsUtil.java
 
b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/CuboidStatsUtil.java
index def1e68..dc3471b 100644
--- 
a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/CuboidStatsUtil.java
+++ 
b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/CuboidStatsUtil.java
@@ -55,25 +55,26 @@ public class CuboidStatsUtil {
 
         for (Map.Entry<Long, Long> hitFrequency : hitFrequencyMap.entrySet()) {
             long cuboid = hitFrequency.getKey();
-            if (statistics.get(cuboid) != null) {
-                continue;
-            }
-            if (rollingUpCountSourceMap.get(cuboid) == null || 
rollingUpCountSourceMap.get(cuboid).isEmpty()) {
-                continue;
-            }
-            long totalEstScanCount = 0L;
-            for (long estScanCount : 
rollingUpCountSourceMap.get(cuboid).values()) {
-                totalEstScanCount += estScanCount;
-            }
-            totalEstScanCount /= rollingUpCountSourceMap.get(cuboid).size();
-            if ((hitFrequency.getValue() * 1.0 / totalHitFrequency)
-                    * totalEstScanCount >= rollUpThresholdForMandatory) {
-                mandatoryCuboidSet.add(cuboid);
+
+            if (isCuboidMandatory(cuboid, statistics, 
rollingUpCountSourceMap)) {
+                long totalEstScanCount = 0L;
+                for (long estScanCount : 
rollingUpCountSourceMap.get(cuboid).values()) {
+                    totalEstScanCount += estScanCount;
+                }
+                totalEstScanCount /= 
rollingUpCountSourceMap.get(cuboid).size();
+                if ((hitFrequency.getValue() * 1.0 / totalHitFrequency)
+                        * totalEstScanCount >= rollUpThresholdForMandatory) {
+                    mandatoryCuboidSet.add(cuboid);
+                }
             }
         }
         return mandatoryCuboidSet;
     }
 
+    private static boolean isCuboidMandatory(Long cuboid, Map<Long, Long> 
statistics, Map<Long, Map<Long, Long>> rollingUpCountSourceMap) {
+        return !statistics.containsKey(cuboid) && 
rollingUpCountSourceMap.containsKey(cuboid) && 
!rollingUpCountSourceMap.get(cuboid).isEmpty();
+    }
+
     /**
      * Complement row count for mandatory cuboids
      * with its best parent's row count
@@ -81,7 +82,7 @@ public class CuboidStatsUtil {
     public static void complementRowCountForMandatoryCuboids(Map<Long, Long> 
statistics, long baseCuboid,
             Set<Long> mandatoryCuboidSet) {
         // Sort entries order by row count asc
-        SortedSet<Map.Entry<Long, Long>> sortedStatsSet = new 
TreeSet<Map.Entry<Long, Long>>(
+        SortedSet<Map.Entry<Long, Long>> sortedStatsSet = new TreeSet<>(
                 new Comparator<Map.Entry<Long, Long>>() {
                     public int compare(Map.Entry<Long, Long> o1, 
Map.Entry<Long, Long> o2) {
                         return o1.getValue().compareTo(o2.getValue());
diff --git 
a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/greedy/GreedyAlgorithm.java
 
b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/greedy/GreedyAlgorithm.java
index 7f415de..e8b0ae8 100755
--- 
a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/greedy/GreedyAlgorithm.java
+++ 
b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/greedy/GreedyAlgorithm.java
@@ -110,12 +110,12 @@ public class GreedyAlgorithm extends 
AbstractRecommendAlgorithm {
 
         List<Long> excluded = Lists.newArrayList(remaining);
         remaining.retainAll(selected);
-        Preconditions.checkArgument(remaining.size() == 0,
+        Preconditions.checkArgument(remaining.isEmpty(),
                 "There should be no intersection between excluded list and 
selected list.");
         logger.info("Greedy Algorithm finished.");
 
         if (logger.isTraceEnabled()) {
-            logger.trace("Excluded cuboidId size:" + excluded.size());
+            logger.trace(String.format(Locale.ROOT, "Excluded cuboidId 
size:%d", excluded.size()));
             logger.trace("Excluded cuboidId detail:");
             for (Long cuboid : excluded) {
                 logger.trace(String.format(Locale.ROOT, "cuboidId %d and Cost: 
%d and Space: %f", cuboid,
diff --git 
a/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/CubeScanRangePlanner.java
 
b/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/CubeScanRangePlanner.java
index 1a02e1a..3095c8f 100644
--- 
a/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/CubeScanRangePlanner.java
+++ 
b/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/CubeScanRangePlanner.java
@@ -24,6 +24,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 
@@ -370,7 +371,7 @@ public class CubeScanRangePlanner extends 
ScanRangePlannerBase {
                     result.add(new GTScanRange(range.pkStart, range.pkEnd, 
subFuzzyKeys));
                     startIndex = endIndex;
                 }
-                logger.debug("large FuzzyKeys split size : {0}", 
result.size());
+                logger.debug(String.format(Locale.ROOT, "large FuzzyKeys split 
size : %d", result.size()));
             } else {
                 result.add(range);
             }

Reply via email to