Java源码示例:com.clearspring.analytics.stream.Counter
示例1
public CompositeData finishLocalSampling(String sampler, int count) throws OpenDataException
{
SamplerResult<ByteBuffer> samplerResults = metric.samplers.get(Sampler.valueOf(sampler))
.finishSampling(count);
TabularDataSupport result = new TabularDataSupport(COUNTER_TYPE);
for (Counter<ByteBuffer> counter : samplerResults.topK)
{
byte[] key = counter.getItem().array();
result.put(new CompositeDataSupport(COUNTER_COMPOSITE_TYPE, COUNTER_NAMES, new Object[] {
Hex.bytesToHex(key), // raw
counter.getCount(), // count
counter.getError(), // error
metadata.getKeyValidator().getString(ByteBuffer.wrap(key)) })); // string
}
return new CompositeDataSupport(SAMPLING_RESULT, SAMPLER_NAMES, new Object[]{
samplerResults.cardinality, result});
}
示例2
@Override
public Object getValue() {
Map<Object, Long> topN = new LinkedHashMap<Object, Long>();
if ((m_counter == null))
return topN;
List<Counter<Object>> topCounters = m_counter.topK(m_topElementCnt);
for (Counter<Object> counter : topCounters) {
topN.put(counter.getItem(), counter.getCount());
}
return topN;
}
示例3
@Override
public Object getValue() {
Map<Object, Long> topN = new LinkedHashMap<Object, Long>();
if ((m_counter == null))
return topN;
List<Counter<Object>> topCounters = m_counter.topK(m_topElementCnt);
for (Counter<Object> counter : topCounters) {
topN.put(counter.getItem(), counter.getCount());
}
return topN;
}
示例4
InternalTopK(String name, Number size, StreamSummary<Term> summary) {
super(name);
this.size = size;
this.summary = summary;
this.buckets = new ArrayList<>();
this.bucketsMap = null;
if (this.summary != null) {
List<Counter<Term>> counters = this.summary.topK(this.summary.size());
for (Counter<Term> c : counters) {
this.buckets.add(new TopK.Bucket(c.getItem().term, c.getCount(), c.getItem().bucketOrd, null));
}
this.sortBuckets();
}
}
示例5
private <T> Map<T, Long> countMap(List<Counter<T>> target)
{
Map<T, Long> counts = Maps.newHashMap();
for(Counter<T> counter : target)
{
counts.put(counter.getItem(), counter.getCount());
}
return counts;
}
示例6
@Override
public Object getValue() {
Map<Object, Long> topN = new LinkedHashMap<Object, Long>();
if ((m_counter == null))
return topN;
List<Counter<Object>> topCounters = m_counter.topK(m_topElementCnt);
for (Counter<Object> counter : topCounters) {
topN.put(counter.getItem(), counter.getCount());
}
return topN;
}