public class DoubleHistogram extends EncodableHistogram implements DoubleValueRecorder, java.io.Serializable
It is important to note that DoubleHistogram
is not thread-safe, and does not support safe concurrent
recording by multiple threads. If concurrent operation is required, consider usings
ConcurrentDoubleHistogram
, SynchronizedDoubleHistogram
, or(recommended)
DoubleRecorder
, which are intended for this purpose.
DoubleHistogram
supports the recording and analyzing sampled data value counts across a
configurable dynamic range of floating point (double) values, with configurable value precision within the range.
Dynamic range is expressed as a ratio between the highest and lowest non-zero values trackable within the histogram
at any given time. Value precision is expressed as the number of significant [decimal] digits in the value recording,
and provides control over value quantization behavior across the value range and the subsequent value resolution at
any given level.
Auto-ranging: Unlike integer value based histograms, the specific value range tracked by a DoubleHistogram
is not specified upfront. Only the dynamic range of values that the histogram can cover is
(optionally) specified. E.g. When a DoubleHistogram
is created to track a dynamic range of
3600000000000 (enough to track values from a nanosecond to an hour), values could be recorded into into it in any
consistent unit of time as long as the ratio between the highest and lowest non-zero values stays within the
specified dynamic range, so recording in units of nanoseconds (1.0 thru 3600000000000.0), milliseconds (0.000001
thru 3600000.0) seconds (0.000000001 thru 3600.0), hours (1/3.6E12 thru 1.0) will all work just as well.
Auto-resizing: When constructed with no specified dynamic range (or when auto-resize is turned on with setAutoResize(boolean)
) a DoubleHistogram
will auto-resize its dynamic range to
include recorded values as they are encountered. Note that recording calls that cause auto-resizing may take
longer to execute, as resizing incurs allocation and copying of internal data structures.
Attempts to record non-zero values that range outside of the specified dynamic range (or exceed the limits of
of dynamic range when auto-resizing) may results in ArrayIndexOutOfBoundsException
exceptions, either
due to overflow or underflow conditions. These exceptions will only be thrown if recording the value would have
resulted in discarding or losing the required value precision of values already recorded in the histogram.
See package description for org.HdrHistogram
for details.
Modifier and Type | Class and Description |
---|---|
class |
DoubleHistogram.AllValues
|
class |
DoubleHistogram.LinearBucketValues
|
class |
DoubleHistogram.LogarithmicBucketValues
|
class |
DoubleHistogram.Percentiles
|
class |
DoubleHistogram.RecordedValues
An
Iterable <DoubleHistogramIterationValue > through
the histogram using a DoubleRecordedValuesIterator |
Modifier and Type | Field and Description |
---|---|
private boolean |
autoResize |
private long |
configuredHighestToLowestValueRatio |
private double |
currentHighestValueLimitInAutoRange |
private double |
currentLowestValueInAutoRange |
private static int |
DHIST_compressedEncodingCookie |
private static int |
DHIST_encodingCookie |
private static double |
highestAllowedValueEver |
(package private) AbstractHistogram |
integerValuesHistogram |
private static long |
serialVersionUID |
Modifier | Constructor and Description |
---|---|
|
DoubleHistogram(DoubleHistogram source)
Construct a
DoubleHistogram with the same range settings as a given source,
duplicating the source's start/end timestamps (but NOT it's contents) |
|
DoubleHistogram(int numberOfSignificantValueDigits)
Construct a new auto-resizing DoubleHistogram using a precision stated as a number
of significant decimal digits.
|
|
DoubleHistogram(int numberOfSignificantValueDigits,
java.lang.Class<? extends AbstractHistogram> internalCountsHistogramClass)
Construct a new auto-resizing DoubleHistogram using a precision stated as a number
of significant decimal digits.
|
|
DoubleHistogram(long highestToLowestValueRatio,
int numberOfSignificantValueDigits)
Construct a new DoubleHistogram with the specified dynamic range (provided in
highestToLowestValueRatio ) and using a precision stated as a number of significant
decimal digits. |
protected |
DoubleHistogram(long highestToLowestValueRatio,
int numberOfSignificantValueDigits,
java.lang.Class<? extends AbstractHistogram> internalCountsHistogramClass)
Construct a new DoubleHistogram with the specified dynamic range (provided in
highestToLowestValueRatio ) and using a precision stated as a number of significant
decimal digits. |
private |
DoubleHistogram(long highestToLowestValueRatio,
int numberOfSignificantValueDigits,
java.lang.Class<? extends AbstractHistogram> internalCountsHistogramClass,
AbstractHistogram internalCountsHistogram) |
private |
DoubleHistogram(long highestToLowestValueRatio,
int numberOfSignificantValueDigits,
java.lang.Class<? extends AbstractHistogram> internalCountsHistogramClass,
AbstractHistogram internalCountsHistogram,
boolean mimicInternalModel) |
Modifier and Type | Method and Description |
---|---|
void |
add(DoubleHistogram fromHistogram)
Add the contents of another histogram to this one.
|
void |
addWhileCorrectingForCoordinatedOmission(DoubleHistogram fromHistogram,
double expectedIntervalBetweenValueSamples)
Add the contents of another histogram to this one, while correcting the incoming data for coordinated omission.
|
DoubleHistogram.AllValues |
allValues()
Provide a means of iterating through all histogram values using the finest granularity steps supported by
the underlying representation.
|
private void |
autoAdjustRangeForValue(double value) |
private void |
autoAdjustRangeForValueSlowPath(double value) |
private static DoubleHistogram |
constructHistogramFromBuffer(int cookie,
java.nio.ByteBuffer buffer,
java.lang.Class<? extends AbstractHistogram> histogramClass,
long minBarForHighestToLowestValueRatio) |
DoubleHistogram |
copy()
Create a copy of this histogram, complete with data and everything.
|
DoubleHistogram |
copyCorrectedForCoordinatedOmission(double expectedIntervalBetweenValueSamples)
Get a copy of this histogram, corrected for coordinated omission.
|
void |
copyInto(DoubleHistogram targetHistogram)
Copy this histogram into the target histogram, overwriting it's contents.
|
void |
copyIntoCorrectedForCoordinatedOmission(DoubleHistogram targetHistogram,
double expectedIntervalBetweenValueSamples)
Copy this histogram, corrected for coordinated omission, into the target histogram, overwriting it's contents.
|
static DoubleHistogram |
decodeFromByteBuffer(java.nio.ByteBuffer buffer,
java.lang.Class<? extends AbstractHistogram> internalCountsHistogramClass,
long minBarForHighestToLowestValueRatio)
Construct a new DoubleHistogram by decoding it from a ByteBuffer, using a
specified AbstractHistogram subclass for tracking internal counts (e.g.
|
static DoubleHistogram |
decodeFromByteBuffer(java.nio.ByteBuffer buffer,
long minBarForHighestToLowestValueRatio)
Construct a new DoubleHistogram by decoding it from a ByteBuffer.
|
static DoubleHistogram |
decodeFromCompressedByteBuffer(java.nio.ByteBuffer buffer,
java.lang.Class<? extends AbstractHistogram> internalCountsHistogramClass,
long minBarForHighestToLowestValueRatio)
Construct a new DoubleHistogram by decoding it from a compressed form in a ByteBuffer, using a
specified AbstractHistogram subclass for tracking internal counts (e.g.
|
static DoubleHistogram |
decodeFromCompressedByteBuffer(java.nio.ByteBuffer buffer,
long minBarForHighestToLowestValueRatio)
Construct a new DoubleHistogram by decoding it from a compressed form in a ByteBuffer.
|
private long |
deriveIntegerValueRange(long externalHighestToLowestValueRatio,
int numberOfSignificantValueDigits) |
private long |
deriveInternalHighestToLowestValueRatio(long externalHighestToLowestValueRatio) |
int |
encodeIntoByteBuffer(java.nio.ByteBuffer buffer)
Encode this histogram into a ByteBuffer
|
int |
encodeIntoCompressedByteBuffer(java.nio.ByteBuffer targetBuffer)
Encode this histogram in compressed form into a byte array
|
int |
encodeIntoCompressedByteBuffer(java.nio.ByteBuffer targetBuffer,
int compressionLevel)
Encode this histogram in compressed form into a byte array
|
boolean |
equals(java.lang.Object other)
Determine if this histogram is equivalent to another.
|
private int |
findCappedContainingBinaryOrderOfMagnitude(double doubleNumber) |
private static int |
findContainingBinaryOrderOfMagnitude(double doubleNumber) |
private static int |
findContainingBinaryOrderOfMagnitude(long longNumber) |
long |
getCountAtValue(double value)
Get the count of recorded values at a specific value (to within the histogram resolution at the value level).
|
double |
getCountBetweenValues(double lowValue,
double highValue)
Get the count of recorded values within a range of value levels (inclusive to within the histogram's resolution).
|
(package private) double |
getCurrentHighestTrackableValue()
get the current highest trackable value in the automatically determined range
(keep in mind that this can change because it is auto ranging)
|
(package private) double |
getCurrentLowestTrackableNonZeroValue()
get the current lowest (non zero) trackable value the automatically determined range
(keep in mind that this can change because it is auto ranging)
|
(package private) double |
getDoubleToIntegerValueConversionRatio() |
long |
getEndTimeStamp()
get the end time stamp [optionally] stored with this histogram
|
int |
getEstimatedFootprintInBytes()
Provide a (conservatively high) estimate of the Histogram's total footprint in bytes
|
long |
getHighestToLowestValueRatio()
get the Dynamic range of the histogram: the configured ratio between the highest trackable value and the
lowest trackable non zero value at any given time.
|
double |
getIntegerToDoubleValueConversionRatio()
Get the current conversion ratio from interval integer value representation to double units.
|
private long |
getLowestTrackingIntegerValue() |
double |
getMaxValue()
Get the highest recorded value level in the histogram
|
double |
getMaxValueAsDouble()
Get the highest recorded value level in the histogram as a double
|
double |
getMean()
Get the computed mean value of all recorded values in the histogram
|
double |
getMinNonZeroValue()
Get the lowest recorded non-zero value level in the histogram
|
double |
getMinValue()
Get the lowest recorded value level in the histogram
|
int |
getNeededByteBufferCapacity()
Get the capacity needed to encode this histogram into a ByteBuffer
|
private int |
getNeededByteBufferCapacity(int relevantLength) |
int |
getNumberOfSignificantValueDigits()
get the configured numberOfSignificantValueDigits
|
double |
getPercentileAtOrBelowValue(double value)
Get the percentile at a given value.
|
long |
getStartTimeStamp()
get the start time stamp [optionally] stored with this histogram
|
double |
getStdDeviation()
Get the computed standard deviation of all recorded values in the histogram
|
java.lang.String |
getTag()
get the tag string [optionally] associated with this histogram
|
long |
getTotalCount()
Get the total count of all recorded values in the histogram
|
double |
getValueAtPercentile(double percentile)
Get the value at a given percentile.
|
private void |
handleShiftValuesException(int numberOfBinaryOrdersOfMagnitude,
java.lang.Exception ex) |
int |
hashCode() |
double |
highestEquivalentValue(double value)
Get the highest value that is equivalent to the given value within the histogram's resolution.
|
private void |
init(long configuredHighestToLowestValueRatio,
double lowestTrackableUnitValue,
AbstractHistogram integerValuesHistogram) |
boolean |
isAutoResize() |
private static boolean |
isCompressedDoubleHistogramCookie(int cookie) |
(package private) static boolean |
isDoubleHistogramCookie(int cookie) |
private static boolean |
isNonCompressedDoubleHistogramCookie(int cookie) |
DoubleHistogram.LinearBucketValues |
linearBucketValues(double valueUnitsPerBucket)
Provide a means of iterating through histogram values using linear steps.
|
DoubleHistogram.LogarithmicBucketValues |
logarithmicBucketValues(double valueUnitsInFirstBucket,
double logBase)
Provide a means of iterating through histogram values at logarithmically increasing levels.
|
double |
lowestEquivalentValue(double value)
Get the lowest value that is equivalent to the given value within the histogram's resolution.
|
double |
medianEquivalentValue(double value)
Get a value that lies in the middle (rounded up) of the range of values equivalent the given value.
|
double |
nextNonEquivalentValue(double value)
Get the next value that is not equivalent to the given value within the histogram's resolution.
|
void |
outputPercentileDistribution(java.io.PrintStream printStream,
java.lang.Double outputValueUnitScalingRatio)
Produce textual representation of the value distribution of histogram data by percentile.
|
void |
outputPercentileDistribution(java.io.PrintStream printStream,
int percentileTicksPerHalfDistance,
java.lang.Double outputValueUnitScalingRatio)
Produce textual representation of the value distribution of histogram data by percentile.
|
void |
outputPercentileDistribution(java.io.PrintStream printStream,
int percentileTicksPerHalfDistance,
java.lang.Double outputValueUnitScalingRatio,
boolean useCsvFormat)
Produce textual representation of the value distribution of histogram data by percentile.
|
DoubleHistogram.Percentiles |
percentiles(int percentileTicksPerHalfDistance)
Provide a means of iterating through histogram values according to percentile levels.
|
private void |
readObject(java.io.ObjectInputStream o) |
private void |
recordCountAtValue(long count,
double value) |
DoubleHistogram.RecordedValues |
recordedValues()
Provide a means of iterating through all recorded histogram values using the finest granularity steps
supported by the underlying representation.
|
private void |
recordSingleValue(double value) |
void |
recordValue(double value)
Record a value in the histogram
|
void |
recordValueWithCount(double value,
long count)
Record a value in the histogram (adding to the value's current count)
|
private void |
recordValueWithCountAndExpectedInterval(double value,
long count,
double expectedIntervalBetweenValueSamples) |
void |
recordValueWithExpectedInterval(double value,
double expectedIntervalBetweenValueSamples)
Record a value in the histogram.
|
void |
reset()
Reset the contents and stats of this histogram
|
void |
setAutoResize(boolean autoResize) |
void |
setEndTimeStamp(long timeStampMsec)
Set the end time stamp value associated with this histogram to a given value.
|
void |
setStartTimeStamp(long timeStampMsec)
Set the start time stamp value associated with this histogram to a given value.
|
void |
setTag(java.lang.String tag)
Set the tag string associated with this histogram
|
private void |
setTrackableValueRange(double lowestValueInAutoRange,
double highestValueInAutoRange) |
private void |
shiftCoveredRangeToTheLeft(int numberOfBinaryOrdersOfMagnitude) |
private void |
shiftCoveredRangeToTheRight(int numberOfBinaryOrdersOfMagnitude) |
double |
sizeOfEquivalentValueRange(double value)
Get the size (in value units) of the range of values that are equivalent to the given value within the
histogram's resolution.
|
void |
subtract(DoubleHistogram otherHistogram)
Subtract the contents of another histogram from this one.
|
boolean |
valuesAreEquivalent(double value1,
double value2)
Determine if two values are equivalent with the histogram's resolution.
|
private void |
writeObject(java.io.ObjectOutputStream o) |
private static final double highestAllowedValueEver
private long configuredHighestToLowestValueRatio
private volatile double currentLowestValueInAutoRange
private volatile double currentHighestValueLimitInAutoRange
AbstractHistogram integerValuesHistogram
private boolean autoResize
private static final long serialVersionUID
private static final int DHIST_encodingCookie
private static final int DHIST_compressedEncodingCookie
public DoubleHistogram(int numberOfSignificantValueDigits)
numberOfSignificantValueDigits
- Specifies the precision to use. This is the number of significant
decimal digits to which the histogram will maintain value resolution
and separation. Must be a non-negative integer between 0 and 5.public DoubleHistogram(int numberOfSignificantValueDigits, java.lang.Class<? extends AbstractHistogram> internalCountsHistogramClass)
DoubleHistogram
will use the specified AbstractHistogram subclass
for tracking internal counts (e.g. Histogram
,
ConcurrentHistogram
, SynchronizedHistogram
,
IntCountsHistogram
, ShortCountsHistogram
).numberOfSignificantValueDigits
- Specifies the precision to use. This is the number of significant
decimal digits to which the histogram will maintain value resolution
and separation. Must be a non-negative integer between 0 and 5.internalCountsHistogramClass
- The class to use for internal counts trackingpublic DoubleHistogram(long highestToLowestValueRatio, int numberOfSignificantValueDigits)
highestToLowestValueRatio
) and using a precision stated as a number of significant
decimal digits.highestToLowestValueRatio
- specifies the dynamic range to usenumberOfSignificantValueDigits
- Specifies the precision to use. This is the number of significant
decimal digits to which the histogram will maintain value resolution
and separation. Must be a non-negative integer between 0 and 5.protected DoubleHistogram(long highestToLowestValueRatio, int numberOfSignificantValueDigits, java.lang.Class<? extends AbstractHistogram> internalCountsHistogramClass)
highestToLowestValueRatio
) and using a precision stated as a number of significant
decimal digits.
The DoubleHistogram
will use the specified AbstractHistogram subclass
for tracking internal counts (e.g. Histogram
,
ConcurrentHistogram
, SynchronizedHistogram
,
IntCountsHistogram
, ShortCountsHistogram
).highestToLowestValueRatio
- specifies the dynamic range to use.numberOfSignificantValueDigits
- Specifies the precision to use. This is the number of significant
decimal digits to which the histogram will maintain value resolution
and separation. Must be a non-negative integer between 0 and 5.internalCountsHistogramClass
- The class to use for internal counts trackingprivate DoubleHistogram(long highestToLowestValueRatio, int numberOfSignificantValueDigits, java.lang.Class<? extends AbstractHistogram> internalCountsHistogramClass, AbstractHistogram internalCountsHistogram)
private DoubleHistogram(long highestToLowestValueRatio, int numberOfSignificantValueDigits, java.lang.Class<? extends AbstractHistogram> internalCountsHistogramClass, AbstractHistogram internalCountsHistogram, boolean mimicInternalModel)
public DoubleHistogram(DoubleHistogram source)
DoubleHistogram
with the same range settings as a given source,
duplicating the source's start/end timestamps (but NOT it's contents)source
- The source histogram to duplicateprivate void init(long configuredHighestToLowestValueRatio, double lowestTrackableUnitValue, AbstractHistogram integerValuesHistogram)
private void setTrackableValueRange(double lowestValueInAutoRange, double highestValueInAutoRange)
double getDoubleToIntegerValueConversionRatio()
public boolean isAutoResize()
public void setAutoResize(boolean autoResize)
public void recordValue(double value) throws java.lang.ArrayIndexOutOfBoundsException
recordValue
in interface DoubleValueRecorder
value
- The value to be recordedjava.lang.ArrayIndexOutOfBoundsException
- (may throw) if value cannot be covered by the histogram's rangepublic void recordValueWithCount(double value, long count) throws java.lang.ArrayIndexOutOfBoundsException
recordValueWithCount
in interface DoubleValueRecorder
value
- The value to be recordedcount
- The number of occurrences of this value to recordjava.lang.ArrayIndexOutOfBoundsException
- (may throw) if value cannot be covered by the histogram's rangepublic void recordValueWithExpectedInterval(double value, double expectedIntervalBetweenValueSamples) throws java.lang.ArrayIndexOutOfBoundsException
To compensate for the loss of sampled values when a recorded value is larger than the expected interval between value samples, Histogram will auto-generate an additional series of decreasingly-smaller (down to the expectedIntervalBetweenValueSamples) value records.
Note: This is a at-recording correction method, as opposed to the post-recording correction method provided
by copyCorrectedForCoordinatedOmission(double)
.
The use cases for these two methods are mutually exclusive, and only one of the two should be be used on
a given data set to correct for the same coordinated omission issue.
See notes in the description of the Histogram calls for an illustration of why this corrective behavior is important.
recordValueWithExpectedInterval
in interface DoubleValueRecorder
value
- The value to recordexpectedIntervalBetweenValueSamples
- If expectedIntervalBetweenValueSamples is larger than 0, add
auto-generated value records as appropriate if value is larger
than expectedIntervalBetweenValueSamplesjava.lang.ArrayIndexOutOfBoundsException
- (may throw) if value cannot be covered by the histogram's rangeprivate void recordCountAtValue(long count, double value) throws java.lang.ArrayIndexOutOfBoundsException
java.lang.ArrayIndexOutOfBoundsException
private void recordSingleValue(double value) throws java.lang.ArrayIndexOutOfBoundsException
java.lang.ArrayIndexOutOfBoundsException
private void recordValueWithCountAndExpectedInterval(double value, long count, double expectedIntervalBetweenValueSamples) throws java.lang.ArrayIndexOutOfBoundsException
java.lang.ArrayIndexOutOfBoundsException
private void autoAdjustRangeForValue(double value)
private void autoAdjustRangeForValueSlowPath(double value)
private void shiftCoveredRangeToTheRight(int numberOfBinaryOrdersOfMagnitude)
private void shiftCoveredRangeToTheLeft(int numberOfBinaryOrdersOfMagnitude)
private void handleShiftValuesException(int numberOfBinaryOrdersOfMagnitude, java.lang.Exception ex)
public void reset()
reset
in interface DoubleValueRecorder
public DoubleHistogram copy()
public DoubleHistogram copyCorrectedForCoordinatedOmission(double expectedIntervalBetweenValueSamples)
To compensate for the loss of sampled values when a recorded value is larger than the expected
interval between value samples, the new histogram will include an auto-generated additional series of
decreasingly-smaller (down to the expectedIntervalBetweenValueSamples) value records for each count found
in the current histogram that is larger than the expectedIntervalBetweenValueSamples.
Note: This is a post-correction method, as opposed to the at-recording correction method provided
by recordValueWithExpectedInterval
. The two
methods are mutually exclusive, and only one of the two should be be used on a given data set to correct
for the same coordinated omission issue.
by
See notes in the description of the Histogram calls for an illustration of why this corrective behavior is important.
expectedIntervalBetweenValueSamples
- If expectedIntervalBetweenValueSamples is larger than 0, add
auto-generated value records as appropriate if value is larger
than expectedIntervalBetweenValueSamplespublic void copyInto(DoubleHistogram targetHistogram)
targetHistogram
- the histogram to copy intopublic void copyIntoCorrectedForCoordinatedOmission(DoubleHistogram targetHistogram, double expectedIntervalBetweenValueSamples)
copyCorrectedForCoordinatedOmission(double)
for more detailed explanation about how correction is applied)targetHistogram
- the histogram to copy intoexpectedIntervalBetweenValueSamples
- If expectedIntervalBetweenValueSamples is larger than 0, add
auto-generated value records as appropriate if value is larger
than expectedIntervalBetweenValueSamplespublic void add(DoubleHistogram fromHistogram) throws java.lang.ArrayIndexOutOfBoundsException
fromHistogram
- The other histogram.java.lang.ArrayIndexOutOfBoundsException
- (may throw) if values in fromHistogram's cannot be
covered by this histogram's rangepublic void addWhileCorrectingForCoordinatedOmission(DoubleHistogram fromHistogram, double expectedIntervalBetweenValueSamples)
To compensate for the loss of sampled values when a recorded value is larger than the expected
interval between value samples, the values added will include an auto-generated additional series of
decreasingly-smaller (down to the expectedIntervalBetweenValueSamples) value records for each count found
in the current histogram that is larger than the expectedIntervalBetweenValueSamples.
Note: This is a post-recording correction method, as opposed to the at-recording correction method provided
by recordValueWithExpectedInterval
. The two
methods are mutually exclusive, and only one of the two should be be used on a given data set to correct
for the same coordinated omission issue.
by
See notes in the description of the Histogram calls for an illustration of why this corrective behavior is important.
fromHistogram
- Other histogram. highestToLowestValueRatio and numberOfSignificantValueDigits must match.expectedIntervalBetweenValueSamples
- If expectedIntervalBetweenValueSamples is larger than 0, add
auto-generated value records as appropriate if value is larger
than expectedIntervalBetweenValueSamplesjava.lang.ArrayIndexOutOfBoundsException
- (may throw) if values exceed highestTrackableValuepublic void subtract(DoubleHistogram otherHistogram)
otherHistogram
- The other histogram.java.lang.ArrayIndexOutOfBoundsException
- (may throw) if values in fromHistogram's cannot be
covered by this histogram's rangepublic boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- the other histogram to compare topublic int hashCode()
hashCode
in class java.lang.Object
public long getTotalCount()
double getCurrentLowestTrackableNonZeroValue()
double getCurrentHighestTrackableValue()
public double getIntegerToDoubleValueConversionRatio()
getDoubleValueIteratedTo()
and
getDoubleValueIteratedFrom()
accessors to HistogramIterationValue
iterated values.public int getNumberOfSignificantValueDigits()
public long getHighestToLowestValueRatio()
public double sizeOfEquivalentValueRange(double value)
value
- The given valuepublic double lowestEquivalentValue(double value)
value
- The given valuepublic double highestEquivalentValue(double value)
value
- The given valuepublic double medianEquivalentValue(double value)
value
- The given valuepublic double nextNonEquivalentValue(double value)
value
- The given valuepublic boolean valuesAreEquivalent(double value1, double value2)
value1
- first value to comparevalue2
- second value to comparepublic int getEstimatedFootprintInBytes()
public long getStartTimeStamp()
getStartTimeStamp
in class EncodableHistogram
public void setStartTimeStamp(long timeStampMsec)
setStartTimeStamp
in class EncodableHistogram
timeStampMsec
- the value to set the time stamp to, [by convention] in msec since the epoch.public long getEndTimeStamp()
getEndTimeStamp
in class EncodableHistogram
public void setEndTimeStamp(long timeStampMsec)
setEndTimeStamp
in class EncodableHistogram
timeStampMsec
- the value to set the time stamp to, [by convention] in msec since the epoch.public java.lang.String getTag()
getTag
in class EncodableHistogram
public void setTag(java.lang.String tag)
setTag
in class EncodableHistogram
tag
- the tag string to assciate with this histogrampublic double getMinValue()
public double getMaxValue()
public double getMinNonZeroValue()
public double getMaxValueAsDouble()
getMaxValueAsDouble
in class EncodableHistogram
public double getMean()
public double getStdDeviation()
public double getValueAtPercentile(double percentile)
Note that two values are "equivalent" in this statement if
valuesAreEquivalent(double, double)
would return true.
percentile
- The percentile for which to return the associated valuepublic double getPercentileAtOrBelowValue(double value)
Note that two values are "equivalent" in this statement if
valuesAreEquivalent(double, double)
would return true.
value
- The value for which to return the associated percentilepublic double getCountBetweenValues(double lowValue, double highValue) throws java.lang.ArrayIndexOutOfBoundsException
lowValue
- The lower value bound on the range for which
to provide the recorded count. Will be rounded down with
lowestEquivalentValue
.highValue
- The higher value bound on the range for which to provide the recorded count.
Will be rounded up with highestEquivalentValue
.java.lang.ArrayIndexOutOfBoundsException
public long getCountAtValue(double value) throws java.lang.ArrayIndexOutOfBoundsException
value
- The value for which to provide the recorded countjava.lang.ArrayIndexOutOfBoundsException
public DoubleHistogram.Percentiles percentiles(int percentileTicksPerHalfDistance)
percentileTicksPerHalfDistance
- The number of iteration steps per half-distance to 100%.Iterable
<DoubleHistogramIterationValue
>
through the histogram using a
DoublePercentileIterator
public DoubleHistogram.LinearBucketValues linearBucketValues(double valueUnitsPerBucket)
valueUnitsPerBucket
- The size (in value units) of the linear buckets to useIterable
<DoubleHistogramIterationValue
>
through the histogram using a
DoubleLinearIterator
public DoubleHistogram.LogarithmicBucketValues logarithmicBucketValues(double valueUnitsInFirstBucket, double logBase)
valueUnitsInFirstBucket
- The size (in value units) of the first bucket in the iterationlogBase
- The multiplier by which bucket sizes will grow in each iteration stepIterable
<DoubleHistogramIterationValue
>
through the histogram using
a DoubleLogarithmicIterator
public DoubleHistogram.RecordedValues recordedValues()
Iterable
<DoubleHistogramIterationValue
>
through the histogram using
a DoubleRecordedValuesIterator
public DoubleHistogram.AllValues allValues()
Iterable
<DoubleHistogramIterationValue
>
through the histogram using a DoubleAllValuesIterator
public void outputPercentileDistribution(java.io.PrintStream printStream, java.lang.Double outputValueUnitScalingRatio)
printStream
- Stream into which the distribution will be output
outputValueUnitScalingRatio
- The scaling factor by which to divide histogram recorded values units in
outputpublic void outputPercentileDistribution(java.io.PrintStream printStream, int percentileTicksPerHalfDistance, java.lang.Double outputValueUnitScalingRatio)
printStream
- Stream into which the distribution will be output
percentileTicksPerHalfDistance
- The number of reporting points per exponentially decreasing half-distance
outputValueUnitScalingRatio
- The scaling factor by which to divide histogram recorded values units in
outputpublic void outputPercentileDistribution(java.io.PrintStream printStream, int percentileTicksPerHalfDistance, java.lang.Double outputValueUnitScalingRatio, boolean useCsvFormat)
printStream
- Stream into which the distribution will be output
percentileTicksPerHalfDistance
- The number of reporting points per exponentially decreasing half-distance
outputValueUnitScalingRatio
- The scaling factor by which to divide histogram recorded values units in
outputuseCsvFormat
- Output in CSV format if true. Otherwise use plain text form.private void writeObject(java.io.ObjectOutputStream o) throws java.io.IOException
java.io.IOException
private void readObject(java.io.ObjectInputStream o) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public int getNeededByteBufferCapacity()
getNeededByteBufferCapacity
in class EncodableHistogram
private int getNeededByteBufferCapacity(int relevantLength)
static boolean isDoubleHistogramCookie(int cookie)
private static boolean isCompressedDoubleHistogramCookie(int cookie)
private static boolean isNonCompressedDoubleHistogramCookie(int cookie)
public int encodeIntoByteBuffer(java.nio.ByteBuffer buffer)
buffer
- The buffer to encode intopublic int encodeIntoCompressedByteBuffer(java.nio.ByteBuffer targetBuffer, int compressionLevel)
encodeIntoCompressedByteBuffer
in class EncodableHistogram
targetBuffer
- The buffer to encode intocompressionLevel
- Compression level (for java.util.zip.Deflater).public int encodeIntoCompressedByteBuffer(java.nio.ByteBuffer targetBuffer)
targetBuffer
- The buffer to encode intoprivate static DoubleHistogram constructHistogramFromBuffer(int cookie, java.nio.ByteBuffer buffer, java.lang.Class<? extends AbstractHistogram> histogramClass, long minBarForHighestToLowestValueRatio) throws java.util.zip.DataFormatException
java.util.zip.DataFormatException
public static DoubleHistogram decodeFromByteBuffer(java.nio.ByteBuffer buffer, long minBarForHighestToLowestValueRatio)
buffer
- The buffer to decode fromminBarForHighestToLowestValueRatio
- Force highestTrackableValue to be set at least this highpublic static DoubleHistogram decodeFromByteBuffer(java.nio.ByteBuffer buffer, java.lang.Class<? extends AbstractHistogram> internalCountsHistogramClass, long minBarForHighestToLowestValueRatio)
Histogram
,
ConcurrentHistogram
, SynchronizedHistogram
,
IntCountsHistogram
, ShortCountsHistogram
).buffer
- The buffer to decode frominternalCountsHistogramClass
- The class to use for internal counts trackingminBarForHighestToLowestValueRatio
- Force highestTrackableValue to be set at least this highpublic static DoubleHistogram decodeFromCompressedByteBuffer(java.nio.ByteBuffer buffer, long minBarForHighestToLowestValueRatio) throws java.util.zip.DataFormatException
buffer
- The buffer to decode fromminBarForHighestToLowestValueRatio
- Force highestTrackableValue to be set at least this highjava.util.zip.DataFormatException
- on error parsing/decompressing the bufferpublic static DoubleHistogram decodeFromCompressedByteBuffer(java.nio.ByteBuffer buffer, java.lang.Class<? extends AbstractHistogram> internalCountsHistogramClass, long minBarForHighestToLowestValueRatio) throws java.util.zip.DataFormatException
Histogram
,
AtomicHistogram
, SynchronizedHistogram
,
IntCountsHistogram
, ShortCountsHistogram
).buffer
- The buffer to decode frominternalCountsHistogramClass
- The class to use for internal counts trackingminBarForHighestToLowestValueRatio
- Force highestTrackableValue to be set at least this highjava.util.zip.DataFormatException
- on error parsing/decompressing the bufferprivate long deriveInternalHighestToLowestValueRatio(long externalHighestToLowestValueRatio)
private long deriveIntegerValueRange(long externalHighestToLowestValueRatio, int numberOfSignificantValueDigits)
private long getLowestTrackingIntegerValue()
private static int findContainingBinaryOrderOfMagnitude(long longNumber)
private static int findContainingBinaryOrderOfMagnitude(double doubleNumber)
private int findCappedContainingBinaryOrderOfMagnitude(double doubleNumber)