mkuchenbecker commented on code in PR #5486:
URL: https://github.com/apache/hadoop/pull/5486#discussion_r1139322336
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableQuantiles.java:
##########
@@ -52,6 +52,7 @@ public class MutableQuantiles extends MutableMetric {
new Quantile(0.75, 0.025), new Quantile(0.90, 0.010),
new Quantile(0.95, 0.005), new Quantile(0.99, 0.001) };
+ protected boolean inverseQuantiles = false;
Review Comment:
`private final boolean`
You will also need to set it in the constructor.
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/util/SampleQuantiles.java:
##########
@@ -243,7 +245,12 @@ synchronized public Map<Quantile, Long> snapshot() {
Map<Quantile, Long> values = new TreeMap<Quantile, Long>();
for (int i = 0; i < quantiles.length; i++) {
- values.put(quantiles[i], query(quantiles[i].quantile));
+ /* eg : effectiveQuantile for 0.99 with inverseQuantiles will be 0.01.
+ For inverse quantiles higher numeric value is better and hence we want
+ to query from the opposite end of the sorted sample
+ */
+ double effectiveQuantile = inverseQuantiles ? 1 - quantiles[i].quantile
: quantiles[i].quantile;
Review Comment:
Shouldn't this come after the next line?
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/util/SampleQuantiles.java:
##########
@@ -243,7 +245,12 @@ synchronized public Map<Quantile, Long> snapshot() {
Map<Quantile, Long> values = new TreeMap<Quantile, Long>();
for (int i = 0; i < quantiles.length; i++) {
- values.put(quantiles[i], query(quantiles[i].quantile));
+ /* eg : effectiveQuantile for 0.99 with inverseQuantiles will be 0.01.
Review Comment:
Leaning into OOO: I might make an inversequantile class that overrides this
function to keep it simple rather than overloading quantile with multiple
definitions.
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/util/SampleQuantiles.java:
##########
@@ -243,7 +245,12 @@ synchronized public Map<Quantile, Long> snapshot() {
Map<Quantile, Long> values = new TreeMap<Quantile, Long>();
for (int i = 0; i < quantiles.length; i++) {
- values.put(quantiles[i], query(quantiles[i].quantile));
+ /* eg : effectiveQuantile for 0.99 with inverseQuantiles will be 0.01.
+ For inverse quantiles higher numeric value is better and hence we want
+ to query from the opposite end of the sorted sample
+ */
+ double effectiveQuantile = inverseQuantiles ? 1 - quantiles[i].quantile
: quantiles[i].quantile;
+ values.put(quantiles[i], query(effectiveQuantile));
Review Comment:
Wouldn't reversing list order traversal give you the same thing wihtout
altering the math?
--
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]