io.airlift.stats.cardinality.HyperLogLog.cardinality()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中io.airlift.stats.cardinality.HyperLogLog.cardinality()方法的一些代码示例,展示了HyperLogLog.cardinality()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HyperLogLog.cardinality()方法的具体详情如下:
包路径:io.airlift.stats.cardinality.HyperLogLog
类名称:HyperLogLog
方法名:cardinality

HyperLogLog.cardinality介绍

暂无

代码示例

代码示例来源:origin: prestodb/presto

public long cardinality()
{
  if (isExact()) {
    return minhash.size();
  }
  return hll.cardinality();
}

代码示例来源:origin: prestodb/presto

@OutputFunction(StandardTypes.BIGINT)
public static void evaluateFinal(@AggregationState HyperLogLogState state, BlockBuilder out)
{
  HyperLogLog hyperLogLog = state.getHyperLogLog();
  if (hyperLogLog == null) {
    BIGINT.writeLong(out, 0);
  }
  else {
    BIGINT.writeLong(out, hyperLogLog.cardinality());
  }
}

代码示例来源:origin: prestodb/presto

@ScalarFunction
@Description("compute the cardinality of a HyperLogLog instance")
@SqlType(StandardTypes.BIGINT)
public static long cardinality(@SqlType(StandardTypes.HYPER_LOG_LOG) Slice serializedHll)
{
  return HyperLogLog.newInstance(serializedHll).cardinality();
}

代码示例来源:origin: io.prestosql/presto-main

public long cardinality()
{
  if (isExact()) {
    return minhash.size();
  }
  return hll.cardinality();
}

代码示例来源:origin: prestosql/presto

public long cardinality()
{
  if (isExact()) {
    return minhash.size();
  }
  return hll.cardinality();
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

@OutputFunction(StandardTypes.BIGINT)
  public static void evaluateFinal(HyperLogLogState state, BlockBuilder out)
  {
    HyperLogLog hyperLogLog = state.getHyperLogLog();
    if (hyperLogLog == null) {
      BIGINT.writeLong(out, 0);
    }
    else {
      BIGINT.writeLong(out, hyperLogLog.cardinality());
    }
  }
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

@ScalarFunction
  @Description("compute the cardinality of a HyperLogLog instance")
  @SqlType(StandardTypes.BIGINT)
  public static long cardinality(@SqlType(StandardTypes.HYPER_LOG_LOG) Slice serializedHll)
  {
    return HyperLogLog.newInstance(serializedHll).cardinality();
  }
}

代码示例来源:origin: io.prestosql/presto-main

@OutputFunction(StandardTypes.BIGINT)
public static void evaluateFinal(@AggregationState HyperLogLogState state, BlockBuilder out)
{
  HyperLogLog hyperLogLog = state.getHyperLogLog();
  if (hyperLogLog == null) {
    BIGINT.writeLong(out, 0);
  }
  else {
    BIGINT.writeLong(out, hyperLogLog.cardinality());
  }
}

代码示例来源:origin: prestosql/presto

@ScalarFunction
@Description("compute the cardinality of a HyperLogLog instance")
@SqlType(StandardTypes.BIGINT)
public static long cardinality(@SqlType(StandardTypes.HYPER_LOG_LOG) Slice serializedHll)
{
  return HyperLogLog.newInstance(serializedHll).cardinality();
}

代码示例来源:origin: prestosql/presto

@OutputFunction(StandardTypes.BIGINT)
  public static void evaluateFinal(@AggregationState HyperLogLogState state, BlockBuilder out)
  {
    HyperLogLog hyperLogLog = state.getHyperLogLog();
    if (hyperLogLog == null) {
      BIGINT.writeLong(out, 0);
    }
    else {
      BIGINT.writeLong(out, hyperLogLog.cardinality());
    }
  }
}

代码示例来源:origin: io.prestosql/presto-main

@ScalarFunction
@Description("compute the cardinality of a HyperLogLog instance")
@SqlType(StandardTypes.BIGINT)
public static long cardinality(@SqlType(StandardTypes.HYPER_LOG_LOG) Slice serializedHll)
{
  return HyperLogLog.newInstance(serializedHll).cardinality();
}

代码示例来源:origin: airlift/airlift

double error = (hll.cardinality() - cardinality) * 1.0 / cardinality;

代码示例来源:origin: io.airlift/stats

double error = (hll.cardinality() - cardinality) * 1.0 / cardinality;

代码示例来源:origin: io.airlift/stats

private void verifyRoundtrip(List<Long> sequence)
  {
    HyperLogLog hll = HyperLogLog.newInstance(2048);

    for (Long value : sequence) {
      hll.add(value);
    }

    hll.verify();

    Slice serialized = hll.serialize();
    HyperLogLog deserialized = HyperLogLog.newInstance(serialized);
    deserialized.verify();

    assertEquals(hll.cardinality(), deserialized.cardinality());

    Slice reserialized = deserialized.serialize();
    assertSlicesEqual(serialized, reserialized);
  }
}

代码示例来源:origin: airlift/airlift

private void verifyRoundtrip(List<Long> sequence)
  {
    HyperLogLog hll = HyperLogLog.newInstance(2048);

    for (Long value : sequence) {
      hll.add(value);
    }

    hll.verify();

    Slice serialized = hll.serialize();
    HyperLogLog deserialized = HyperLogLog.newInstance(serialized);
    deserialized.verify();

    assertEquals(hll.cardinality(), deserialized.cardinality());

    Slice reserialized = deserialized.serialize();
    assertSlicesEqual(serialized, reserialized);
  }
}

代码示例来源:origin: airlift/airlift

private void verifyMerge(List<Long> one, List<Long> two)
{
  HyperLogLog hll1 = HyperLogLog.newInstance(2048);
  HyperLogLog hll2 = HyperLogLog.newInstance(2048);
  HyperLogLog expected = HyperLogLog.newInstance(2048);
  for (long value : one) {
    hll1.add(value);
    expected.add(value);
  }
  for (long value : two) {
    hll2.add(value);
    expected.add(value);
  }
  hll1.verify();
  hll2.verify();
  hll1.mergeWith(hll2);
  hll1.verify();
  assertEquals(hll1.cardinality(), expected.cardinality());
  assertEquals(hll1.serialize(), expected.serialize());
}

代码示例来源:origin: io.airlift/stats

private void verifyMerge(List<Long> one, List<Long> two)
{
  HyperLogLog hll1 = HyperLogLog.newInstance(2048);
  HyperLogLog hll2 = HyperLogLog.newInstance(2048);
  HyperLogLog expected = HyperLogLog.newInstance(2048);
  for (long value : one) {
    hll1.add(value);
    expected.add(value);
  }
  for (long value : two) {
    hll2.add(value);
    expected.add(value);
  }
  hll1.verify();
  hll2.verify();
  hll1.mergeWith(hll2);
  hll1.verify();
  assertEquals(hll1.cardinality(), expected.cardinality());
  assertEquals(hll1.serialize(), expected.serialize());
}

相关文章