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

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

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

HyperLogLog.mergeWith介绍

暂无

代码示例

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

private static void merge(@AggregationState HyperLogLogState state, HyperLogLog input)
{
  HyperLogLog previous = state.getHyperLogLog();
  if (previous == null) {
    state.setHyperLogLog(input);
    state.addMemoryUsage(input.estimatedInMemorySize());
  }
  else {
    state.addMemoryUsage(-previous.estimatedInMemorySize());
    previous.mergeWith(input);
    state.addMemoryUsage(previous.estimatedInMemorySize());
  }
}

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

public void mergeWith(SetDigest other)
{
  hll.mergeWith(other.hll);
  LongBidirectionalIterator iterator = other.minhash.keySet().iterator();
  while (iterator.hasNext()) {
    long key = iterator.nextLong();
    int count = minhash.get(key) + other.minhash.get(key);
    minhash.put(key, Shorts.saturatedCast(count));
  }
  while (minhash.size() > maxHashes) {
    minhash.remove(minhash.lastLongKey());
  }
}

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

@CombineFunction
public static void combineState(@AggregationState HyperLogLogState state, @AggregationState HyperLogLogState otherState)
{
  HyperLogLog input = otherState.getHyperLogLog();
  HyperLogLog previous = state.getHyperLogLog();
  if (previous == null) {
    state.setHyperLogLog(input);
    state.addMemoryUsage(input.estimatedInMemorySize());
  }
  else {
    state.addMemoryUsage(-previous.estimatedInMemorySize());
    previous.mergeWith(input);
    state.addMemoryUsage(previous.estimatedInMemorySize());
  }
}

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

@CombineFunction
public static void combineState(@AggregationState HyperLogLogState state, @AggregationState HyperLogLogState otherState)
{
  HyperLogLog input = otherState.getHyperLogLog();
  HyperLogLog previous = state.getHyperLogLog();
  if (previous == null) {
    state.setHyperLogLog(input);
    state.addMemoryUsage(input.estimatedInMemorySize());
  }
  else {
    state.addMemoryUsage(-previous.estimatedInMemorySize());
    previous.mergeWith(input);
    state.addMemoryUsage(previous.estimatedInMemorySize());
  }
}

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

private static void merge(@AggregationState HyperLogLogState state, HyperLogLog input)
{
  HyperLogLog previous = state.getHyperLogLog();
  if (previous == null) {
    state.setHyperLogLog(input);
    state.addMemoryUsage(input.estimatedInMemorySize());
  }
  else {
    state.addMemoryUsage(-previous.estimatedInMemorySize());
    previous.mergeWith(input);
    state.addMemoryUsage(previous.estimatedInMemorySize());
  }
}

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

private static void merge(@AggregationState HyperLogLogState state, HyperLogLog input)
{
  HyperLogLog previous = state.getHyperLogLog();
  if (previous == null) {
    state.setHyperLogLog(input);
    state.addMemoryUsage(input.estimatedInMemorySize());
  }
  else {
    state.addMemoryUsage(-previous.estimatedInMemorySize());
    previous.mergeWith(input);
    state.addMemoryUsage(previous.estimatedInMemorySize());
  }
}

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

@CombineFunction
public static void combineState(HyperLogLogState state, HyperLogLogState otherState)
{
  HyperLogLog input = otherState.getHyperLogLog();
  HyperLogLog previous = state.getHyperLogLog();
  if (previous == null) {
    state.setHyperLogLog(input);
    state.addMemoryUsage(input.estimatedInMemorySize());
  }
  else {
    state.addMemoryUsage(-previous.estimatedInMemorySize());
    previous.mergeWith(input);
    state.addMemoryUsage(previous.estimatedInMemorySize());
  }
}

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

@CombineFunction
public static void combineState(HyperLogLogState state, HyperLogLogState otherState)
{
  HyperLogLog input = otherState.getHyperLogLog();
  HyperLogLog previous = state.getHyperLogLog();
  if (previous == null) {
    state.setHyperLogLog(input);
    state.addMemoryUsage(input.estimatedInMemorySize());
  }
  else {
    state.addMemoryUsage(-previous.estimatedInMemorySize());
    previous.mergeWith(input);
    state.addMemoryUsage(previous.estimatedInMemorySize());
  }
}

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

public void mergeWith(SetDigest other)
{
  hll.mergeWith(other.hll);
  LongBidirectionalIterator iterator = other.minhash.keySet().iterator();
  while (iterator.hasNext()) {
    long key = iterator.nextLong();
    int count = minhash.get(key) + other.minhash.get(key);
    minhash.put(key, Shorts.saturatedCast(count));
  }
  while (minhash.size() > maxHashes) {
    minhash.remove(minhash.lastLongKey());
  }
}

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

public void mergeWith(SetDigest other)
{
  hll.mergeWith(other.hll);
  LongBidirectionalIterator iterator = other.minhash.keySet().iterator();
  while (iterator.hasNext()) {
    long key = iterator.nextLong();
    int count = minhash.get(key) + other.minhash.get(key);
    minhash.put(key, Shorts.saturatedCast(count));
  }
  while (minhash.size() > maxHashes) {
    minhash.remove(minhash.lastLongKey());
  }
}

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

@CombineFunction
public static void combineState(@AggregationState HyperLogLogState state, @AggregationState HyperLogLogState otherState)
{
  HyperLogLog input = otherState.getHyperLogLog();
  HyperLogLog previous = state.getHyperLogLog();
  if (previous == null) {
    state.setHyperLogLog(input);
    state.addMemoryUsage(input.estimatedInMemorySize());
  }
  else {
    state.addMemoryUsage(-previous.estimatedInMemorySize());
    previous.mergeWith(input);
    state.addMemoryUsage(previous.estimatedInMemorySize());
  }
}

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

@CombineFunction
public static void combineState(@AggregationState HyperLogLogState state, @AggregationState HyperLogLogState otherState)
{
  HyperLogLog input = otherState.getHyperLogLog();
  HyperLogLog previous = state.getHyperLogLog();
  if (previous == null) {
    state.setHyperLogLog(input);
    state.addMemoryUsage(input.estimatedInMemorySize());
  }
  else {
    state.addMemoryUsage(-previous.estimatedInMemorySize());
    previous.mergeWith(input);
    state.addMemoryUsage(previous.estimatedInMemorySize());
  }
}

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

@CombineFunction
public static void combineState(@AggregationState HyperLogLogState state, @AggregationState HyperLogLogState otherState)
{
  HyperLogLog input = otherState.getHyperLogLog();
  HyperLogLog previous = state.getHyperLogLog();
  if (previous == null) {
    state.setHyperLogLog(input);
    state.addMemoryUsage(input.estimatedInMemorySize());
  }
  else {
    state.addMemoryUsage(-previous.estimatedInMemorySize());
    previous.mergeWith(input);
    state.addMemoryUsage(previous.estimatedInMemorySize());
  }
}

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

@CombineFunction
public static void combineState(@AggregationState HyperLogLogState state, @AggregationState HyperLogLogState otherState)
{
  HyperLogLog input = otherState.getHyperLogLog();
  HyperLogLog previous = state.getHyperLogLog();
  if (previous == null) {
    state.setHyperLogLog(input);
    state.addMemoryUsage(input.estimatedInMemorySize());
  }
  else {
    state.addMemoryUsage(-previous.estimatedInMemorySize());
    previous.mergeWith(input);
    state.addMemoryUsage(previous.estimatedInMemorySize());
  }
}

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

@InputFunction
@IntermediateInputFunction
public static void merge(HyperLogLogState state, @SqlType(StandardTypes.HYPER_LOG_LOG) Slice value)
{
  HyperLogLog input = HyperLogLog.newInstance(value);
  HyperLogLog previous = state.getHyperLogLog();
  if (previous == null) {
    state.setHyperLogLog(input);
    state.addMemoryUsage(input.estimatedInMemorySize());
  }
  else {
    state.addMemoryUsage(-previous.estimatedInMemorySize());
    previous.mergeWith(input);
    state.addMemoryUsage(previous.estimatedInMemorySize());
  }
}

代码示例来源: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());
}

相关文章