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


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java:
##########
@@ -186,6 +206,71 @@ public static DBCheckpoint createOmSnapshotCheckpoint(
     return dbCheckpoint;
   }
 
+  /**
+   * Helper method to delete keys in the snapshot scope from active DB's
+   * deletedTable.
+   *
+   * @param omMetadataManager OMMetadataManager instance
+   * @param volumeName volume name
+   * @param bucketName bucket name
+   */
+  private static void deleteKeysInSnapshotScopeFromDTableInternal(
+      OMMetadataManager omMetadataManager,
+      String volumeName,
+      String bucketName) throws IOException {
+
+    // Range delete start key (inclusive)
+    String beginKey =
+        omMetadataManager.getOzoneKey(volumeName, bucketName, "");
+
+    // Range delete end key (exclusive) to be found
+    String endKey;
+
+    try (TableIterator<String,
+        ? extends Table.KeyValue<String, RepeatedOmKeyInfo>>
+        keyIter = omMetadataManager.getDeletedTable().iterator()) {
+
+      // TODO: Start timer for perf tracking
+      keyIter.seek(beginKey);
+      // Continue only when there are entries of snapshot (bucket) scope
+      // in deletedTable in the first place
+      if (!keyIter.hasNext()) {
+        // Use null as a marker. No need to do deleteRange() at all.
+        endKey = null;
+      } else {
+        // Remember the last key with a matching prefix
+        endKey = keyIter.next().getKey();
+
+        // Loop until prefix mismatches.
+        // TODO: Room for optimization? Seek next predicted bucket name.
+        while (keyIter.hasNext()) {

Review Comment:
   `seekToLast()` doesn't take a param. It goes to the last entry in the table, 
not the last entry that matches the given prefix.



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java:
##########
@@ -186,6 +206,71 @@ public static DBCheckpoint createOmSnapshotCheckpoint(
     return dbCheckpoint;
   }
 
+  /**
+   * Helper method to delete keys in the snapshot scope from active DB's
+   * deletedTable.
+   *
+   * @param omMetadataManager OMMetadataManager instance
+   * @param volumeName volume name
+   * @param bucketName bucket name
+   */
+  private static void deleteKeysInSnapshotScopeFromDTableInternal(
+      OMMetadataManager omMetadataManager,
+      String volumeName,
+      String bucketName) throws IOException {
+
+    // Range delete start key (inclusive)
+    String beginKey =
+        omMetadataManager.getOzoneKey(volumeName, bucketName, "");
+
+    // Range delete end key (exclusive) to be found
+    String endKey;
+
+    try (TableIterator<String,
+        ? extends Table.KeyValue<String, RepeatedOmKeyInfo>>
+        keyIter = omMetadataManager.getDeletedTable().iterator()) {
+
+      // TODO: Start timer for perf tracking
+      keyIter.seek(beginKey);
+      // Continue only when there are entries of snapshot (bucket) scope
+      // in deletedTable in the first place
+      if (!keyIter.hasNext()) {
+        // Use null as a marker. No need to do deleteRange() at all.
+        endKey = null;
+      } else {
+        // Remember the last key with a matching prefix
+        endKey = keyIter.next().getKey();
+
+        // Loop until prefix mismatches.
+        // TODO: Room for optimization? Seek next predicted bucket name.
+        while (keyIter.hasNext()) {

Review Comment:
   `seekToLast()` doesn't take a param. It goes to the last entry in 
`deletedTable`, not the last entry that matches the given prefix.



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