sodonnel commented on code in PR #4967:
URL: https://github.com/apache/ozone/pull/4967#discussion_r1243550458


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerManagerImpl.java:
##########
@@ -471,4 +444,37 @@ public ContainerStateManager getContainerStateManager() {
   public SCMHAManager getSCMHAManager() {
     return haManager;
   }
+
+  private static List<ContainerID> filterSortAndLimit(

Review Comment:
   I think this could be made more efficient. The current algorithm takes the 
set, forms a new list of all elements. Then filters, sorted and returns the 
range.
   
   Using an adaption of the priorityQueue technique here - 
https://www.baeldung.com/java-array-top-elements
   
   We could avoid the copy from set to list, and the potentially large sort.
   
   ```
   for (contaienrID cid : set) {
       if (id > startID)
           maxHeap.add(number);
   
           if (maxHeap.size() > count) {
               maxHeap.poll();
           }
       }
       return new ArrayList<>(maxHeap);
       // Might need reversed, I am not sure
   });
   ```
   
   I think this would be more memory efficient on large container sets, and 
should perform better than the full sort



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