Skip to content

Commit

Permalink
KYLIN-3597 fix sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
whuwb authored and shaofengshi committed Dec 24, 2018
1 parent 5982bb7 commit 3b9c5a5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,33 +55,34 @@ public static Set<Long> generateMandatoryCuboidSet(Map<Long, Long> statistics, M

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
* */
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ public List<Long> start(double spaceLimit) {

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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -370,7 +371,7 @@ private List<GTScanRange> splitFuzzyKeys(List<GTScanRange> mergedRanges) {
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);
}
Expand Down

0 comments on commit 3b9c5a5

Please sign in to comment.