jiajunwang commented on a change in pull request #520: Refactor soft 
constraints to simply the algorithm and fix potential issues.
URL: https://github.com/apache/helix/pull/520#discussion_r339248381
 
 

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/ConstraintBasedAlgorithm.java
 ##########
 @@ -109,19 +109,22 @@ public OptimalAssignment calculate(ClusterModel 
clusterModel) throws HelixRebala
       return Optional.empty();
     }
 
-    Function<AssignableNode, Float> calculatePoints =
+    Function<AssignableNode, Double> calculatePoints =
         (candidateNode) -> getAssignmentNormalizedScore(candidateNode, 
replica, clusterContext);
 
     return candidateNodes.stream().max(Comparator.comparing(calculatePoints));
   }
 
-  private float getAssignmentNormalizedScore(AssignableNode node, 
AssignableReplica replica,
+  private double getAssignmentNormalizedScore(AssignableNode node, 
AssignableReplica replica,
       ClusterContext clusterContext) {
-    float sum = 0;
+    double sum = 0;
     for (Map.Entry<SoftConstraint, Float> softConstraintEntry : 
_softConstraints.entrySet()) {
       SoftConstraint softConstraint = softConstraintEntry.getKey();
       float weight = softConstraintEntry.getValue();
-      sum += weight * softConstraint.getAssignmentNormalizedScore(node, 
replica, clusterContext);
+      if (weight != 0) {
 
 Review comment:
   For that statement, I am not so sure. For example, I have a cluster don't 
care about top state assignment. So I set the weight of top state constraint to 
be zero. Then Helix does not need to do that calculation.

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


With regards,
Apache Git Services

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

Reply via email to