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


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ContainerEndpoint.java:
##########
@@ -241,60 +227,62 @@ public Response getKeysForContainer(
     }
 
     try {
-      Map<ContainerKeyPrefix, Integer> containerKeyPrefixMap =
-          
reconContainerMetadataManager.getKeyPrefixesForContainer(containerID, 
prevKeyPrefix, limit);
-      // Get set of Container-Key mappings for given containerId.
-      for (ContainerKeyPrefix containerKeyPrefix : containerKeyPrefixMap
-          .keySet()) {
-
-        // Directly calling getSkipCache() on the Key/FileTable table
-        // instead of iterating since only full keys are supported now. We will
-        // try to get the OmKeyInfo object by searching the KEY_TABLE table 
with
-        // the key prefix. If it's not found, we will then search the 
FILE_TABLE
-        OmKeyInfo omKeyInfo = 
omMetadataManager.getKeyTable(BucketLayout.LEGACY)
-            .getSkipCache(containerKeyPrefix.getKeyPrefix());
-        if (omKeyInfo == null) {
-          omKeyInfo =
-              omMetadataManager.getKeyTable(BucketLayout.FILE_SYSTEM_OPTIMIZED)
-                  .getSkipCache(containerKeyPrefix.getKeyPrefix());
+      if (StringUtils.isNotBlank(startPrefix)) {
+
+        // Ensure startPrefix starts with '/' for non-empty values.
+        // Validate startPrefix if it's provided
+        if (isNotBlank(startPrefix) && !validateStartPrefix(startPrefix)) {
+          return createBadRequestResponse("Invalid startPrefix: Path must be 
at the bucket level or deeper.");
         }
 
-        if (null != omKeyInfo) {
-          // Filter keys by version.
-          List<OmKeyLocationInfoGroup> matchedKeys = omKeyInfo
-              .getKeyLocationVersions()
-              .stream()
-              .filter(k -> (k.getVersion() ==
-                  containerKeyPrefix.getKeyVersion()))
-              .collect(Collectors.toList());
-
-          List<ContainerBlockMetadata> blockIds =
-              getBlocks(matchedKeys, containerID);
-
-          String ozoneKey = containerKeyPrefix.getKeyPrefix();
-          lastKey = ozoneKey;
-          if (keyMetadataMap.containsKey(ozoneKey)) {
-            keyMetadataMap.get(ozoneKey).getVersions()
-                .add(containerKeyPrefix.getKeyVersion());
-
-            keyMetadataMap.get(ozoneKey).getBlockIds()
-                .put(containerKeyPrefix.getKeyVersion(), blockIds);
+        // Convert the provided startPrefix to object-id path if bucket layout 
is FSO.
+        boolean isFSO = isFSOBucket(startPrefix);
+        if (isFSO) {
+          Table<String, OmKeyInfo> fileTable = 
omMetadataManager.getKeyTable(BucketLayout.FILE_SYSTEM_OPTIMIZED);
+          startPrefix = ReconUtils.convertToObjectPathForSearch(
+              startPrefix, omMetadataManager, reconNamespaceSummaryManager, 
reconSCM, fileTable);
+        }
+
+        // If a startPrefix is provided, fetch only the specific matching 
record(s).
+        List<ContainerKeyPrefix> keyRecords =

Review Comment:
   The behavior is not consistent if previousKeyPrefix is given. there its not 
getting sub-directory in else part.



##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ContainerEndpoint.java:
##########
@@ -209,25 +207,13 @@ public Response getContainers(
   }
 
 
-  /**
-   * Return @{@link org.apache.hadoop.ozone.recon.api.types.KeyMetadata} for
-   * all keys that belong to the container identified by the id param
-   * starting from the given "prev-key" query param for the given "limit".
-   * The given prevKeyPrefix is skipped from the results returned.
-   *
-   * @param containerID   the given containerID.
-   * @param limit         max no. of keys to get.
-   * @param prevKeyPrefix the key prefix after which results are returned.
-   * @return {@link Response}
-   */
   @GET
   @Path("/{id}/keys")
   public Response getKeysForContainer(
       @PathParam("id") Long containerID,
-      @DefaultValue(DEFAULT_FETCH_COUNT) @QueryParam(RECON_QUERY_LIMIT)
-          int limit,
-      @DefaultValue(StringUtils.EMPTY) @QueryParam(RECON_QUERY_PREVKEY)
-          String prevKeyPrefix) {
+      @DefaultValue(DEFAULT_FETCH_COUNT) @QueryParam(RECON_QUERY_LIMIT) int 
limit,
+      @DefaultValue(StringUtils.EMPTY) @QueryParam(RECON_QUERY_PREVKEY) String 
prevKeyPrefix,
+      @DefaultValue(StringUtils.EMPTY) @QueryParam(RECON_QUERY_START_PREFIX) 
String startPrefix) {

Review Comment:
   in java doc, we can add comment about prevKeyPrefix and startPrefix format, 
they are of different format for fso.



-- 
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-unsubscr...@ozone.apache.org

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


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

Reply via email to