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 32a3150 KYLIN-3597 fix sonar issues 32a3150 is described below commit 32a31506ce609eeabe3c88544a2bcf742a5c5599 Author: whuwb <skywind2...@gmail.com> AuthorDate: Fri Dec 14 14:45:39 2018 +0800 KYLIN-3597 fix sonar issues --- .../java/org/apache/kylin/common/util/SSHClient.java | 7 ++++--- .../kylin/cube/cuboid/algorithm/CuboidRecommender.java | 17 +++++++++-------- .../kylin/storage/gtrecord/CubeScanRangePlanner.java | 8 ++------ 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/core-common/src/main/java/org/apache/kylin/common/util/SSHClient.java b/core-common/src/main/java/org/apache/kylin/common/util/SSHClient.java index 2672920..b5d6459 100644 --- a/core-common/src/main/java/org/apache/kylin/common/util/SSHClient.java +++ b/core-common/src/main/java/org/apache/kylin/common/util/SSHClient.java @@ -42,6 +42,7 @@ import com.jcraft.jsch.Session; public class SSHClient { protected static final org.slf4j.Logger logger = LoggerFactory.getLogger(SSHClient.class); + private static final String ERROR_IN_CHECK_ACK = "Error in checkAck()"; private String hostname; private int port; @@ -97,7 +98,7 @@ public class SSHClient { out.write(command.getBytes(StandardCharsets.UTF_8)); out.flush(); if (checkAck(in) != 0) { - throw new Exception("Error in checkAck()"); + throw new Exception(ERROR_IN_CHECK_ACK); } } @@ -115,7 +116,7 @@ public class SSHClient { out.write(command.getBytes(StandardCharsets.UTF_8)); out.flush(); if (checkAck(in) != 0) { - throw new Exception("Error in checkAck()"); + throw new Exception(ERROR_IN_CHECK_ACK); } // send a content of lfile @@ -134,7 +135,7 @@ public class SSHClient { out.write(buf, 0, 1); out.flush(); if (checkAck(in) != 0) { - throw new Exception("Error in checkAck()"); + throw new Exception(ERROR_IN_CHECK_ACK); } out.close(); diff --git a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/CuboidRecommender.java b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/CuboidRecommender.java index 057f7e8..54c6764 100644 --- a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/CuboidRecommender.java +++ b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/CuboidRecommender.java @@ -20,6 +20,7 @@ package org.apache.kylin.cube.cuboid.algorithm; import java.io.IOException; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; @@ -97,20 +98,20 @@ public class CuboidRecommender { true); if (recommendCuboid != null) { - logger.info("Add recommend cuboids for " + key + " to cache"); + logger.info(String.format(Locale.ROOT, "Add recommend cuboids for %s to cache", key)); cuboidRecommendCache.put(key, recommendCuboid); } return recommendCuboid; } catch (Exception e) { cuboidRecommendCache.invalidate(key); - logger.error("Failed to get recommend cuboids for " + key + " in cache", e); + logger.error(String.format(Locale.ROOT, "Failed to get recommend cuboids for %s in cache", key), e); throw e; } } }); } catch (ExecutionException e) { - logger.error("Failed to get recommend cuboids for " + key); + logger.error(String.format(Locale.ROOT, "Failed to get recommend cuboids for %s", key)); } } return results; @@ -121,9 +122,9 @@ public class CuboidRecommender { */ public Map<Long, Long> getRecommendCuboidList(CuboidStats cuboidStats, KylinConfig kylinConf, boolean ifForceRecommend) { - long Threshold1 = 1L << kylinConf.getCubePlannerAgreedyAlgorithmAutoThreshold(); - long Threshold2 = 1L << kylinConf.getCubePlannerGeneticAlgorithmAutoThreshold(); - if (Threshold1 >= Threshold2) { + long threshold1 = 1L << kylinConf.getCubePlannerAgreedyAlgorithmAutoThreshold(); + long threshold2 = 1L << kylinConf.getCubePlannerGeneticAlgorithmAutoThreshold(); + if (threshold1 >= threshold2) { logger.error("Invalid Cube Planner Algorithm configuration"); return null; } @@ -134,7 +135,7 @@ public class CuboidRecommender { BenefitPolicy benefitPolicy = new PBPUSCalculator(cuboidStats); CuboidRecommendAlgorithm algorithm = null; - if (allCuboidCount <= Threshold2) { + if (allCuboidCount <= threshold2) { algorithm = new GreedyAlgorithm(-1, benefitPolicy, cuboidStats); } else { algorithm = new GeneticAlgorithm(-1, benefitPolicy, cuboidStats); @@ -161,7 +162,7 @@ public class CuboidRecommender { } } - if (!ifForceRecommend && allCuboidCount <= Threshold1) { + if (!ifForceRecommend && allCuboidCount <= threshold1) { return null; } return recommendCuboidsWithStats; 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 229ef01..1a02e1a 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 @@ -167,7 +167,7 @@ public class CubeScanRangePlanner extends ScanRangePlannerBase { public GTScanRequest planScanRequest() { GTScanRequest scanRequest; List<GTScanRange> scanRanges = this.planScanRanges(); - if (scanRanges != null && scanRanges.size() != 0) { + if (scanRanges != null && !scanRanges.isEmpty()) { scanRequest = new GTScanRequestBuilder().setInfo(gtInfo).setRanges(scanRanges).setDimensions(gtDimensions) .setAggrGroupBy(gtAggrGroups).setAggrMetrics(gtAggrMetrics).setAggrMetricsFuncs(gtAggrFuncs) .setFilterPushDown(gtFilter)// @@ -260,10 +260,6 @@ public class CubeScanRangePlanner extends ScanRangePlannerBase { List<Map<Integer, ByteArray>> fuzzyValueCombinations = FuzzyValueCombination.calculate(fuzzyValueSet, maxFuzzyKeys); for (Map<Integer, ByteArray> fuzzyValue : fuzzyValueCombinations) { - // BitSet bitSet = new BitSet(gtInfo.getColumnCount()); - // for (Map.Entry<Integer, ByteArray> entry : fuzzyValue.entrySet()) { - // bitSet.set(entry.getKey()); - // } GTRecord fuzzy = new GTRecord(gtInfo); for (Map.Entry<Integer, ByteArray> entry : fuzzyValue.entrySet()) { fuzzy.set(entry.getKey(), entry.getValue()); @@ -374,7 +370,7 @@ public class CubeScanRangePlanner extends ScanRangePlannerBase { result.add(new GTScanRange(range.pkStart, range.pkEnd, subFuzzyKeys)); startIndex = endIndex; } - logger.debug("large FuzzyKeys split size : " + result.size()); + logger.debug("large FuzzyKeys split size : {0}", result.size()); } else { result.add(range); }