You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/08/24 10:28:28 UTC

[GitHub] [ozone] smengcl commented on a diff in pull request #3082: HDDS-6312. Use KeyPrefixContainer table to accelerate the process of DELETE/UPDATE events

smengcl commented on code in PR #3082:
URL: https://github.com/apache/ozone/pull/3082#discussion_r953625656


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/ContainerKeyMapperTask.java:
##########
@@ -252,48 +253,54 @@ private void handleDeleteOMKeyEvent(String key,
                                       List<ContainerKeyPrefix>
                                           deletedContainerKeyList)
       throws IOException {
+
     Set<ContainerKeyPrefix> keysToBeDeleted = new HashSet<>();
-    try (TableIterator<ContainerKeyPrefix,
-        ? extends Table.KeyValue<ContainerKeyPrefix, Integer>> containerIterator
-             = reconContainerMetadataManager.getContainerTableIterator()) {
+    try (TableIterator<KeyPrefixContainer, ? extends
+        Table.KeyValue<KeyPrefixContainer, Integer>> keyContainerIterator =
+             reconContainerMetadataManager.getKeyContainerTableIterator()) {
 
       // Check if we have keys in this container in the DB
-      while (containerIterator.hasNext()) {
-        Table.KeyValue<ContainerKeyPrefix, Integer> keyValue =
-            containerIterator.next();
+      keyContainerIterator.seek(new KeyPrefixContainer(key));
+      while (keyContainerIterator.hasNext()) {
+        Table.KeyValue<KeyPrefixContainer, Integer> keyValue =
+            keyContainerIterator.next();
         String keyPrefix = keyValue.getKey().getKeyPrefix();
         if (keyPrefix.equals(key)) {
-          keysToBeDeleted.add(keyValue.getKey());
+          if (keyValue.getKey().getContainerId() != -1) {
+            keysToBeDeleted.add(keyValue.getKey().toContainerKeyPrefix());
+          }
+        } else {
+          break;
         }
       }
-    }

Review Comment:
   Hmm, why not release `keyContainerIterator` here?
   Do we have other reasons to keep `keyContainerIterator` til the method end?



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org