Class Histogram.LinearBinScheme

java.lang.Object
org.apache.kafka.common.metrics.stats.Histogram.LinearBinScheme
All Implemented Interfaces:
Histogram.BinScheme
Enclosing class:
Histogram

public static class Histogram.LinearBinScheme
extends Object
implements Histogram.BinScheme
A scheme for calculating the bins where the width of each bin is one more than the previous bin, and therefore the bin widths are increasing at a linear rate. However, the bin widths are scaled such that the specified range of values will all fit within the bins (e.g., the upper range of the last bin is equal to the maximum value).
  • Constructor Summary

    Constructors
    Constructor Description
    LinearBinScheme​(int numBins, double max)
    Create a linear bin scheme with the specified number of bins and the maximum value to be counted in the bins.
  • Method Summary

    Modifier and Type Method Description
    int bins()
    Get the number of bins.
    double fromBin​(int b)
    Determine the value at the upper range of the specified bin.
    int toBin​(double x)
    Determine the 0-based bin number in which the supplied value should be placed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LinearBinScheme

      public LinearBinScheme​(int numBins, double max)
      Create a linear bin scheme with the specified number of bins and the maximum value to be counted in the bins.
      Parameters:
      numBins - the number of bins; must be at least 2
      max - the maximum value to be counted in the bins
  • Method Details

    • bins

      public int bins()
      Description copied from interface: Histogram.BinScheme
      Get the number of bins.
      Specified by:
      bins in interface Histogram.BinScheme
      Returns:
      the number of bins
    • fromBin

      public double fromBin​(int b)
      Description copied from interface: Histogram.BinScheme
      Determine the value at the upper range of the specified bin.
      Specified by:
      fromBin in interface Histogram.BinScheme
      Parameters:
      b - the 0-based bin number
      Returns:
      the value at the upper end of the bin; or negative infinity if the bin number is negative or positive infinity if the 0-based bin number is greater than or equal to the number of bins.
    • toBin

      public int toBin​(double x)
      Description copied from interface: Histogram.BinScheme
      Determine the 0-based bin number in which the supplied value should be placed.
      Specified by:
      toBin in interface Histogram.BinScheme
      Parameters:
      x - the value
      Returns:
      the 0-based index of the bin