@Experimental public class HistogramData extends java.lang.Object implements java.io.Serializable
We may consider using Apache Commons or HdrHistogram library in the future for advanced features such as sparsely populated histograms.
This class is considered experimental and may break or receive backwards-incompatible changes in future versions of the Apache Beam SDK.
Modifier and Type | Class and Description |
---|---|
static interface |
HistogramData.BucketType |
static class |
HistogramData.LinearBuckets |
Constructor and Description |
---|
HistogramData(HistogramData.BucketType bucketType)
Create a histogram.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
long |
getCount(int bucketIndex)
Get the bucket count for the given bucketIndex.
|
java.lang.String |
getPercentileString(java.lang.String elemType,
java.lang.String unit) |
long |
getTotalCount() |
static HistogramData |
linear(double start,
double width,
int numBuckets)
Create a histogram with linear buckets.
|
double |
p50() |
double |
p90() |
double |
p99() |
void |
record(double... values) |
void |
record(double value) |
public HistogramData(HistogramData.BucketType bucketType)
bucketType
- a bucket type for a new histogram instance.public static HistogramData linear(double start, double width, int numBuckets)
start
- Lower bound of a starting bucket.width
- Bucket width. Smaller width implies a better resolution for percentile estimation.numBuckets
- The number of buckets. Upper bound of an ending bucket is defined by start +
width * numBuckets.public void record(double... values)
public void clear()
public void record(double value)
public long getTotalCount()
public java.lang.String getPercentileString(java.lang.String elemType, java.lang.String unit)
public long getCount(int bucketIndex)
This method does not guarantee the atomicity when sequentially accessing the multiple buckets i.e. other threads may alter the value between consecutive invocations. For summing the total number of elements in the histogram, use `getTotalCount()` instead.
bucketIndex
- index of the bucketpublic double p99()
public double p90()
public double p50()