Class Base2ExponentialHistogramIndexer
- java.lang.Object
-
- io.opentelemetry.sdk.metrics.internal.aggregator.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.
-
Constructor Summary
Constructors Modifier Constructor Description private
Base2ExponentialHistogramIndexer(int scale)
-
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.
-
-
-
Field Detail
-
cache
private static final java.util.Map<java.lang.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:
- 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
-
-
Method Detail
-
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:
- All Scales: Use the Logarithm Function
-
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)
-
-