xinglin commented on a change in pull request #3197:
URL: https://github.com/apache/hadoop/pull/3197#discussion_r669969202
##########
File path:
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/PartitionedGSet.java
##########
@@ -280,12 +279,22 @@ private void printStats() {
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() {
+
+ if (partitionIterator == null)
Review comment:
I don't think we need to handle that case: if one creates the Iterator()
for an empty PartitionedGSet, it makes sense the iterator returns zero elements
which represents a correct snapshot.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]