You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kylin.apache.org by GitBox <gi...@apache.org> on 2018/12/24 09:05:26 UTC

[GitHub] shaofengshi closed pull request #401: KYLIN-3597 fix sonar issues

shaofengshi closed pull request #401: KYLIN-3597 fix sonar issues
URL: https://github.com/apache/kylin/pull/401
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 def1e68116..dc3471b4b7 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 @@
 
         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 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 7f415de0bc..e8b0ae894a 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 GreedyAlgorithm(final long timeout, BenefitPolicy benefitPolicy, CuboidSt
 
         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 1a02e1aa3a..3095c8f708 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.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 @@ private GTScanRange mergeKeyRange(List<GTScanRange> ranges) {
                     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);
             }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services