[ 
https://issues.apache.org/jira/browse/HDFS-16125?focusedWorklogId=623268&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-623268
 ]

ASF GitHub Bot logged work on HDFS-16125:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 15/Jul/21 20:09
            Start Date: 15/Jul/21 20:09
    Worklog Time Spent: 10m 
      Work Description: shvachko commented on a change in pull request #3197:
URL: https://github.com/apache/hadoop/pull/3197#discussion_r670727803



##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/PartitionedGSet.java
##########
@@ -275,17 +274,36 @@ private void printStats() {
    * modifying other partitions, while iterating through the current one.
    */
   private class EntryIterator implements Iterator<E> {
-    private final Iterator<K> keyIterator;
+    private Iterator<K> keyIterator;
     private Iterator<E> partitionIterator;
 
     public EntryIterator() {
       keyIterator = partitions.keySet().iterator();
-      K curKey = partitions.firstKey();
-      partitionIterator = getPartition(curKey).iterator();
+ 
+      if (!keyIterator.hasNext()) {
+        partitionIterator = null;
+        return;
+      }
+
+      K firstKey = keyIterator.next();
+      partitionIterator = partitions.get(firstKey).iterator();
     }
 
     @Override
     public boolean hasNext() {
+
+      // Special case: an iterator was created for an empty PartitionedGSet.
+      // Check whether new partitions have been added since then.
+      if (partitionIterator == null) {
+        if (partitions.size() == 0)

Review comment:
       Per Hadoop code style we should use curly braces even for one-operator 
body.

##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/PartitionedGSet.java
##########
@@ -298,10 +316,8 @@ public boolean hasNext() {
 
     @Override
     public E next() {
-      while(!partitionIterator.hasNext()) {
-        K curKey = keyIterator.next();
-        partitionIterator = getPartition(curKey).iterator();
-      }
+      if (!hasNext())

Review comment:
       Per Hadoop code style we should use curly braces even for one-operator 
body.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 623268)
    Time Spent: 50m  (was: 40m)

> [FGL] Fix the iterator for PartitionedGSet 
> -------------------------------------------
>
>                 Key: HDFS-16125
>                 URL: https://issues.apache.org/jira/browse/HDFS-16125
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>          Components: hdfs, namenode
>            Reporter: Xing Lin
>            Assignee: Xing Lin
>            Priority: Minor
>              Labels: pull-request-available
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> Iterator in PartitionedGSet would visit the first partition twice, since we 
> did not set the keyIterator to move to the first key during initialization.  
>  
> This is related to fgl: https://issues.apache.org/jira/browse/HDFS-14703



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to