[ 
https://issues.apache.org/jira/browse/HDDS-1685?focusedWorklogId=268976&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-268976
 ]

ASF GitHub Bot logged work on HDDS-1685:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 28/Jun/19 01:56
            Start Date: 28/Jun/19 01:56
    Worklog Time Spent: 10m 
      Work Description: avijayanhwx commented on pull request #987: HDDS-1685. 
Recon: Add support for 'start' query param to containers…
URL: https://github.com/apache/hadoop/pull/987#discussion_r298426673
 
 

 ##########
 File path: 
hadoop-ozone/ozone-recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/ContainerDBServiceProviderImpl.java
 ##########
 @@ -128,23 +128,65 @@ public Integer getCountForForContainerKeyPrefix(
   }
 
   /**
-   * Use the DB's prefix seek iterator to start the scan from the given
-   * container ID prefix.
+   * Get key prefixes for the given container ID.
    *
    * @param containerId the given containerId.
    * @return Map of (Key-Prefix,Count of Keys).
    */
   @Override
   public Map<ContainerKeyPrefix, Integer> getKeyPrefixesForContainer(
       long containerId) throws IOException {
+    // set the default startKeyPrefix to empty string
+    return getKeyPrefixesForContainer(containerId, StringUtils.EMPTY);
+  }
+
+  /**
+   * Use the DB's prefix seek iterator to start the scan from the given
+   * container ID and prev key prefix. The prev key prefix is skipped from
+   * the result.
+   *
+   * @param containerId the given containerId.
+   * @param prevKeyPrefix the given key prefix to start the scan from.
+   * @return Map of (Key-Prefix,Count of Keys).
+   */
+  @Override
+  public Map<ContainerKeyPrefix, Integer> getKeyPrefixesForContainer(
+      long containerId, String prevKeyPrefix) throws IOException {
 
     Map<ContainerKeyPrefix, Integer> prefixes = new LinkedHashMap<>();
     TableIterator<ContainerKeyPrefix, ? extends KeyValue<ContainerKeyPrefix,
         Integer>> containerIterator = containerKeyTable.iterator();
-    containerIterator.seek(new ContainerKeyPrefix(containerId));
+    ContainerKeyPrefix seekKey;
+    boolean skipPrevKey = false;
+    if (StringUtils.isNotBlank(prevKeyPrefix)) {
+      skipPrevKey = true;
+      seekKey = new ContainerKeyPrefix(containerId, prevKeyPrefix);
+    } else {
+      seekKey = new ContainerKeyPrefix(containerId);
+    }
+    KeyValue<ContainerKeyPrefix, Integer> seekKeyValue =
+        containerIterator.seek(seekKey);
+
+    // check if RocksDB was able to seek correctly to the given key prefix
+    // if not, then return empty result
+    // In case of an empty prevKeyPrefix, all the keys in the container are
+    // returned
+    if (seekKeyValue == null ||
+        (StringUtils.isNotBlank(prevKeyPrefix) &&
 
 Review comment:
   The assumption is that, the previous key prefix being passed in is always 
present in our Rocksdb. The UI container key table probably passes in only 
valid key prefixes for pagination. But maybe the API can support an arbitrary 
previous key prefix also. We can refine this in subsequent changes when the use 
cases are more defined.
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 268976)
    Time Spent: 2h 40m  (was: 2.5h)

> Recon: Add support for "start" query param to containers and containers/{id} 
> endpoints
> --------------------------------------------------------------------------------------
>
>                 Key: HDDS-1685
>                 URL: https://issues.apache.org/jira/browse/HDDS-1685
>             Project: Hadoop Distributed Data Store
>          Issue Type: Sub-task
>          Components: Ozone Recon
>    Affects Versions: 0.4.0
>            Reporter: Vivek Ratnavel Subramanian
>            Assignee: Vivek Ratnavel Subramanian
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 2h 40m
>  Remaining Estimate: 0h
>
> * Support "start" query param to seek to the given key in RocksDB.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to