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


Java HyperLogLog.offer方法代码示例

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


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

示例1: hllSerializationTest

import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的package包/类
@Test
public void hllSerializationTest() {
    HyperLogLog hll = new HyperLogLog(16);
    for (int i = 0; i < 10; i++) {
        hll.offer(i);
    }

    try {

        //this would check if we can return the data as string
        //and still be usable after we build HLL
        //both should use the same bytes and same hash function to merge cardinality

        String hllAsStr = Base64.encodeBase64String(hll.getBytes());

        HyperLogLog hll2 = HyperLogLog.Builder.build(Base64.decodeBase64(hllAsStr));
        assertEquals(hll.cardinality(), hll2.cardinality());
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:sumanthn,项目名称:SketchOnStorm,代码行数:22,代码来源:HLLTest.java

示例2: testHllFieldSerializedSize

import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的package包/类
@Test
public void testHllFieldSerializedSize()
    throws Exception {
  for (int i = 5; i < 10; i++) {
    HyperLogLog hll = new HyperLogLog(i);
    Assert.assertEquals(HllSizeUtils.getHllFieldSizeFromLog2m(i), hll.getBytes().length);
    LOGGER.info("Estimated: " + hll.cardinality());
    for (int j = 0; j < 100; j++) {
      hll.offer(rand.nextLong());
    }
    Assert.assertEquals(HllSizeUtils.getHllFieldSizeFromLog2m(i), hll.getBytes().length);
    LOGGER.info("Estimated: " + hll.cardinality());
    for (int j = 0; j < 9900; j++) {
      hll.offer(rand.nextLong());
    }
    Assert.assertEquals(HllSizeUtils.getHllFieldSizeFromLog2m(i), hll.getBytes().length);
    LOGGER.info("Estimated: " + hll.cardinality());
  }
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:20,代码来源:HllFieldSizeTest.java

示例3: main

import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException, CardinalityMergeException {
  HyperLogLog hll = new HyperLogLog(12);
  for (int i = 0; i < 25; i++) {
    hll.offer(i);
  }
  System.out.println(hll.cardinality());
  byte[] bytes =hll.getBytes();
  HyperLogLog hll2 = new HyperLogLog(12);
  HyperLogLog other = HyperLogLog.Builder.build(bytes);
  hll2.addAll(other);
  System.out.println(hll2.cardinality());
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:13,代码来源:StatisticsAggrFunctions.java

示例4: getHLLResultValues

import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的package包/类
private static List<Serializable> getHLLResultValues(int numberOfElements) {
    List<Serializable> hllResultList = new ArrayList<Serializable>();
    for (int i = 0; i < numberOfElements; ++i) {
        HyperLogLog hllResult = new HyperLogLog(DistinctCountHLLAggregationFunction.DEFAULT_BIT_SIZE);
        hllResult.offer(i);
        hllResultList.add(hllResult);
    }
    return hllResultList;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:10,代码来源:DistinctCountHLLTest.java

示例5: init

import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的package包/类
@Override
public HyperLogLog init(TridentTuple tuple) {
    HyperLogLog hll = zero();
    //directly offer the object, internally the instance is checked
    // and the hash is computed based on type
    hll.offer(tuple.getValueByField(fieldName));
    return hll;
}
 
开发者ID:sumanthn,项目名称:SketchOnStorm,代码行数:9,代码来源:HLLAggregator.java

示例6: testMerge

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

        HyperLogLog hll = new HyperLogLog(16);

        for (int i = 0; i < 10; i++) {
            hll.offer(i);
        }

        HyperLogLog hll2 = new HyperLogLog(16);
        for (int i = 1000; i < (1000 + 10); i++) {
            hll2.offer(i);
        }

        HyperLogLog hll3 = new HyperLogLog(16);

        assertEquals(hll.cardinality(), 10);
        assertEquals(hll2.cardinality(), 10);
        assertEquals(hll3.cardinality(), 0);

        try {
            ICardinality hllMerged = hll.merge(hll2);
            hllMerged = hllMerged.merge(hll3);
//            System.out.println(hllMerged.cardinality());

            assertEquals(hllMerged.cardinality(), 20);
        } catch (CardinalityMergeException e) {
            e.printStackTrace();
        }
    }
 
开发者ID:sumanthn,项目名称:SketchOnStorm,代码行数:31,代码来源:HLLTest.java

示例7: add

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

示例8: offerNumberInRangeTo

import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的package包/类
public void offerNumberInRangeTo(HyperLogLog hyperLogLog, int start, int end) {
    end = Math.min(end, arr.length);
    for (int i = start; i < end; i++) {
        hyperLogLog.offer(arr[i]);
    }
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:7,代码来源:DistinctCountHLLTest.java

示例9: singleValueHllAsString

import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的package包/类
/**
 * Generate a hll from a single value, and convert it to string type.
 * It is used for default derived field value.
 * @param log2m
 * @param value
 * @return
 */
public static String singleValueHllAsString(int log2m, Object value) {
  HyperLogLog hll = new HyperLogLog(log2m);
  hll.offer(value);
  return convertHllToString(hll);
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:13,代码来源:HllUtil.java


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