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

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/PartitionMovementConstraint.java
 ##########
 @@ -54,23 +52,18 @@
   @Override
   protected float getAssignmentScore(AssignableNode node, AssignableReplica 
replica,
       ClusterContext clusterContext) {
+    // Prioritize the matching of the previous Best Possible assignment.
     Map<String, String> bestPossibleStateMap =
         getStateMap(replica, clusterContext.getBestPossibleAssignment());
+    if (!bestPossibleStateMap.isEmpty()) {
+      return calculateAssignmentScale(node, replica, bestPossibleStateMap);
+    }
     Map<String, String> baselineStateMap =
         getStateMap(replica, clusterContext.getBaselineAssignment());
-
-    // Prioritize the matching of the previous Best Possible assignment.
-    float scale = calculateAssignmentScale(node, replica, 
bestPossibleStateMap);
-    // If the baseline is also provided, adjust the final score accordingly.
-    scale = scale * (1 - BASELINE_MATCH_FACTOR)
-        + calculateAssignmentScale(node, replica, baselineStateMap) * 
BASELINE_MATCH_FACTOR;
-
-    return scale;
-  }
-
-  @Override
-  NormalizeFunction getNormalizeFunction() {
-    return score -> score * (getMaxScore() - getMinScore()) + getMinScore();
+    if (!baselineStateMap.isEmpty()) {
+      return calculateAssignmentScale(node, replica, baselineStateMap);
+    }
+    return 0;
 
 Review comment:
   Tried, failed, no better idea for this constraint.
   You are welcome to nominate some candidates : )

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