dombizita commented on code in PR #6969:
URL: https://github.com/apache/ozone/pull/6969#discussion_r1731157349


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMDBInsightSearchEndpoint.java:
##########
@@ -325,46 +332,108 @@ public String convertToObjectPath(String prevKeyPrefix) 
throws IOException {
     return prevKeyPrefix;
   }
 
-
   /**
-   * Common method to retrieve keys from a table based on a search prefix and 
a limit.
+   * Performs a search for deleted keys in the Ozone Manager DeletedTable 
using a specified search prefix.
+   * This endpoint searches across both File System Optimized (FSO) and Object 
Store (non-FSO) layouts,
+   * compiling a list of keys that match the given prefix along with their 
data sizes.
+   *
+   * The search prefix must start from the bucket level 
('/volumeName/bucketName/') or any specific directory
+   * or key level (e.g., '/volA/bucketA/dir1' for everything under 'dir1' 
inside 'bucketA' of 'volA').
+   * The search operation matches the prefix against the start of keys' names 
within the OM DB DeletedTable.
+   *
+   * Example Usage:
+   * 1. A startPrefix of "/volA/bucketA/" retrieves every key under bucket 
'bucketA' in volume 'volA'.
+   * 2. Specifying "/volA/bucketA/dir1" focuses the search within 'dir1' 
inside 'bucketA' of 'volA'.
    *
-   * @param table       The table to retrieve keys from.
-   * @param startPrefix The search prefix to match keys against.
-   * @param limit       The maximum number of keys to retrieve.
+   * @param startPrefix The prefix for searching keys, starting from the 
bucket level or any specific path.
+   * @param limit       Limits the number of returned keys.
    * @param prevKey     The key to start after for the next set of records.
-   * @return A map of keys and their corresponding OmKeyInfo objects.
-   * @throws IOException If there are problems accessing the table.
+   * @return A KeyInsightInfoResponse, containing matching keys and their data 
sizes.
+   * @throws IOException On failure to access the OM database or process the 
operation.
    */
-  private Map<String, OmKeyInfo> retrieveKeysFromTable(
-      Table<String, OmKeyInfo> table, String startPrefix, int limit, String 
prevKey)
-      throws IOException {
-    Map<String, OmKeyInfo> matchedKeys = new LinkedHashMap<>();
-    try (TableIterator<String, ? extends Table.KeyValue<String, OmKeyInfo>> 
keyIter = table.iterator()) {
-      // If a previous key is provided, seek to the previous key and skip it.
-      if (!prevKey.isEmpty()) {
-        keyIter.seek(prevKey);
-        if (keyIter.hasNext()) {
-          // Skip the previous key
-          keyIter.next();
-        }
-      } else {
-        // If no previous key is provided, start from the search prefix.
-        keyIter.seek(startPrefix);
+  @GET
+  @Path("/deletePending/search")
+  public Response searchDeletedKeys(

Review Comment:
   The beginning and ending of this method have a lot in common with 
`searchOpenKeys`. 
   
https://github.com/apache/ozone/blob/350a340277dbb94f7a3157594d1b705f33c1d195/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMDBInsightSearchEndpoint.java#L110-L117
   Can we extract them? Do you think it would make sense? 



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