本文整理汇总了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;
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
}
}
}
};
}
示例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());
}
示例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");
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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());
}