Package org.apache.cassandra.metrics
Class FrequencySampler<T>
java.lang.Object
org.apache.cassandra.metrics.Sampler<T>
org.apache.cassandra.metrics.FrequencySampler<T>
- Type Parameters:
T-
Find the most frequent sample. A sample adds to the sum of its key ie
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. Note:Sampler.samplerExecutor is single threaded but we still need to synchronize as we have access
from both internal and the external JMX context that can cause races.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.cassandra.metrics.Sampler
Sampler.Sample<S>, Sampler.SamplerType -
Field Summary
Fields inherited from class org.apache.cassandra.metrics.Sampler
samplerExecutor -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbeginSampling(int capacity, long durationMillis) Start to record samplesfinishSampling(int count) Call to stop collecting samples, and gather the resultsprotected voidMethods inherited from class org.apache.cassandra.metrics.Sampler
addSample, disable, isActive, isEnabled, shutdownNowAndWait, toString, updateEndTime
-
Constructor Details
-
FrequencySampler
public FrequencySampler()
-
-
Method Details
-
beginSampling
public void beginSampling(int capacity, long durationMillis) Start to record samples- Specified by:
beginSamplingin classSampler<T>- Parameters:
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.durationMillis- Upperbound duration in milliseconds for sampling. The sampler stops accepting new samples after exceeding the duration even ifSampler.finishSampling(int)} is not called.
-
finishSampling
Call to stop collecting samples, and gather the results- Specified by:
finishSamplingin classSampler<T>- Parameters:
count- Number of most frequent items to return- Returns:
- a list of samples, the size is the minimum of the total samples and .
-
insert
-