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


Java HyperLogLog.cardinality方法代码示例

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


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

示例1: count

import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的package包/类
@Override
public long count() {
    final Iterator<HyperLogLog> it = states.iterator();

    if (!it.hasNext()) {
        return 0L;
    }

    HyperLogLog current = it.next();

    while (it.hasNext()) {
        try {
            current.addAll(it.next());
        } catch (CardinalityMergeException e) {
            throw new RuntimeException(e);
        }
    }

    return current.cardinality();
}
 
开发者ID:spotify,项目名称:heroic,代码行数:21,代码来源:ReduceHyperLogLogCardinalityBucket.java

示例2: reduce

import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的package包/类
@Override
public Long reduce(List<HyperLogLog> combinedResultList) {
  if ((combinedResultList == null) || combinedResultList.isEmpty()) {
    return 0L;
  }
  HyperLogLog reducedResult = combinedResultList.get(0);
  for (int i = 1; i < combinedResultList.size(); ++i) {
    try {
      reducedResult.addAll(combinedResultList.get(i));
    } catch (CardinalityMergeException e) {
      LOGGER.error("Caught exception while merging Cardinality using HyperLogLog", e);
      Utils.rethrowException(e);
    }
  }
  return reducedResult.cardinality();
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:17,代码来源:DistinctCountHLLAggregationFunction.java

示例3: testInsertionTime

import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的package包/类
@Test
public void testInsertionTime() {
    int numOfItems = 10000000;

    println("#items_inserted, HLL_time(nano), IntOpenHashSet(nano), time_ratio, estimate, precise, error");
    for (int i = 0; i < numOfItems; i+=numOfItems/17) {
        if (i == 0) {
            continue;
        }
        RandomNumberArray arr = new RandomNumberArray(i, DUPLICATION_PER_ITEM);
        HyperLogLog hllResult = new HyperLogLog(DistinctCountHLLAggregationFunction.DEFAULT_BIT_SIZE);
        IntOpenHashSet set = new IntOpenHashSet(); //HashSet<Integer> set = new HashSet<Integer>();
        long t1 = System.nanoTime();
        arr.offerAllNumberTo(hllResult);
        long t2 = System.nanoTime();
        arr.offerAllNumberTo(set);
        long t3 = System.nanoTime();
        long estimate = hllResult.cardinality();
        long precise = set.size();
        println(i + ", " + "" + (t2 - t1) + ", " + (t3 - t2) + ", " + (t2 - t1 + 0.0) / (t3 - t2 + 0.0) + ", "
                + estimate + ", " + precise + ", " + getErrorString(precise, estimate));
    }
    assertEquals(true, true);
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:25,代码来源:DistinctCountHLLTest.java

示例4: testMemoryConsumption

import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的package包/类
@Test
public void testMemoryConsumption() {
    int numOfItems = 10000000;

    println("#items_inserted, HLL_ser_size, openHashSet_ser_size, ser_size_ratio, estimate, precise, error");
    for (int i = 0; i < numOfItems; i+=numOfItems/17) {
        if (i == 0) {
            continue;
        }
        RandomNumberArray arr = new RandomNumberArray(i, DUPLICATION_PER_ITEM);
        HyperLogLog hllResult = new HyperLogLog(DistinctCountHLLAggregationFunction.DEFAULT_BIT_SIZE);
        IntOpenHashSet set = new IntOpenHashSet();
        arr.offerAllNumberTo(hllResult);
        arr.offerAllNumberTo(set);
        int hllSize = getSerializedSize(hllResult);
        int setSize = getSerializedSize(set);
        long estimate = hllResult.cardinality();
        long precise = set.size();
        println(i + ", " + hllSize + ", " + setSize + ", " + (hllSize + 0.0) / (setSize + 0.0) + ", "
                + estimate + ", " + precise + ", " + getErrorString(precise, estimate));
    }
    assertEquals(true, true);
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:24,代码来源:DistinctCountHLLTest.java

示例5: fetchUniqueUserCount

import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的package包/类
public int fetchUniqueUserCount(final int minOfDay){
    HyperLogLog hllSketch = fetchSketchForMin(minOfDay);
    if (hllSketch!=null)
        hllSketch.cardinality();

    return -1;

}
 
开发者ID:sumanthn,项目名称:SketchOnStorm,代码行数:9,代码来源:UserIdQueryHandler.java

示例6: count

import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的package包/类
@Override
public Response count(final HyperLogLog log, final Request request) {
    return new NumericResponse<>(log.cardinality());
}
 
开发者ID:mintDS,项目名称:mintds,代码行数:5,代码来源:HyperLogLogStore.java

示例7: extractFinalResult

import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的package包/类
@Nonnull
@Override
public Long extractFinalResult(@Nonnull HyperLogLog intermediateResult) {
  return intermediateResult.cardinality();
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:6,代码来源:DistinctCountHLLAggregationFunction.java


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