Class Base2ExponentialHistogramIndexer


  • final class Base2ExponentialHistogramIndexer
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.Map<java.lang.Integer,​Base2ExponentialHistogramIndexer> cache  
      private static int EXPONENT_BIAS
      Bias used in representing the exponent of IEEE 754 double precision number.
      private static long EXPONENT_BIT_MASK
      Bit mask used to isolate exponent of IEEE 754 double precision number.
      private static int EXPONENT_WIDTH
      The number of bits used to represent the exponent of IEEE 754 double precision number.
      private static double LOG_BASE2_E  
      private int scale  
      private double scaleFactor  
      private static long SIGNIFICAND_BIT_MASK
      Bit mask used to isolate the significand of IEEE 754 double precision number.
      private static int SIGNIFICAND_WIDTH
      The number of bits used to represent the significand of IEEE 754 double precision number, excluding the implicit bit.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) int computeIndex​(double value)
      Compute the index for the given value.
      private static double computeScaleFactor​(int scale)  
      (package private) static Base2ExponentialHistogramIndexer get​(int scale)
      Get an indexer for the given scale.
      private int getIndexByLogarithm​(double value)
      Compute the bucket index using a logarithm based approach.
      private static int mapToIndexScaleZero​(double value)
      Compute the exact bucket index for scale zero by extracting the exponent.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EXPONENT_BIT_MASK

        private static final long EXPONENT_BIT_MASK
        Bit mask used to isolate exponent of IEEE 754 double precision number.
        See Also:
        Constant Field Values
      • 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:
        Constant Field Values
      • EXPONENT_BIAS

        private static final int EXPONENT_BIAS
        Bias used in representing the exponent of IEEE 754 double precision number.
        See Also:
        Constant Field Values
      • 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:
        Constant Field Values
      • 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:
        Constant Field Values
      • LOG_BASE2_E

        private static final double LOG_BASE2_E
      • scale

        private final int scale
      • scaleFactor

        private final double scaleFactor
    • Constructor Detail

      • Base2ExponentialHistogramIndexer

        private Base2ExponentialHistogramIndexer​(int scale)
    • Method Detail

      • 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.
      • mapToIndexScaleZero

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

        private static double computeScaleFactor​(int scale)