private Bin emptyBinAt(int index) { BinDefinition binDef = definition.getBinDefinition(index); return new Bin(0, binDef.getStart(), binDef.getEnd()); }
public MutableGaugeMetricValue(TimeRange timeRange) { this.range = timeRange; this.histo = new HistogramAccumulator(InsightGaugeHistogramDefinition.getInstance()); }
private HistogramFactory(GaugeMetricValue gaugeValue) { metricValue = gaugeValue; binsCount = 1; definition = InsightGaugeHistogramDefinition.getInstance(); lowOutliers = false; highOutliers = false; start = Double.NEGATIVE_INFINITY; end = Double.POSITIVE_INFINITY; }
/** * Add all data from another histogram into this accumulator. The passed * histogram must be created against the same {@link HistogramDefinition} as * any other histograms passed into this accumulator. */ public void add(SparseHistogram histo) { for (IndexedBin addBin : histo.getBins()) { MutableLong bin = getOrCreateBin(addBin.getBinNumber()); bin.increment(addBin.getCount()); } }
public double getValueAtPercentile(GaugeMetricValue value, int p) { SparseHistogram histo = value.getHistogram(); int binNo = histo.getBinAfterPercentile(p); if (binNo == -1) { return Double.NaN; } return INSIGHT_HISTO.getBinDefinition(binNo).getStart(); }
public GaugeMetricValue(TimeRange timeRange) { this.range = timeRange; this.min = NaN; this.max = NaN; this.n = 0; this.sum = 0.0; this.sumOfSquares = 0.0; this.histo = new SparseHistogram(InsightGaugeHistogramDefinition.getInstance(), new ArrayList<IndexedBin>()); }
private int binNumberFor(double value) { int bin = definition.getBinForValue(value); if (value == definition.getBinEnd(bin)) { bin ++; } return bin; }
public long getTotalCount() { long total = 0L; for (IndexedBin bin : bins) { total += bin.getCount(); } return total; }
public int compareTo(IndexedBin o) { return getBinNumber() - o.getBinNumber(); } }
/** * @param binNum Bin number - zero based * @return the {@link BinDefinition} of the given bin. */ public BinDefinition getBinDefinition(int binNum) { if (binNum < 0) { throw new IllegalArgumentException("BinNum cannot be < 0"); } double start = 0.0; if (binNum != 0) { start = getBinEnd(binNum - 1); } double end = getBinEnd(binNum); return new BinDefinition(start, end); }
/** * Add the given value to the histogram. */ public void add(double value) { int binNum = def.getBinForValue(value); MutableLong bin = getOrCreateBin(binNum); bin.increment(1); }
private List<Bin> collect(List<Bin> bins, double startValue, double endValue) { int startBin = Double.NEGATIVE_INFINITY != startValue ? binNumberFor(startValue) : 0; int endBin = Double.POSITIVE_INFINITY != endValue ? binNumberFor(endValue) : bins.size(); if (endBin > bins.size()) { endBin = bins.size(); } List<Bin> collected = startBin < bins.size() ? bins.subList(startBin, endBin) : Collections.<Bin>emptyList(); if (collected.isEmpty()) { return Collections.singletonList(new Bin(0, startValue, endValue)); } return collected; }
public void add(double[] values) { for (double d : values) { add(d); } }
public void addHistogramEntry(int binNum, long count) { histo.incrementBin(binNum, count); }
public static HistogramFactory forValue(GaugeMetricValue metricValue) { return new HistogramFactory(metricValue); }
static private HistogramAccumulator makeHistoAccumulator() { return new HistogramAccumulator(InsightGaugeHistogramDefinition.getInstance()); } }
public SparseHistogram() { // for serialization this(InsightGaugeHistogramDefinition.getInstance()); }
public GaugeMetricValueBuilder(TimeRange timeRange){ this(timeRange, new HistogramAccumulator(InsightGaugeHistogramDefinition.getInstance()), new SummaryStatistics()); }
SparseHistogram(List<IndexedBin> indexedBins) { this(InsightGaugeHistogramDefinition.getInstance(), indexedBins); }