[ 
https://issues.apache.org/jira/browse/KYLIN-3580?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628585#comment-16628585
 ] 

ASF GitHub Bot commented on KYLIN-3580:
---------------------------------------

shaofengshi closed pull request #252: KYLIN-3580 Avoid using entrySet to add 
elements
URL: https://github.com/apache/kylin/pull/252
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/CuboidStatsUtil.java
 
b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/CuboidStatsUtil.java
index c2683df993..def1e68116 100644
--- 
a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/CuboidStatsUtil.java
+++ 
b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/CuboidStatsUtil.java
@@ -87,7 +87,10 @@ public int compare(Map.Entry<Long, Long> o1, Map.Entry<Long, 
Long> o2) {
                         return o1.getValue().compareTo(o2.getValue());
                     }
                 });
-        sortedStatsSet.addAll(statistics.entrySet());
+        //sortedStatsSet.addAll(statistics.entrySet()); KYLIN-3580
+        for(Map.Entry<Long, Long> entry : statistics.entrySet()){
+            sortedStatsSet.add(entry);
+        }
         for (Long cuboid : mandatoryCuboidSet) {
             if (statistics.get(cuboid) == null) {
                 // Get estimate row count for mandatory cuboid


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> CuboidStatsUtil#complementRowCountForMandatoryCuboids uses entrySet to add 
> elements
> -----------------------------------------------------------------------------------
>
>                 Key: KYLIN-3580
>                 URL: https://issues.apache.org/jira/browse/KYLIN-3580
>             Project: Kylin
>          Issue Type: Bug
>            Reporter: Ted Yu
>            Assignee: Lijun Cao
>            Priority: Major
>             Fix For: v2.6.0
>
>
> Here is related code:
> {code}
>         sortedStatsSet.addAll(statistics.entrySet());
> {code}
> The entrySet() method is allowed to return a view of the underlying Map in 
> which a single Entry object is reused and returned during the iteration.
> When iterating through such a Map, the Entry value is only valid until you 
> advance to the next iteration.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to