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


Java CardinalityMergeException类代码示例

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


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

示例1: merge

import com.clearspring.analytics.stream.cardinality.CardinalityMergeException; //导入依赖的package包/类
@Override
public ICardinality merge(ICardinality... estimators) throws CardinalityMergeException {
    HyperLogLog merged = new HyperLogLog(log2m, new RegisterSet(this.registerSet.count));
    merged.addAll(this);

    if (estimators == null) {
        return merged;
    }

    for (ICardinality estimator : estimators) {
        if (!(estimator instanceof HyperLogLog)) {
            throw new HyperLogLogMergeException("Cannot merge estimators of different class");
        }
        HyperLogLog hll = (HyperLogLog) estimator;
        merged.addAll(hll);
    }

    return merged;
}
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:20,代码来源:HyperLogLog.java

示例2: count

import com.clearspring.analytics.stream.cardinality.CardinalityMergeException; //导入依赖的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

示例3: count

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

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

    HyperLogLogPlus 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,代码来源:ReduceHyperLogLogPlusCardinalityBucket.java

示例4: combine

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

示例5: combineTwoValues

import com.clearspring.analytics.stream.cardinality.CardinalityMergeException; //导入依赖的package包/类
@Override
public HyperLogLog combineTwoValues(HyperLogLog aggregationResult0, HyperLogLog aggregationResult1) {
  if (aggregationResult0 == null) {
    return aggregationResult1;
  }
  if (aggregationResult1 == null) {
    return aggregationResult0;
  }
  try {
    aggregationResult0.addAll(aggregationResult1);
  } catch (CardinalityMergeException e) {
    LOGGER.error("Caught exception while merging Cardinality using HyperLogLog", e);
    Utils.rethrowException(e);
  }
  return aggregationResult0;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:17,代码来源:DistinctCountHLLAggregationFunction.java

示例6: reduce

import com.clearspring.analytics.stream.cardinality.CardinalityMergeException; //导入依赖的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

示例7: getLeafCollector

import com.clearspring.analytics.stream.cardinality.CardinalityMergeException; //导入依赖的package包/类
@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx,
                                            final LeafBucketCollector sub) throws IOException {
    if (valuesSource == null) {
        return LeafBucketCollector.NO_OP_COLLECTOR;
    }
    final BigArrays bigArrays = context.bigArrays();
    final SortedBinaryDocValues values = valuesSource.bytesValues(ctx);
    return new LeafBucketCollectorBase(sub, values) {
        @Override
        public void collect(int doc, long bucket) throws IOException {
            hyperLogLogPlusPlusObjectArray = bigArrays.grow(hyperLogLogPlusPlusObjectArray, bucket + 1);
            values.setDocument(doc);
            final int valuesCount = values.count();
            HyperLogLogPlus hll;
            for (int i = 0; i < valuesCount; i++) {
                hll = deserializeHyperLogLogPlus(values.valueAt(i));
                    HyperLogLogPlus current = hyperLogLogPlusPlusObjectArray.get(bucket);
                    if (current == null) {
                        hyperLogLogPlusPlusObjectArray.set(bucket, hll);
                    } else {
                        try {
                            hyperLogLogPlusPlusObjectArray.set(bucket, (HyperLogLogPlus) hll.merge(current));
                        } catch (CardinalityMergeException cme) {
                            throw new ElasticsearchGenerationException("Failed to merge HyperLogLogPlus structures  ", cme);
                        }
                    }

            }
        }
    };
}
 
开发者ID:bazaarvoice,项目名称:elasticsearch-hyperloglog,代码行数:33,代码来源:HyperUniqueSumAggregator.java

示例8: main

import com.clearspring.analytics.stream.cardinality.CardinalityMergeException; //导入依赖的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

示例9: combine

import com.clearspring.analytics.stream.cardinality.CardinalityMergeException; //导入依赖的package包/类
@Override
public <U extends IAggregableReduceOp<T, Writable>> void combine(U acc) {
    if (acc instanceof AggregableCountUnique) {
        try {
            hll.addAll(((AggregableCountUnique<T>) acc).getHll());
        } catch (CardinalityMergeException e) {
            throw new RuntimeException(e);
        }
    } else
        throw new UnsupportedOperationException("Tried to combine() incompatible " + acc.getClass().getName()
                        + " operator where " + this.getClass().getName() + " expected");
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:13,代码来源:AggregatorImpls.java

示例10: add

import com.clearspring.analytics.stream.cardinality.CardinalityMergeException; //导入依赖的package包/类
public StringQuality add(StringQuality other) throws CardinalityMergeException {
    hll.addAll(other.hll);
    return new StringQuality(countValid + other.countValid, countInvalid + other.countInvalid,
                    countMissing + other.countMissing, countTotal + other.countTotal,
                    countEmptyString + other.countEmptyString, countAlphabetic + other.countAlphabetic,
                    countNumerical + other.countNumerical, countWordCharacter + other.countWordCharacter,
                    countWhitespace + other.countWhitespace, hll);
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:9,代码来源:StringQuality.java

示例11: mergeAccumulators

import com.clearspring.analytics.stream.cardinality.CardinalityMergeException; //导入依赖的package包/类
@Override
public HyperLogLogPlus mergeAccumulators(Iterable<HyperLogLogPlus> accumulators) {
  HyperLogLogPlus mergedAccum = createAccumulator();
  for (HyperLogLogPlus accum : accumulators) {
    try {
      mergedAccum.addAll(accum);
    } catch (CardinalityMergeException e) {
      // Should never happen because only HyperLogLogPlus accumulators are instantiated.
      throw new IllegalStateException(
          "The accumulators cannot be merged: " + e.getMessage(), e);
    }
  }
  return mergedAccum;
}
 
开发者ID:apache,项目名称:beam,代码行数:15,代码来源:ApproximateDistinct.java

示例12: mergeCardinalities

import com.clearspring.analytics.stream.cardinality.CardinalityMergeException; //导入依赖的package包/类
private static ICardinality mergeCardinalities(Collection<ICardinality> cardinalities)
{
    ICardinality base = new HyperLogLogPlus(13, 25); // see MetadataCollector.cardinality
    try
    {
        base = base.merge(cardinalities.toArray(new ICardinality[cardinalities.size()]));
    }
    catch (CardinalityMergeException e)
    {
        logger.warn("Could not merge cardinalities", e);
    }
    return base;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:14,代码来源:SSTableReader.java

示例13: _apply

import com.clearspring.analytics.stream.cardinality.CardinalityMergeException; //导入依赖的package包/类
@Override
protected HyperLogLogPlus _apply(final HyperLogLogPlus a, final HyperLogLogPlus b) {
    try {
        a.addAll(b);
    } catch (final CardinalityMergeException exception) {
        throw new RuntimeException("An Exception occurred when trying to aggregate the HyperLogLogPlus objects", exception);
    }
    return a;
}
 
开发者ID:gchq,项目名称:Gaffer,代码行数:10,代码来源:HyperLogLogPlusAggregator.java

示例14: merge

import com.clearspring.analytics.stream.cardinality.CardinalityMergeException; //导入依赖的package包/类
/**
 * Merges hllp sets and returns new merged set. Does not modify original sets.
 *
 * @param estimators hllp sets to merge
 * @return New merged hllp set
 */
public HyperLogLogPlus merge(List<HyperLogLogPlus> estimators) {
  List<com.clearspring.analytics.stream.cardinality.HyperLogLogPlus> converted = Lists.transform(estimators, s -> s.hllp);
  ICardinality merged = null;
  try {
    merged = hllp.merge(converted.toArray(new com.clearspring.analytics.stream.cardinality.HyperLogLogPlus[]{}));
  } catch (CardinalityMergeException e) {
    throw new IllegalArgumentException("Unable to merge estimators", e);
  }
  return new HyperLogLogPlus(p, sp, (com.clearspring.analytics.stream.cardinality.HyperLogLogPlus) merged);
}
 
开发者ID:apache,项目名称:metron,代码行数:17,代码来源:HyperLogLogPlus.java

示例15: mergeTest

import com.clearspring.analytics.stream.cardinality.CardinalityMergeException; //导入依赖的package包/类
@Test
public void mergeTest() throws CardinalityMergeException {

    SiteSession siteSessionA = new SiteSession("user1", 100, "testURL-A");
    siteSessionA.update(100, "testURL-common");
    SiteSession siteSessionB = new SiteSession("user1", 100, "testURL-B");
    siteSessionB.update(100, "testURL-common");

    HyperLogLog hll = siteSessionA.getHyperLogLog();
    hll.addAll(siteSessionB.getHyperLogLog());

    assertEquals(3, hll.cardinality());
}
 
开发者ID:jhalliday,项目名称:csc8101,代码行数:14,代码来源:SiteSessionTest.java


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