当前位置: 首页>>代码示例>>Java>>正文


Java StreamSummary.offer方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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


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