Class DoubleRecorder

java.lang.Object
org.HdrHistogram.DoubleRecorder
All Implemented Interfaces:
DoubleValueRecorder, IntervalHistogramProvider<DoubleHistogram>

public class DoubleRecorder extends Object implements DoubleValueRecorder, IntervalHistogramProvider<DoubleHistogram>
Records floating point (double) values, and provides stable interval DoubleHistogram samples from live recorded data without interrupting or stalling active recording of values. Each interval histogram provided contains all value counts accumulated since the previous interval histogram was taken.

This pattern is commonly used in logging interval histogram information while recording is ongoing.

DoubleRecorder supports concurrent recordValue(double) or recordValueWithExpectedInterval(double, double) calls. Recording calls are wait-free on architectures that support atomic increment operations, and are lock-free on architectures that do not.

A common pattern for using a DoubleRecorder looks like this:


 DoubleRecorder recorder = new DoubleRecorder(2); // Two decimal point accuracy
 DoubleHistogram intervalHistogram = null;
 ...
 [start of some loop construct that periodically wants to grab an interval histogram]
   ...
   // Get interval histogram, recycling previous interval histogram:
   intervalHistogram = recorder.getIntervalHistogram(intervalHistogram);
   histogramLogWriter.outputIntervalHistogram(intervalHistogram);
   ...
 [end of loop construct]
 
  • Constructor Summary

    Constructors
    Constructor
    Description
    DoubleRecorder(int numberOfSignificantValueDigits)
    Construct an auto-resizing DoubleRecorder using a precision stated as a number of significant decimal digits.
    DoubleRecorder(int numberOfSignificantValueDigits, boolean packed)
    Construct an auto-resizing DoubleRecorder using a precision stated as a number of significant decimal digits.
    DoubleRecorder(long highestToLowestValueRatio, int numberOfSignificantValueDigits)
    Construct a DoubleRecorder dynamic range of values to cover and a number of significant decimal digits.
  • Method Summary

    Modifier and Type
    Method
    Description
    Get a new instance of an interval histogram, which will include a stable, consistent view of all value counts accumulated since the last interval histogram was taken.
    Get an interval histogram, which will include a stable, consistent view of all value counts accumulated since the last interval histogram was taken.
    getIntervalHistogram(DoubleHistogram histogramToRecycle, boolean enforceContainingInstance)
    Get an interval histogram, which will include a stable, consistent view of all value counts accumulated since the last interval histogram was taken.
    void
    Place a copy of the value counts accumulated since accumulated (since the last interval histogram was taken) into targetHistogram.
    void
    recordValue(double value)
    Record a value
    void
    recordValueWithCount(double value, long count)
    Record a value in the histogram (adding to the value's current count)
    void
    recordValueWithExpectedInterval(double value, double expectedIntervalBetweenValueSamples)
    Record a value
    void
    Reset any value counts accumulated thus far.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DoubleRecorder

      public DoubleRecorder(int numberOfSignificantValueDigits, boolean packed)
      Construct an auto-resizing DoubleRecorder using a precision stated as a number of significant decimal digits.

      Depending on the valuer of the packed parameter DoubleRecorder can be configured to track value counts in a packed internal representation optimized for typical histogram recoded values are sparse in the value range and tend to be incremented in small unit counts. This packed representation tends to require significantly smaller amounts of storage when compared to unpacked representations, but can incur additional recording cost due to resizing and repacking operations that may occur as previously unrecorded values are encountered.

      Parameters:
      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.
      packed - Specifies whether the recorder will uses a packed internal representation or not.
    • DoubleRecorder

      public DoubleRecorder(int numberOfSignificantValueDigits)
      Construct an auto-resizing DoubleRecorder using a precision stated as a number of significant decimal digits.
      Parameters:
      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.
    • DoubleRecorder

      public DoubleRecorder(long highestToLowestValueRatio, int numberOfSignificantValueDigits)
      Construct a DoubleRecorder dynamic range of values to cover and a number of significant decimal digits.
      Parameters:
      highestToLowestValueRatio - specifies the dynamic range to use (as a ratio)
      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.
  • Method Details