jon-wei commented on a change in pull request #6638: Fixed buckets histogram 
aggregator
URL: https://github.com/apache/incubator-druid/pull/6638#discussion_r244889946
 
 

 ##########
 File path: 
extensions-core/histogram/src/test/java/org/apache/druid/query/aggregation/histogram/FixedBucketsHistogramTest.java
 ##########
 @@ -0,0 +1,1509 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.query.aggregation.histogram;
+
+import org.apache.commons.math3.distribution.NormalDistribution;
+import org.apache.commons.math3.random.JDKRandomGenerator;
+import org.apache.commons.math3.stat.descriptive.rank.Percentile;
+import org.apache.druid.java.util.common.logger.Logger;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Random;
+
+public class FixedBucketsHistogramTest
+{
+  private static final Logger log = new 
Logger(FixedBucketsHistogramTest.class);
+
+  static final float[] VALUES2 = {23, 19, 10, 16, 36, 2, 1, 9, 32, 30, 45, 46};
+
+  static final float[] VALUES3 = {
+      20, 16, 19, 27, 17, 20, 18, 20, 28, 14, 17, 21, 20, 21, 10, 25, 23, 17, 
21, 18,
+      14, 20, 18, 12, 19, 20, 23, 25, 15, 22, 14, 17, 15, 23, 23, 15, 27, 20, 
17, 15
+  };
+  static final float[] VALUES4 = {
+      27.489f, 3.085f, 3.722f, 66.875f, 30.998f, -8.193f, 5.395f, 5.109f, 
10.944f, 54.75f,
+      14.092f, 15.604f, 52.856f, 66.034f, 22.004f, -14.682f, -50.985f, 2.872f, 
61.013f,
+      -21.766f, 19.172f, 62.882f, 33.537f, 21.081f, 67.115f, 44.789f, 64.1f, 
20.911f,
+      -6.553f, 2.178f
+  };
+  static final float[] VALUES5 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+  static final float[] VALUES6 = {
+      1f, 1.5f, 2f, 2.5f, 3f, 3.5f, 4f, 4.5f, 5f, 5.5f, 6f, 6.5f, 7f, 7.5f, 
8f, 8.5f, 9f, 9.5f, 10f
+  };
+
+  static final float[] VALUES7 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 12, 12, 
15, 20, 25, 25, 25};
+
+  protected FixedBucketsHistogram buildHistogram(
+      double lowerLimit,
+      double upperLimit,
+      int numBuckets,
+      FixedBucketsHistogram.OutlierHandlingMode outlierHandlingMode,
+      float[] values
+  )
+  {
+    FixedBucketsHistogram h = new FixedBucketsHistogram(
+        lowerLimit,
+        upperLimit,
+        numBuckets,
+        outlierHandlingMode
+    );
+
+    for (float v : values) {
+      h.add(v);
+    }
+    return h;
+  }
+
+  @Test
+  public void testOffer()
+  {
+    FixedBucketsHistogram h = buildHistogram(
+        0,
+        200,
+        200,
+        FixedBucketsHistogram.OutlierHandlingMode.OVERFLOW,
+        VALUES2
+    );
+
+    float[] quantiles = h.percentilesFloat(new double[]{12.5f, 50.0f, 98f});
+    double[] doubles = new double[VALUES2.length];
+
+    for (int i = 0; i < doubles.length; i++) {
+      doubles[i] = VALUES2[i];
+    }
+
+    Percentile percentile = new Percentile();
+    percentile.setData(doubles);
+    log.debug("MY-P12.5: " + quantiles[0]);
 
 Review comment:
   Removed these debug blocks

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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