swamirishi commented on code in PR #9423:
URL: https://github.com/apache/ozone/pull/9423#discussion_r2586204708


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java:
##########
@@ -2295,15 +2296,33 @@ private <T extends WithParentObjectId> DeleteKeysResult 
gatherSubPathsWithIterat
     List<OmKeyInfo> keyInfos = new ArrayList<>();
     String seekFileInDB = metadataManager.getOzonePathKey(volumeId, bucketId, 
parentInfo.getObjectID(), "");
     try (TableIterator<String, ? extends KeyValue<String, T>> iterator = 
table.iterator(seekFileInDB)) {
-      while (iterator.hasNext() && remainingNum > 0) {
+      String startKey = null;
+      String lastLoopExclusiveKey = 
getLexicographicallyHigherString(seekFileInDB);
+      List<DeleteKeysResult.ExclusiveRange> keyRanges = new ArrayList<>();
+      while (iterator.hasNext()) {
         KeyValue<String, T> entry = iterator.next();
         KeyValue<String, OmKeyInfo> keyInfo = 
deleteKeyTransformer.apply(entry);
+        if (remainingNum <= 0) {
+          lastLoopExclusiveKey = keyInfo.getKey();
+          break;
+        }
         if (deleteKeyFilter.apply(keyInfo)) {
           keyInfos.add(keyInfo.getValue());
           remainingNum--;
+          if (startKey == null) {
+            startKey = keyInfo.getKey();
+          }
+        } else {
+          if (startKey != null) {
+            keyRanges.add(new DeleteKeysResult.ExclusiveRange(startKey, 
keyInfo.getKey()));
+          }
+          startKey = null;
         }
       }
-      return new DeleteKeysResult(keyInfos, !iterator.hasNext());
+      if (startKey != null) {
+        keyRanges.add(new DeleteKeysResult.ExclusiveRange(startKey, 
lastLoopExclusiveKey));
+      }
+      return new DeleteKeysResult(keyInfos, keyRanges, !iterator.hasNext());

Review Comment:
   this iterator.hasNext() is wrong since the last value at line 2306 has been 
skipped



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

Reply via email to