You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2018/09/30 03:07:33 UTC

[kylin] 02/02: KYLIN-3579 Replace keySet iterator with entrySet iterator

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

commit 8db033097833be5118655a6d88a5b96e862055ae
Author: chao long <wa...@qq.com>
AuthorDate: Tue Sep 25 15:46:07 2018 +0800

    KYLIN-3579 Replace keySet iterator with entrySet iterator
---
 .../kylin/cube/cuboid/algorithm/BPUSCalculator.java      | 16 ++++++++--------
 .../org/apache/kylin/cube/gridtable/CubeCodeSystem.java  |  8 ++++----
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/BPUSCalculator.java b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/BPUSCalculator.java
index ea91c6c..6316858 100755
--- a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/BPUSCalculator.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/BPUSCalculator.java
@@ -60,15 +60,15 @@ public class BPUSCalculator implements BenefitPolicy {
                 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();
                     }
                 }
             }
@@ -106,9 +106,9 @@ public class BPUSCalculator implements BenefitPolicy {
         }
         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++;
             }
         }
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/gridtable/CubeCodeSystem.java b/core-cube/src/main/java/org/apache/kylin/cube/gridtable/CubeCodeSystem.java
index 3577476..4c71fea 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/gridtable/CubeCodeSystem.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/gridtable/CubeCodeSystem.java
@@ -168,13 +168,13 @@ public class CubeCodeSystem implements IGTCodeSystem {
 
         // 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]);
                 }