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

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

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

HyperLogLog.add介绍

[英]Adds a value that has already been hashed to the set of values tracked by this HyperLogLog instance.
[中]将已散列的值添加到此HyperLogLog实例跟踪的值集。

代码示例

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

public void add(Slice value)
{
  addHash(Murmur3.hash64(value));
  hll.add(value);
}

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

public void add(long value)
{
  addHash(Murmur3.hash64(value));
  hll.add(value);
}

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

private static Slice nextHyperLogLog(Random random)
{
  HyperLogLog hll = HyperLogLog.newInstance(HYPER_LOG_LOG_BUCKETS);
  int size = random.nextInt(MAX_HYPER_LOG_LOG_ELEMENTS);
  for (int i = 0; i < size; i++) {
    hll.add(random.nextLong());
  }
  return hll.serialize();
}

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

@ScalarFunction
  @SqlType(StandardTypes.HYPER_LOG_LOG)
  public static Slice createHll(@SqlType(StandardTypes.BIGINT) long value)
  {
    HyperLogLog hll = HyperLogLog.newInstance(4096);
    hll.add(value);
    return hll.serialize();
  }
}

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

@InputFunction
public static void input(@AggregationState HyperLogLogState state, @SqlType(StandardTypes.DOUBLE) double value)
{
  HyperLogLog hll = getOrCreateHyperLogLog(state);
  state.addMemoryUsage(-hll.estimatedInMemorySize());
  hll.add(Double.doubleToLongBits(value));
  state.addMemoryUsage(hll.estimatedInMemorySize());
}

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

@InputFunction
public static void input(@AggregationState HyperLogLogState state, @SqlType(StandardTypes.BIGINT) long value)
{
  HyperLogLog hll = getOrCreateHyperLogLog(state);
  state.addMemoryUsage(-hll.estimatedInMemorySize());
  hll.add(value);
  state.addMemoryUsage(hll.estimatedInMemorySize());
}

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

@InputFunction
@LiteralParameters("x")
public static void input(@AggregationState HyperLogLogState state, @SqlType("varchar(x)") Slice value)
{
  HyperLogLog hll = getOrCreateHyperLogLog(state);
  state.addMemoryUsage(-hll.estimatedInMemorySize());
  hll.add(value);
  state.addMemoryUsage(hll.estimatedInMemorySize());
}

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

@Override
  public Object getExpectedValue(int start, int length)
  {
    if (length == 0) {
      return null;
    }

    HyperLogLog hll = HyperLogLog.newInstance(NUMBER_OF_BUCKETS);
    for (int i = start; i < start + length; i++) {
      hll.add(i);
    }
    hll.makeDense();
    return new SqlVarbinary(hll.serialize().getBytes());
  }
}

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

@Override
public Block[] getSequenceBlocks(int start, int length)
{
  BlockBuilder blockBuilder = HYPER_LOG_LOG.createBlockBuilder(null, length);
  for (int i = start; i < start + length; i++) {
    HyperLogLog hll = HyperLogLog.newInstance(NUMBER_OF_BUCKETS);
    hll.add(i);
    hll.makeDense();
    HYPER_LOG_LOG.writeSlice(blockBuilder, hll.serialize());
  }
  return new Block[] {blockBuilder.build()};
}

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

public void add(Slice value)
{
  addHash(Murmur3.hash64(value));
  hll.add(value);
}

代码示例来源:origin: com.facebook.presto/presto-thrift-connector-api

private static Slice nextHyperLogLog(Random random)
{
  HyperLogLog hll = HyperLogLog.newInstance(HYPER_LOG_LOG_BUCKETS);
  int size = random.nextInt(MAX_HYPER_LOG_LOG_ELEMENTS);
  for (int i = 0; i < size; i++) {
    hll.add(random.nextLong());
  }
  return hll.serialize();
}

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

@InputFunction
public static void input(HyperLogLogState state, @SqlType(StandardTypes.DOUBLE) double value)
{
  HyperLogLog hll = getOrCreateHyperLogLog(state);
  state.addMemoryUsage(-hll.estimatedInMemorySize());
  hll.add(Double.doubleToLongBits(value));
  state.addMemoryUsage(hll.estimatedInMemorySize());
}

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

@ScalarFunction
  @SqlType(StandardTypes.HYPER_LOG_LOG)
  public static Slice createHll(@SqlType(StandardTypes.BIGINT) long value)
  {
    HyperLogLog hll = HyperLogLog.newInstance(4096);
    hll.add(value);
    return hll.serialize();
  }
}

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

@InputFunction
public static void input(HyperLogLogState state, @SqlType(StandardTypes.VARCHAR) Slice value)
{
  HyperLogLog hll = getOrCreateHyperLogLog(state);
  state.addMemoryUsage(-hll.estimatedInMemorySize());
  hll.add(value);
  state.addMemoryUsage(hll.estimatedInMemorySize());
}

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

@InputFunction
public static void input(@AggregationState HyperLogLogState state, @SqlType(StandardTypes.BIGINT) long value)
{
  HyperLogLog hll = getOrCreateHyperLogLog(state);
  state.addMemoryUsage(-hll.estimatedInMemorySize());
  hll.add(value);
  state.addMemoryUsage(hll.estimatedInMemorySize());
}

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

@InputFunction
public static void input(HyperLogLogState state, @SqlType(StandardTypes.BIGINT) long value, @SqlType(StandardTypes.DOUBLE) double maxStandardError)
{
  HyperLogLog hll = getOrCreateHyperLogLog(state, maxStandardError);
  state.addMemoryUsage(-hll.estimatedInMemorySize());
  hll.add(value);
  state.addMemoryUsage(hll.estimatedInMemorySize());
}

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

@InputFunction
public static void inputBinary(HyperLogLogState state, @SqlType(StandardTypes.VARBINARY) Slice value, @SqlType(StandardTypes.DOUBLE) double maxStandardError)
{
  HyperLogLog hll = getOrCreateHyperLogLog(state, maxStandardError);
  state.addMemoryUsage(-hll.estimatedInMemorySize());
  hll.add(value);
  state.addMemoryUsage(hll.estimatedInMemorySize());
}

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

@InputFunction
@LiteralParameters("x")
public static void input(@AggregationState HyperLogLogState state, @SqlType("varchar(x)") Slice value)
{
  HyperLogLog hll = getOrCreateHyperLogLog(state);
  state.addMemoryUsage(-hll.estimatedInMemorySize());
  hll.add(value);
  state.addMemoryUsage(hll.estimatedInMemorySize());
}

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

@Override
public Block[] getSequenceBlocks(int start, int length)
{
  BlockBuilder blockBuilder = HYPER_LOG_LOG.createBlockBuilder(null, length);
  for (int i = start; i < start + length; i++) {
    HyperLogLog hll = HyperLogLog.newInstance(NUMBER_OF_BUCKETS);
    hll.add(i);
    hll.makeDense();
    HYPER_LOG_LOG.writeSlice(blockBuilder, hll.serialize());
  }
  return new Block[] {blockBuilder.build()};
}

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

@Override
public Block[] getSequenceBlocks(int start, int length)
{
  BlockBuilder blockBuilder = HYPER_LOG_LOG.createBlockBuilder(null, length);
  for (int i = start; i < start + length; i++) {
    HyperLogLog hll = HyperLogLog.newInstance(NUMBER_OF_BUCKETS);
    hll.add(i);
    hll.makeDense();
    HYPER_LOG_LOG.writeSlice(blockBuilder, hll.serialize());
  }
  return new Block[] {blockBuilder.build()};
}

相关文章