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

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

shaofengshi commented on a change in pull request #252: KYLIN-3580 Avoid using 
entrySet to add elements
URL: https://github.com/apache/kylin/pull/252#discussion_r220143396
 
 

 ##########
 File path: 
core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/CuboidStatsUtil.java
 ##########
 @@ -87,7 +88,11 @@ 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
+        Iterator<Map.Entry<Long, Long>> entryIterator = 
statistics.entrySet().iterator();
 
 Review comment:
   Please use "for ( element : a set) " expression, that is more clear than 
this.

----------------------------------------------------------------
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