Class ZeroBucket
java.lang.Object
org.elasticsearch.exponentialhistogram.ZeroBucket
Represents the bucket for values around zero in an exponential histogram.
The range of this bucket is
[-zeroThreshold, +zeroThreshold].
To allow efficient comparison with bucket boundaries, this class internally
represents the zero threshold as a exponential histogram bucket index with a scale,
computed via ExponentialScaleUtils.computeIndex(double, int).-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptioncollapseOverlappingBuckets(BucketIterator buckets) Collapses all buckets from the given iterator whose lower boundaries are smaller than the zero threshold.collapseOverlappingBucketsForAll(BucketIterator... bucketIterators) Collapses all buckets from the given iterators whose lower boundaries are smaller than the zero threshold.intcompareZeroThreshold(ZeroBucket other) Compares the zero threshold of this bucket with another one.longcount()static ZeroBucketcreate(double zeroThreshold, long count) Creates a zero bucket from the given threshold represented as double.static ZeroBucketcreate(long index, int scale, long count) Creates a zero bucket from the given threshold represented as exponentially scaled number.booleaninthashCode()longindex()booleanmerge(ZeroBucket other) Merges this zero bucket with another one.static ZeroBucketstatic ZeroBucketminimalWithCount(long count) Creates a zero bucket with the smallest possible threshold and a given count.intscale()double
-
Field Details
-
SHALLOW_SIZE
public static final long SHALLOW_SIZE
-
-
Method Details
-
minimalEmpty
- Returns:
- A singleton instance of an empty zero bucket with the smallest possible threshold.
-
minimalWithCount
Creates a zero bucket with the smallest possible threshold and a given count.- Parameters:
count- The number of values in the bucket.- Returns:
- A new
ZeroBucket.
-
create
Creates a zero bucket from the given threshold represented as double.- Parameters:
zeroThreshold- the zero threshold defining the bucket range [-zeroThreshold, +zeroThreshold], must be non-negativecount- the number of values in the bucket- Returns:
- the new
ZeroBucket
-
create
Creates a zero bucket from the given threshold represented as exponentially scaled number.- Parameters:
index- the index of the exponentially scaled number defining the zero thresholdscale- the corresponding scale for the indexcount- the number of values in the bucket- Returns:
- the new
ZeroBucket
-
zeroThreshold
public double zeroThreshold()- Returns:
- The value of the zero threshold.
-
index
public long index() -
scale
public int scale() -
count
public long count() -
isIndexBased
public boolean isIndexBased()- Returns:
- True if the zero threshold was created from an index/scale pair, false if it was created from a real-valued threshold.
-
merge
Merges this zero bucket with another one.- If the other zero bucket or both are empty, this instance is returned unchanged.
- If the this zero bucket is empty and the other one is populated, the other instance is returned unchanged.
- Otherwise, the zero threshold is increased if necessary (by taking the maximum of the two), and the counts are summed.
- Parameters:
other- The other zero bucket to merge with.- Returns:
- A new
ZeroBucketrepresenting the merged result.
-
collapseOverlappingBucketsForAll
Collapses all buckets from the given iterators whose lower boundaries are smaller than the zero threshold. The iterators are advanced to point at the first, non-collapsed bucket.- Parameters:
bucketIterators- The iterators whose buckets may be collapsed.- Returns:
- A potentially updated
ZeroBucketwith the collapsed buckets' counts and an adjusted threshold.
-
compareZeroThreshold
Compares the zero threshold of this bucket with another one.- Parameters:
other- The other zero bucket to compare against.- Returns:
- A negative integer, zero, or a positive integer if this bucket's threshold is less than, equal to, or greater than the other's.
-
collapseOverlappingBuckets
Collapses all buckets from the given iterator whose lower boundaries are smaller than the zero threshold. The iterator is advanced to point at the first, non-collapsed bucket.- Parameters:
buckets- The iterator whose buckets may be collapsed.- Returns:
- A potentially updated
ZeroBucketwith the collapsed buckets' counts and an adjusted threshold.
-
equals
-
hashCode
public int hashCode()
-