ArafatKhan2198 commented on code in PR #6969:
URL: https://github.com/apache/ozone/pull/6969#discussion_r1803472815
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMDBInsightEndpoint.java:
##########
@@ -477,17 +429,90 @@ public Response getDeletedKeySummary() {
@GET
@Path("/deletePending")
public Response getDeletedKeyInfo(
- @DefaultValue(DEFAULT_FETCH_COUNT) @QueryParam(RECON_QUERY_LIMIT)
- int limit,
- @DefaultValue(StringUtils.EMPTY) @QueryParam(RECON_QUERY_PREVKEY)
- String prevKey) {
- KeyInsightInfoResponse
- deletedKeyInsightInfo = new KeyInsightInfoResponse();
- getPendingForDeletionKeyInfo(limit, prevKey,
- deletedKeyInsightInfo);
+ @DefaultValue(DEFAULT_FETCH_COUNT) @QueryParam(RECON_QUERY_LIMIT) int
limit,
+ @DefaultValue(StringUtils.EMPTY) @QueryParam(RECON_QUERY_PREVKEY) String
prevKey,
+ @DefaultValue(StringUtils.EMPTY) @QueryParam(RECON_QUERY_START_PREFIX)
String startPrefix) {
+
+ // Initialize the response object to hold the key information
+ KeyInsightInfoResponse deletedKeyInsightInfo = new
KeyInsightInfoResponse();
+
+ boolean keysFound = false;
+
+ try {
+ // Validate startPrefix if it's provided
+ if (isNotBlank(startPrefix) && !validateStartPrefix(startPrefix)) {
Review Comment:
The reason for adding a blank check along with validateStartPrefix is tied
to the default value I've assigned to startPrefix as an empty string ("") for
the /deletePending search. This choice is because both prevKey and startPrefix
have similar roles, but they are used differently. There are four key cases
where either prevKey or startPrefix can be empty or hold a value, and assigning
an empty string ("") to startPrefix—instead of "/"—helps handle these cases
more effectively.
The four cases are:
- prevKey provided, startPrefix empty:
In this case, we seek to the prevKey, skip it, and return the subsequent
records up to the limit.
- prevKey empty, startPrefix empty:
Here, we iterate from the start of the table and retrieve all records up to
the limit.
- startPrefix provided, prevKey empty:
In this scenario, we seek to the first key that matches the startPrefix and
return all matching keys up to the limit.
- startPrefix provided, prevKey provided:
In this case, we seek to the prevKey, skip it, and return the subsequent
keys that match the startPrefix, up to the limit.
By setting the default startPrefix as an empty string, it simplifies
handling these cases, especially in the forthcoming PR where I'll be
integrating open keys search in omDBInsightEndpoint. This ensures that prevKey
and startPrefix work smoothly together, making the logic easier to follow.
--
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]