This is an automated email from the ASF dual-hosted git repository. nju_yaho pushed a commit to tag ebay-3.1.0-release-20200701 in repository https://gitbox.apache.org/repos/asf/kylin.git
commit 9167c1bf2263437039d6a50ecc339dfdfbdf2b47 Author: Zhong, Yanghong <nju_y...@apache.org> AuthorDate: Wed May 27 18:17:25 2020 +0800 KYLIN-4536 Add more logs --- .../algorithm/AbstractRecommendAlgorithm.java | 1 + .../generic/CombinedStoppingCondition.java | 9 ++++- .../cuboid/algorithm/greedy/GreedyAlgorithm.java | 46 ++++++++++++---------- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/AbstractRecommendAlgorithm.java b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/AbstractRecommendAlgorithm.java index 094b960..1635264 100755 --- a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/AbstractRecommendAlgorithm.java +++ b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/AbstractRecommendAlgorithm.java @@ -48,6 +48,7 @@ public abstract class AbstractRecommendAlgorithm implements CuboidRecommendAlgor @Override public List<Long> recommend(double expansionRate) { double spaceLimit = cuboidStats.getBaseCuboidSize() * expansionRate; + logger.info("space limit for the algorithm is {} with expansion rate {}", spaceLimit, expansionRate); return start(spaceLimit); } diff --git a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/generic/CombinedStoppingCondition.java b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/generic/CombinedStoppingCondition.java index a12c44d..cad3839 100755 --- a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/generic/CombinedStoppingCondition.java +++ b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/generic/CombinedStoppingCondition.java @@ -18,12 +18,16 @@ package org.apache.kylin.cube.cuboid.algorithm.generic; +import java.util.List; + import org.apache.commons.math3.genetics.Population; import org.apache.commons.math3.genetics.StoppingCondition; - -import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CombinedStoppingCondition implements StoppingCondition { + private static final Logger logger = LoggerFactory.getLogger(GeneticAlgorithm.class); + private List<StoppingCondition> conditions; public CombinedStoppingCondition(List<StoppingCondition> conditions) { @@ -34,6 +38,7 @@ public class CombinedStoppingCondition implements StoppingCondition { public boolean isSatisfied(Population population) { for (StoppingCondition condition : conditions) { if (condition.isSatisfied(population)) { + logger.info("Stopping condition {} is satisfied", condition); return true; } } 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 0a48eea..268223c 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 @@ -19,6 +19,7 @@ package org.apache.kylin.cube.cuboid.algorithm.greedy; import java.util.List; +import java.util.Locale; import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; @@ -74,32 +75,35 @@ public class GreedyAlgorithm extends AbstractRecommendAlgorithm { remaining.addAll(cuboidStats.getAllCuboidsForSelection()); long round = 0; - boolean doesRemainSpace = true; - while (!shouldCancel() && doesRemainSpace) { - // Choose one cuboId having the maximum benefit per unit space in all available list + while (!shouldCancel()) { + // Choose one cuboid having the maximum benefit per unit space in all available list CuboidBenefitModel best = recommendBestOne(); - // If return null, then we should finish the process and return + if (best == null) { + logger.info("Greedy algorithm ends due to cannot find next best one"); + break; + } // If we finally find the cuboid selected does not meet a minimum threshold of benefit (for // example, a cuboid with 0.99M roll up from a parent cuboid with 1M // rows), then we should finish the process and return - if (best != null && benefitPolicy.ifEfficient(best)) { - remainingSpace -= cuboidStats.getCuboidSize(best.getCuboidId()); - - // If we finally find there is no remaining space, then we should finish the process and return - if (remainingSpace > 0) { - selected.add(best.getCuboidId()); - remaining.remove(best.getCuboidId()); - benefitPolicy.propagateAggregationCost(best.getCuboidId(), selected); - round++; - if (logger.isTraceEnabled()) { - logger.trace("Recommend in round {} : {}", round, best); - } - } else { - doesRemainSpace = false; - } - } else { - doesRemainSpace = false; + if (!benefitPolicy.ifEfficient(best)) { + logger.info("Greedy algorithm ends due to the benefit of the best one is not efficient {}", + best.getBenefit()); + break; + } + + remainingSpace -= cuboidStats.getCuboidSize(best.getCuboidId()); + // If we finally find there is no remaining space, then we should finish the process and return + if (remainingSpace <= 0) { + logger.info("Greedy algorithm ends due to there's no remaining space"); + break; + } + selected.add(best.getCuboidId()); + remaining.remove(best.getCuboidId()); + benefitPolicy.propagateAggregationCost(best.getCuboidId(), selected); + round++; + if (logger.isTraceEnabled()) { + logger.trace(String.format(Locale.ROOT, "Recommend in round %d : %s", round, best.toString())); } }