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


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMDBInsightSearchEndpoint.java:
##########
@@ -325,46 +323,93 @@ 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.
+   * In the DeletedTable both the fso and non-fso keys are stored in a similar 
format, this endpoint compiles
+   * a list of keys that match the given prefix along with their data sizes.
    *
-   * @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.
+   * 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 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")

Review Comment:
   it seems /openkeys also duplicated, we can track to fix it.
   
   End-point functionality can not be duplicated by just purpose. If its 
required to have separate api, then implementation must be one only, call 
internally same.
   
   prevKey search for first record (with additional case of skip that matching 
record). This is used in pagination context.
   searchkey search for first record to be returned (this search can be partial 
also). But both can not be used together.
   
   The new api have extra parameter of searchKey which is optional (can not use 
both searchkey and prvKey together).
   So either discard previous api to use new one. Or extend previous api to 
include searchKey.
   



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