[GitHub] [helix] dasahcc commented on a change in pull request #422: Redefine the hard/soft constraints

2019-08-19 Thread GitBox
dasahcc commented on a change in pull request #422: Redefine the hard/soft 
constraints
URL: https://github.com/apache/helix/pull/422#discussion_r315475010
 
 

 ##
 File path: 
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/SoftConstraintWeightModel.java
 ##
 @@ -0,0 +1,47 @@
+package org.apache.helix.controller.rebalancer.waged.constraints;
+
+import java.util.Map;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * The class retrieves the offline model that defines the relative importance 
of soft constraints.
+ */
+class SoftConstraintWeightModel {
+  private float MIN_SCORE = Float.MIN_VALUE;
+  private float MAX_SCORE = Float.MAX_VALUE;
+  private static Map MODEL;
+
+  static {
+// TODO either define the weights in property files or zookeeper node or 
static human input
+MODEL = ImmutableMap. builder()
+.put(SoftConstraint.Type.LEAST_MOVEMENTS, 1.0f)
+.put(SoftConstraint.Type.LEAST_PARTITION_COUNT, 1.0f)
+.put(SoftConstraint.Type.LEAST_USED_NODE, 1.0f).build();
+  }
+
+  interface ScoreScaler {
+/**
+ * Method to scale the origin score to a normalized range
+ * @param originScore The origin score of a range
+ * @return The normalized value between 0 - 1
+ */
+float scale(float originScore);
+  }
+
+  private ScoreScaler MIN_MAX_SCALER =
+  originScore -> (originScore - MIN_SCORE) / (MAX_SCORE - MIN_SCORE);
+
+  /**
+   * Given the calculated scores map by soft constraints, get the sum of scores
+   * @param originScoresMap The origin scores of soft constraints
+   * @return The sum of double type
+   */
+  double getSumOfScores(Map originScoresMap) {
 
 Review comment:
   Why we have inconsistent data type? If we think float is more efficient, 
let's use float as return type. It is mixing up double/float in the 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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@helix.apache.org
For additional commands, e-mail: reviews-h...@helix.apache.org



[GitHub] [helix] dasahcc commented on a change in pull request #422: Redefine the hard/soft constraints

2019-08-19 Thread GitBox
dasahcc commented on a change in pull request #422: Redefine the hard/soft 
constraints
URL: https://github.com/apache/helix/pull/422#discussion_r315475176
 
 

 ##
 File path: 
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/SoftConstraintWeightModel.java
 ##
 @@ -0,0 +1,47 @@
+package org.apache.helix.controller.rebalancer.waged.constraints;
 
 Review comment:
   Have you set up the apache license header in the intellij? Once you set it 
up, it should be automatically pumped up.


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@helix.apache.org
For additional commands, e-mail: reviews-h...@helix.apache.org