QuantileDigest { public double getCount() { return weightedCount / weight(TimeUnit.NANOSECONDS.toSeconds(ticker.read())); } QuantileDigest(double maxError);  QuantileDigest(double maxError, double alpha); @VisibleForTesting  QuantileDigest(double maxError, double alpha, Ticker ticker);  QuantileDigest(QuantileDigest other);  QuantileDigest(Slice serialized); double getMaxError(); double getAlpha(); void add(long value); void add(long value, long count); void merge(QuantileDigest other); List<Long> getQuantilesLowerBound(List<Double> quantiles); List<Long> getQuantilesUpperBound(List<Double> quantiles); List<Long> getQuantiles(List<Double> quantiles); long getQuantile(double quantile); long getQuantileLowerBound(double quantile); long getQuantileUpperBound(double quantile); double getCount(); List<Bucket> getHistogram(List<Long> bucketUpperBounds); List<Bucket> getHistogram(List<Long> bucketUpperBounds, MiddleFunction middleFunction); long getMin(); long getMax(); int estimatedInMemorySizeInBytes(); int estimatedSerializedSizeInBytes(); Slice serialize(); double getConfidenceFactor(); @SuppressFBWarnings("VA_FORMAT_STRING_USES_NEWLINE") String toGraphviz();  }
@Test public void testNegativeValues() { QuantileDigest digest = new QuantileDigest(1); addAll(digest, asList(-1, -2, -3, -4, -5, 0, 1, 2, 3, 4, 5)); assertEquals(digest.getCount(), (double) 11); }
@Test public void testTreeBuilding() { QuantileDigest digest = new QuantileDigest(1); List<Integer> values = asList(0, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7); addAll(digest, values); assertEquals(digest.getCount(), (double) values.size()); }
@Test public void testTreeBuildingReverse() { QuantileDigest digest = new QuantileDigest(1); List<Integer> values = asList(0, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7); addAll(digest, Lists.reverse(values)); assertEquals(digest.getCount(), (double) values.size()); }
@Test public void testDecayedCountsWithClockIncrementSmallerThanRescaleThreshold() { int targetAgeInSeconds = (int) (QuantileDigest.RESCALE_THRESHOLD_SECONDS - 1); TestingTicker ticker = new TestingTicker(); QuantileDigest digest = new QuantileDigest(1, ExponentialDecay.computeAlpha(0.5, targetAgeInSeconds), ticker); addAll(digest, asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)); ticker.elapseTime(targetAgeInSeconds, TimeUnit.SECONDS); addAll(digest, asList(10, 11, 12, 13, 14, 15, 16, 17, 18, 19)); assertEquals(digest.getCount(), 15.0); }