Class Base2ExponentialHistogramIndexer
java.lang.Object
io.opentelemetry.sdk.metrics.internal.aggregator.Base2ExponentialHistogramIndexer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Map
<Integer, Base2ExponentialHistogramIndexer> private static final int
Bias used in representing the exponent of IEEE 754 double precision number.private static final long
Bit mask used to isolate exponent of IEEE 754 double precision number.private static final int
The number of bits used to represent the exponent of IEEE 754 double precision number.private static final double
private final int
private final double
private static final long
Bit mask used to isolate the significand of IEEE 754 double precision number.private static final int
The number of bits used to represent the significand of IEEE 754 double precision number, excluding the implicit bit. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(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 Details
-
cache
-
EXPONENT_BIT_MASK
private static final long EXPONENT_BIT_MASKBit mask used to isolate exponent of IEEE 754 double precision number.- See Also:
-
SIGNIFICAND_BIT_MASK
private static final long SIGNIFICAND_BIT_MASKBit mask used to isolate the significand of IEEE 754 double precision number.- See Also:
-
EXPONENT_BIAS
private static final int EXPONENT_BIASBias used in representing the exponent of IEEE 754 double precision number.- See Also:
-
SIGNIFICAND_WIDTH
private static final int SIGNIFICAND_WIDTHThe 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_WIDTHThe 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
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)
-