Skip to content

Commit

Permalink
KYLIN-3579 Replace keySet iterator with entrySet iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
Wayne1c committed Sep 30, 2018
1 parent 3c96469 commit 6bdbe40
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Expand Up @@ -60,15 +60,15 @@ private Map<Long, Long> initCuboidAggCostMap() {
cuboidAggCostMap.put(cuboid, getCuboidCost(cuboid));
}
}
Set<Long> mandatoryCuboidSetWithStats = cuboidAggCostMap.keySet();

//Initialize stats for selection cuboids
long baseCuboidCost = getCuboidCost(cuboidStats.getBaseCuboid());
for (Long cuboid : cuboidStats.getAllCuboidsForSelection()) {
long leastCost = baseCuboidCost;
for (Long cuboidTarget : mandatoryCuboidSetWithStats) {
if ((cuboid | cuboidTarget) == cuboidTarget) {
if (leastCost > cuboidAggCostMap.get(cuboidTarget)) {
leastCost = cuboidAggCostMap.get(cuboidTarget);
for (Map.Entry<Long, Long> cuboidTargetEntry : cuboidAggCostMap.entrySet()) {
if ((cuboid | cuboidTargetEntry.getKey()) == cuboidTargetEntry.getKey()) {
if (leastCost > cuboidTargetEntry.getValue()) {
leastCost = cuboidTargetEntry.getValue();
}
}
}
Expand Down Expand Up @@ -106,9 +106,9 @@ public CuboidBenefitModel.BenefitModel calculateBenefitTotal(Set<Long> cuboidsTo
}
double totalCostSaving = 0;
int benefitCount = 0;
for (Long cuboid : cuboidAggCostMapCopy.keySet()) {
if (cuboidAggCostMapCopy.get(cuboid) < processCuboidAggCostMap.get(cuboid)) {
totalCostSaving += processCuboidAggCostMap.get(cuboid) - cuboidAggCostMapCopy.get(cuboid);
for (Map.Entry<Long, Long> entry : cuboidAggCostMapCopy.entrySet()) {
if (entry.getValue() < processCuboidAggCostMap.get(entry.getKey())) {
totalCostSaving += processCuboidAggCostMap.get(entry.getKey()) - entry.getValue();
benefitCount++;
}
}
Expand Down
Expand Up @@ -168,13 +168,13 @@ public MeasureAggregator<?>[] newMetricsAggregators(ImmutableBitSet columns, Str

// deal with holistic distinct count
if (dependentMetricsMap != null) {
for (Integer child : dependentMetricsMap.keySet()) {
if (columns.get(child)) {
Integer parent = dependentMetricsMap.get(child);
for (Map.Entry<Integer, Integer> childEntry : dependentMetricsMap.entrySet()) {
if (columns.get(childEntry.getKey())) {
Integer parent = childEntry.getValue();
if (columns.get(parent) == false)
throw new IllegalStateException();

int childIdx = columns.trueBitIndexOf(child);
int childIdx = columns.trueBitIndexOf(childEntry.getKey());
int parentIdx = columns.trueBitIndexOf(parent);
result[childIdx].setDependentAggregator(result[parentIdx]);
}
Expand Down

0 comments on commit 6bdbe40

Please sign in to comment.