|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.javasimon.callback.quantiles.Buckets
public abstract class Buckets
List of buckets and quantiles computer.
Samples are not kept in buckets only the counter indicates their presence.
Some details impact quantiles computation precision:
| Field Summary | |
|---|---|
protected int |
bucketNb
Number of real buckets (=buckets.length-2). |
protected Bucket[] |
buckets
Array of buckets, sorted by ranges. |
private LogTemplate<Split> |
logTemplate
Log template used to log quantiles. |
protected long |
max
Upper bound of all real buckets. |
protected long |
min
Lower bound of all real buckets. |
| Constructor Summary | |
|---|---|
Buckets(long min,
long max,
int bucketNb)
Constructor, initializes buckets. |
|
| Method Summary | |
|---|---|
void |
addValue(long value)
Searches the appropriate bucket and add the value in it. |
void |
addValues(Collection<Long> values)
For each value, search the appropriate bucket and add the value in it. |
void |
clear()
Clears all buckets. |
private double |
computeQuantile(double ration,
int totalCount)
Computes given quantile. |
protected double |
estimateQuantile(Bucket bucket,
double expectedCount,
double lastCount)
Interpolate quantile located in given Bucket using linear regression. |
protected Bucket |
getBucketForValue(long value)
Get the bucket containing the given value. |
int |
getBucketNb()
|
List<Bucket> |
getBuckets()
Returns the bucket list. |
String |
getLogMessage(Split lastSplit)
Transforms buckets and quantiles into a loggable message. |
LogTemplate<Split> |
getLogTemplate()
|
long |
getMax()
|
double |
getMedian()
Computes median. |
long |
getMin()
|
double |
getQuantile(double ratio)
Computes quantile. |
Double[] |
getQuantiles(double... ratios)
Computes many quantiles. |
Double[] |
getQuartiles()
Computes first (=0.25), second (=median=0.5) and third (=0.75) quartiles. |
private int |
checkAndGetTotalCount()
Computes expected count and check used buckets number. |
void |
log(Split lastSplit)
Logs eventually buckets config and quantiles. |
BucketsSample |
sample()
Sample buckets and quantiles state. |
void |
setLogTemplate(LogTemplate<Split> logTemplate)
|
String |
toString()
String containing: min/max/number configuration and 50%, 75% and 90% quantiles if available. |
private String |
toString(boolean bars)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final Bucket[] buckets
protected final int bucketNb
protected final long min
protected final long max
private LogTemplate<Split> logTemplate
| Constructor Detail |
|---|
public Buckets(long min,
long max,
int bucketNb)
min - Min of all valuesmax - Max of all valuesbucketNb - Number of buckets| Method Detail |
|---|
private int checkAndGetTotalCount()
throws IllegalStateException
IllegalStateException
private double computeQuantile(double ration,
int totalCount)
throws IllegalStateException,
IllegalArgumentException
ration - Nth quantile: 0.5 is mediantotalCount - Total count over all buckets
IllegalStateException - Buckets are poorly configured and
quantile can not be computed
IllegalArgumentException
protected double estimateQuantile(Bucket bucket,
double expectedCount,
double lastCount)
Bucket.min and Bucket.maxBucket.count
bucket - Current bucket containing the quantileexpectedCount - Searched valuelastCount - Value of the bucket lower bound
protected Bucket getBucketForValue(long value)
value - Value
public void addValue(long value)
public void addValues(Collection<Long> values)
public double getQuantile(double ratio)
ratio - Nth quantile, 0.5 is median. Expects values between 0 and 1.
public double getMedian()
public Double[] getQuartiles()
public Double[] getQuantiles(double... ratios)
ratios - Nth quantiles, 0.5 is median. Expects values between 0 and 1.
null, if computation failedpublic LogTemplate<Split> getLogTemplate()
public void setLogTemplate(LogTemplate<Split> logTemplate)
public BucketsSample sample()
public String toString()
toString in class Objectprivate String toString(boolean bars)
public void clear()
public List<Bucket> getBuckets()
public String getLogMessage(Split lastSplit)
getLogMessage in interface LogMessageSource<Split>lastSplit - Context
public void log(Split lastSplit)
public int getBucketNb()
public long getMin()
public long getMax()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||