junkaixue commented on code in PR #2888:
URL: https://github.com/apache/helix/pull/2888#discussion_r1729521273


##########
helix-core/src/main/java/org/apache/helix/controller/dataproviders/ResourceControllerDataProvider.java:
##########
@@ -583,6 +587,38 @@ public Set<CapacityNode> getSimpleCapacitySet() {
     return _simpleCapacitySet;
   }
 
+  public void populateSimpleCapacitySetUsage(final Set<String> resourceNameSet,
+      final CurrentStateOutput currentStateOutput) {
+    Map<String, LiveInstance> instanceMap = getLiveInstances();
+    // Convert the assignableNodes to map for quick lookup
+    Map<String, CapacityNode> simpleCapacityMap =
+        
_simpleCapacitySet.stream().collect(Collectors.toMap(CapacityNode::getId, node 
-> node));

Review Comment:
   Try to avoid lambda but use for loop. Lambda function is slower and creates 
a lot of tmp objects, which Helix already experienced before.
   
   Also, will this update the _simpleCapacitySet when you update the map? It is 
tmp object, right?



##########
helix-core/src/main/java/org/apache/helix/controller/dataproviders/ResourceControllerDataProvider.java:
##########
@@ -583,6 +587,38 @@ public Set<CapacityNode> getSimpleCapacitySet() {
     return _simpleCapacitySet;
   }
 
+  public void populateSimpleCapacitySetUsage(final Set<String> resourceNameSet,
+      final CurrentStateOutput currentStateOutput) {
+    Map<String, LiveInstance> instanceMap = getLiveInstances();
+    // Convert the assignableNodes to map for quick lookup
+    Map<String, CapacityNode> simpleCapacityMap =
+        
_simpleCapacitySet.stream().collect(Collectors.toMap(CapacityNode::getId, node 
-> node));
+    for (String resourceName : resourceNameSet) {
+      // Process current state mapping
+      for (Map.Entry<Partition, Map<String, String>> entry : 
currentStateOutput.getCurrentStateMap(
+          resourceName).entrySet()) {
+        String partition = entry.getKey().getPartitionName();

Review Comment:
   No need to create this reference if it was just used once in following code. 



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