You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2018/12/27 02:09:30 UTC

[kylin] branch master updated: KYLIN-3597 fix sonar problems

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 49e835a  KYLIN-3597 fix sonar problems
49e835a is described below

commit 49e835a3b317ee79ecd4ed1ebbb25409e0ce6718
Author: Lijun Cao <64...@qq.com>
AuthorDate: Thu Dec 27 09:17:16 2018 +0800

    KYLIN-3597 fix sonar problems
---
 .../kylin/cube/cuboid/algorithm/CuboidStatsUtil.java   | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 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 90eafdd..ec2f496 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
@@ -34,6 +34,10 @@ import com.google.common.collect.Maps;
 
 public class CuboidStatsUtil {
 
+    private CuboidStatsUtil() {
+        throw new IllegalStateException("Class CuboidStatsUtil is an utility class !");
+    }
+
     /**
      * According to the cuboid hit frequencies and query uncertainty ratio
      * calculate each cuboid hit probability
@@ -57,8 +61,11 @@ public class CuboidStatsUtil {
             for (Long cuboid : selectionCuboidSet) {
                 //Calculate hit probability for each cuboid
                 if (hitFrequencyMap.get(cuboid) != null) {
-                    cuboidHitProbabilityMap.put(cuboid, unitUncertainProb
-                            + (1 - queryUncertaintyRatio) * hitFrequencyMap.get(cuboid) / totalHitFrequency);
+                    if (totalHitFrequency != 0)
+                        cuboidHitProbabilityMap.put(cuboid, unitUncertainProb
+                                + (1 - queryUncertaintyRatio) * hitFrequencyMap.get(cuboid) / totalHitFrequency);
+                    else
+                        throw new ArithmeticException("/ by zero");
                 } else {
                     cuboidHitProbabilityMap.put(cuboid, unitUncertainProb);
                 }
@@ -118,8 +125,11 @@ public class CuboidStatsUtil {
                     nEffective++;
                 }
             }
-
-            srcCuboidsStats.put(cuboid, totalEstRowCount / nEffective);
+            
+            if (nEffective != 0)
+                srcCuboidsStats.put(cuboid, totalEstRowCount / nEffective);
+            else
+                throw new ArithmeticException("/ by zero");
         }
         srcCuboidsStats.remove(0L);
         adjustCuboidStats(srcCuboidsStats, statistics);