Class Base2ExponentialHistogramIndexer

java.lang.Object
io.opentelemetry.sdk.metrics.internal.aggregator.Base2ExponentialHistogramIndexer

final class Base2ExponentialHistogramIndexer extends Object
  • Field Details

    • cache

      private static final Map<Integer,Base2ExponentialHistogramIndexer> cache
    • EXPONENT_BIT_MASK

      private static final long EXPONENT_BIT_MASK
      Bit mask used to isolate exponent of IEEE 754 double precision number.
      See Also:
    • SIGNIFICAND_BIT_MASK

      private static final long SIGNIFICAND_BIT_MASK
      Bit mask used to isolate the significand of IEEE 754 double precision number.
      See Also:
    • EXPONENT_BIAS

      private static final int EXPONENT_BIAS
      Bias used in representing the exponent of IEEE 754 double precision number.
      See Also:
    • SIGNIFICAND_WIDTH

      private static final int SIGNIFICAND_WIDTH
      The number of bits used to represent the significand of IEEE 754 double precision number, excluding the implicit bit.
      See Also:
    • EXPONENT_WIDTH

      private static final int EXPONENT_WIDTH
      The number of bits used to represent the exponent of IEEE 754 double precision number.
      See Also:
    • LOG_BASE2_E

      private static final double LOG_BASE2_E
    • scale

      private final int scale
    • scaleFactor

      private final double scaleFactor
  • Constructor Details

    • Base2ExponentialHistogramIndexer

      private Base2ExponentialHistogramIndexer(int scale)
  • Method Details

    • get

      static Base2ExponentialHistogramIndexer get(int scale)
      Get an indexer for the given scale. Indexers are cached and reused for performance.
    • computeIndex

      int computeIndex(double value)
      Compute the index for the given value.

      The algorithm to retrieve the index is specified in the OpenTelemetry specification.

      Parameters:
      value - Measured value (must be non-zero).
      Returns:
      the index of the bucket which the value maps to.
    • getIndexByLogarithm

      private int getIndexByLogarithm(double value)
      Compute the bucket index using a logarithm based approach.
      See Also:
    • mapToIndexScaleZero

      private static int mapToIndexScaleZero(double value)
      Compute the exact bucket index for scale zero by extracting the exponent.
      See Also:
    • computeScaleFactor

      private static double computeScaleFactor(int scale)