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

 ##########
 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:
   Is it necessary? Weight comes from our manual setting and it will never be 0 
otherwise it makes no sense to have the corresponding soft constraint 
implementation

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