mkuchenbecker commented on code in PR #5486:
URL: https://github.com/apache/hadoop/pull/5486#discussion_r1140468345


##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableQuantiles.java:
##########
@@ -104,8 +105,7 @@ public MutableQuantiles(String name, String description, 
String sampleName,
           String.format(descTemplate, percentile));
     }
 
-    estimator = new SampleQuantiles(quantiles);
-
+    estimator = inverseQuantiles ? new InverseQuantiles(quantiles) : new 
SampleQuantiles(quantiles);

Review Comment:
   Is estimator variable used?
   
   



##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/util/InverseQuantiles.java:
##########
@@ -0,0 +1,44 @@
+package org.apache.hadoop.metrics2.util;
+
+import org.apache.hadoop.util.Preconditions;
+import java.util.ListIterator;
+
+public class InverseQuantiles extends SampleQuantiles{
+
+  public InverseQuantiles(Quantile[] quantiles) {
+    super(quantiles);
+  }
+  
+
+  /**
+   * Get the estimated value at the inverse of the specified quantile. 
+   * Eg: return the value at (1 - 0.99)*count position for quantile 0.99.
+   * When count is 100, quantile 0.99 is desired to return the value at the 
1st position
+   *
+   * @param quantile Queried quantile, e.g. 0.50 or 0.99.
+   * @return Estimated value at the inverse position of that quantile. 
+   */
+  long query(double quantile) {

Review Comment:
   - Minimal change here is to inverse list-order traversal. 
   - The for loop is performing a Map operation. 
   
   The DRY method would be to encapsulate the for loop to a protected function 
"getQuantilesFromSamples".



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