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/27 02:09:27 UTC

[GitHub] shaofengshi closed pull request #418: KYLIN-3597 fix sonar problems

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

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 90eafdd275..ec2f4965aa 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 @@
 
 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 @@
             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 @@
                     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);


 

----------------------------------------------------------------
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