T
- public abstract class FrequencySampler<T> extends Sampler<T>
add("x", 10); and add("x", 20); will result in "x" = 30
This uses StreamSummary to only store the approximate cardinality (capacity) of keys. If the number of distinct keys exceed the capacity, the error of the sample may increase depending on distribution of keys among the total set.Sampler.Sample<S>, Sampler.SamplerType
Constructor and Description |
---|
FrequencySampler() |
Modifier and Type | Method and Description |
---|---|
void |
beginSampling(int capacity,
int durationMillis)
Start to record samples
|
java.util.List<Sampler.Sample<T>> |
finishSampling(int count)
Call to stop collecting samples, and gather the results
|
protected void |
insert(T item,
long value) |
boolean |
isEnabled() |
public void beginSampling(int capacity, int durationMillis)
beginSampling
in class Sampler<T>
capacity
- Number of sample items to keep in memory, the lower this is
the less accurate results are. For best results use value
close to cardinality, but understand the memory trade offs.public java.util.List<Sampler.Sample<T>> finishSampling(int count)
finishSampling
in class Sampler<T>
count
- Number of most frequent items to returnCopyright © 2009-2021 The Apache Software Foundation