• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java StreamSummary类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.clearspring.analytics.stream.StreamSummary的典型用法代码示例。如果您正苦于以下问题:Java StreamSummary类的具体用法?Java StreamSummary怎么用?Java StreamSummary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StreamSummary类属于com.clearspring.analytics.stream包,在下文中一共展示了StreamSummary类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: enter

import com.clearspring.analytics.stream.StreamSummary; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void enter(Object value) {
    Object[] params = (Object[]) value;

    if (m_counter == null) {
        m_capacity = (Integer) params[0];
        m_topElementCnt = (Integer) params[1];
        m_counter = new StreamSummary<Object>(m_capacity.intValue());
    }

    if (params[2] instanceof Map<?, ?>) {
        Map<Object, Long> topCounters = (Map<Object, Long>) params[2];
        Set<Object> topKeySet = topCounters.keySet();
        for (Object key : topKeySet) {
            m_counter.offer(key, topCounters.get(key).intValue());
        }
    }
}
 
开发者ID:pulsarIO,项目名称:realtime-analytics,代码行数:20,代码来源:TopNumReformAggregator.java


示例2: readFrom

import com.clearspring.analytics.stream.StreamSummary; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    name = in.readString();
    size = in.readInt();
    int n;
    if (in.readBoolean()) {
        int capacity = in.readInt();
        this.summary = new StreamSummary<>(capacity);
        n = in.readInt();
        byte[] bytes = new byte[n];
        in.read(bytes);
        try {
            summary.fromBytes(bytes);
        } catch (ClassNotFoundException e) {
            throw new IOException("Failed to build summary", e);
        }
    }
    n = in.readInt();
    this.buckets = new ArrayList<>();
    this.bucketsMap = null;
    for (int i = 0; i < n; ++i) {
        this.buckets.add(Bucket.readFrom(in));
    }
    // buckets are alreaduy sorted here
}
 
开发者ID:algolia,项目名称:elasticsearch-topk-plugin,代码行数:26,代码来源:InternalTopK.java


示例3: testStreamSummaryAccuracy

import com.clearspring.analytics.stream.StreamSummary; //导入依赖的package包/类
@Test
public void testStreamSummaryAccuracy() {

    StreamSummary<Integer> vs = new StreamSummary<Integer>(5);

    Random random = new Random();
    random.setSeed(3128);
    int maxItems = 5;
    for (int i = 0; i < maxItems; i++) {
        vs.offer(i, random.nextInt(2000));
    }

    int fetchTopK = 5;
    List<Counter<Integer>> topK = vs.topK(fetchTopK);
    for (Counter<Integer> c : topK) {

        //    System.out.println(c.toString());
    }
}
 
开发者ID:sumanthn,项目名称:SketchOnStorm,代码行数:20,代码来源:StreamSummaryTest.java


示例4: enter

import com.clearspring.analytics.stream.StreamSummary; //导入依赖的package包/类
@Override
public void enter(Object value) {
	Object[] values = (Object[]) value;

	if (counter == null) {
		capacity = (Integer) values[0];
		topN = (Integer) values[1];
		counter = new StreamSummary<Object>(capacity.intValue());
	}

	counter.offer(values[2]);
}
 
开发者ID:sdcuike,项目名称:esper-2015,代码行数:13,代码来源:TopKAggregator.java


示例5: resortTopN

import com.clearspring.analytics.stream.StreamSummary; //导入依赖的package包/类
private List<String> resortTopN(DruidSpecs druidSpecs, String dimension,
		List<Map<String, Object>> listOfResult) {
	StreamSummary<String> topN = new StreamSummary<String>(TOPN_MAX);
	for (Map<String, Object> map : listOfResult) {
		@SuppressWarnings("unchecked")
		List<Map<String, Object>> resultList = (List<Map<String, Object>>) map
				.get(RESULT);
		if (resultList != null) {
			for (Map<String, Object> result : resultList) {
				Number metricNum = (Number) result.get(druidSpecs.getSort());
				;
				String dimStr = (String) result.get(dimension);
				if (dimStr == null) {
					dimStr = "";
				}
				topN.offer(dimStr, metricNum.intValue());
			}
		}
	}
	return FluentIterable.from(topN.topK(druidSpecs.getLimit()))
			.transform(new Function<Counter<String>, String>() {
				@Override
				public String apply(Counter<String> input) {
					return input.getItem();
				}
			}).toList();
}
 
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:28,代码来源:DruidQueryProcessor.java


示例6: enter

import com.clearspring.analytics.stream.StreamSummary; //导入依赖的package包/类
@Override
public void enter(Object value) {

    Object[] params = (Object[]) value;

    if (m_counter == null) {
        m_capacity = (Integer) params[0];
        m_topElementCnt = (Integer) params[1];
        m_counter = new StreamSummary<Object>(m_capacity.intValue());
    }

    if (splitter == null) {
        if (params[3] instanceof Character) {
            splitter = Splitter.on((Character) params[3]);
        } else if (params[3] instanceof String) {
            splitter = Splitter.on((String) params[3]);
        }
    }
    if (params[2] instanceof String && splitter != null) {
        Iterable<String> it = splitter.split((String) params[2]);
        for (String nested : it) {
            m_counter.offer(nested);
        }
    } else {
        m_counter.offer(params[2]);
    }
}
 
开发者ID:pulsarIO,项目名称:realtime-analytics,代码行数:28,代码来源:TopKNestedAggregator.java


示例7: InternalTopK

import com.clearspring.analytics.stream.StreamSummary; //导入依赖的package包/类
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();
    }
}
 
开发者ID:algolia,项目名称:elasticsearch-topk-plugin,代码行数:15,代码来源:InternalTopK.java


示例8: buildAggregation

import com.clearspring.analytics.stream.StreamSummary; //导入依赖的package包/类
@Override
public InternalAggregation buildAggregation(long owningBucketOrdinal) {
    StreamSummary<Term> summary = summaries == null || owningBucketOrdinal >= summaries.size() ? null : summaries.get(owningBucketOrdinal);
    InternalTopK topk = new InternalTopK(name, size, summary);
    for (TopK.Bucket bucket : topk.getBuckets()) {
        bucket.aggregations = bucketAggregations(bucket.bucketOrd);
    }
    return topk;
}
 
开发者ID:algolia,项目名称:elasticsearch-topk-plugin,代码行数:10,代码来源:TopKAggregator.java


示例9: testStringBuckets

import com.clearspring.analytics.stream.StreamSummary; //导入依赖的package包/类
@Test
public void testStringBuckets() {
    StreamSummary<String> vs = new StreamSummary<String>(3);
    String[] stream = {"X", "X", "Y", "Z", "A", "B", "C", "X", "X", "A", "C", "A", "A"};
    for (String i : stream) {
        vs.offer(i, 10);
    }
    List<Counter<String>> topK = vs.topK(3);
    for (Counter<String> c : topK) {
        // assertTrue(Arrays.asList("A", "C", "X").contains(c.getItem()));
        //  System.out.println(c.toString());
    }
}
 
开发者ID:sumanthn,项目名称:SketchOnStorm,代码行数:14,代码来源:StreamSummaryTest.java


示例10: enter

import com.clearspring.analytics.stream.StreamSummary; //导入依赖的package包/类
@Override
public void enter(Object value) {
	
	Object[] params = (Object[]) value;
	
	if(m_counter == null) {
	  m_capacity = (Integer) params[0];
	  m_topElementCnt = (Integer) params[1];
	  m_counter = new StreamSummary<Object>(m_capacity.intValue());
	}
			 
	
	m_counter.offer(params[2]);
	
}
 
开发者ID:pulsarIO,项目名称:jetstream-esper,代码行数:16,代码来源:TopKAggregator.java


示例11: run

import com.clearspring.analytics.stream.StreamSummary; //导入依赖的package包/类
@Override
public void run() {

	m_topElementCounter = new StreamSummary<Object>(1000);
	
	long prevTime = System.currentTimeMillis();
	
	while (!isShutDown()) {

		long currTime = System.currentTimeMillis();
		
		if ((currTime - prevTime) > 30000) {
			
			// every 15 secs we will create a new summary
	
			prevTime = currTime;
			m_topElementCounter = new StreamSummary<Object>(1000);
			
		}
	
		
		try {
			m_topElementCounter.offer(m_queue.take());
		} catch (Throwable e) {
			// swallow the exception
		}
		
		refreshTopNRegistry();

	}

}
 
开发者ID:pulsarIO,项目名称:jetstream,代码行数:33,代码来源:Tracker.java



注:本文中的com.clearspring.analytics.stream.StreamSummary类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java State类代码示例发布时间:2022-05-22
下一篇:
Java FocusControl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap