Class DoubleBase2ExponentialHistogramBuckets
- java.lang.Object
-
- io.opentelemetry.sdk.metrics.internal.aggregator.DoubleBase2ExponentialHistogramBuckets
-
- All Implemented Interfaces:
ExponentialHistogramBuckets
final class DoubleBase2ExponentialHistogramBuckets extends java.lang.Object implements ExponentialHistogramBuckets
This class handles the operations for recording, scaling, and exposing data related to the base2 exponential histogram.This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
-
-
Field Summary
Fields Modifier and Type Field Description private Base2ExponentialHistogramIndexerbase2ExponentialHistogramIndexerprivate AdaptingCircularBufferCountercountsprivate MemoryModememoryModeprivate AdaptingCircularBufferCounterreusableCountsprivate intscaleprivate longtotalCount
-
Constructor Summary
Constructors Constructor Description DoubleBase2ExponentialHistogramBuckets(int scale, int maxBuckets, MemoryMode memoryMode)DoubleBase2ExponentialHistogramBuckets(DoubleBase2ExponentialHistogramBuckets buckets)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidclear(int scale)Resets all counters in this bucket set to zero and resets the scale toscale.(package private) DoubleBase2ExponentialHistogramBucketscopy()Returns a copy of this bucket.(package private) voiddownscale(int by)booleanequals(java.lang.Object obj)java.util.List<java.lang.Long>getBucketCounts()The bucket counts is a list of counts representing number of measurements that fall into each bucket.(package private) voidgetBucketCountsIntoReusableList(DynamicPrimitiveLongList reusableLongList)Fills the given reusable list with the bucket counts.intgetOffset()The offset shifts the bucket boundaries according tolower_bound = base^(offset+i).intgetScale()The scale of the buckets.(package private) intgetScaleReduction(double value)Returns the minimum scale reduction required to record the given value in these buckets, by calculating the new required window to allow the new value to be recorded.(package private) intgetScaleReduction(long newStart, long newEnd)longgetTotalCount()The total count is the sum of all the values in the buckets.inthashCode()(package private) booleanrecord(double value)private booleansameBucketCounts(DoubleBase2ExponentialHistogramBuckets other)Tests if two bucket counts are equivalent semantically.java.lang.StringtoString()
-
-
-
Field Detail
-
memoryMode
private final MemoryMode memoryMode
-
counts
private AdaptingCircularBufferCounter counts
-
scale
private int scale
-
base2ExponentialHistogramIndexer
private Base2ExponentialHistogramIndexer base2ExponentialHistogramIndexer
-
totalCount
private long totalCount
-
reusableCounts
@Nullable private AdaptingCircularBufferCounter reusableCounts
-
-
Constructor Detail
-
DoubleBase2ExponentialHistogramBuckets
DoubleBase2ExponentialHistogramBuckets(int scale, int maxBuckets, MemoryMode memoryMode)
-
DoubleBase2ExponentialHistogramBuckets
DoubleBase2ExponentialHistogramBuckets(DoubleBase2ExponentialHistogramBuckets buckets)
-
-
Method Detail
-
copy
DoubleBase2ExponentialHistogramBuckets copy()
Returns a copy of this bucket.
-
clear
void clear(int scale)
Resets all counters in this bucket set to zero and resets the scale toscale.
-
record
boolean record(double value)
-
getOffset
public int getOffset()
Description copied from interface:ExponentialHistogramBucketsThe offset shifts the bucket boundaries according tolower_bound = base^(offset+i)..- Specified by:
getOffsetin interfaceExponentialHistogramBuckets- Returns:
- the offset.
-
getBucketCounts
public java.util.List<java.lang.Long> getBucketCounts()
Description copied from interface:ExponentialHistogramBucketsThe bucket counts is a list of counts representing number of measurements that fall into each bucket.- Specified by:
getBucketCountsin interfaceExponentialHistogramBuckets- Returns:
- the bucket counts.
-
getBucketCountsIntoReusableList
void getBucketCountsIntoReusableList(DynamicPrimitiveLongList reusableLongList)
Fills the given reusable list with the bucket counts.NOTE: This is the same as
getBucketCounts()but instead of returning a List with the values is fill the values intoreusableLongList- Parameters:
reusableLongList- The list to fill with the bucket counts
-
getTotalCount
public long getTotalCount()
Description copied from interface:ExponentialHistogramBucketsThe total count is the sum of all the values in the buckets.- Specified by:
getTotalCountin interfaceExponentialHistogramBuckets- Returns:
- the total count.
-
downscale
void downscale(int by)
-
getScale
public int getScale()
Description copied from interface:ExponentialHistogramBucketsThe scale of the buckets. Must align withExponentialHistogramPointData.getScale().- Specified by:
getScalein interfaceExponentialHistogramBuckets
-
getScaleReduction
int getScaleReduction(double value)
Returns the minimum scale reduction required to record the given value in these buckets, by calculating the new required window to allow the new value to be recorded. To be used with downScale().- Parameters:
value- The proposed value to be recorded.- Returns:
- The required scale reduction in order to fit the value in these buckets.
-
getScaleReduction
int getScaleReduction(long newStart, long newEnd)
-
equals
public boolean equals(@Nullable java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
sameBucketCounts
private boolean sameBucketCounts(DoubleBase2ExponentialHistogramBuckets other)
Tests if two bucket counts are equivalent semantically.Semantic equivalence means:
- All counts are stored between indexStart/indexEnd.
- Offset does NOT need to be the same
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-