Search in sources :

Example 6 with CardinalityMergeException

use of com.clearspring.analytics.stream.cardinality.CardinalityMergeException in project pinot by linkedin.

the class FastHLLAggregationFunction method aggregateGroupBySV.

@Override
public void aggregateGroupBySV(int length, @Nonnull int[] groupKeyArray, @Nonnull GroupByResultHolder groupByResultHolder, @Nonnull BlockValSet... blockValSets) {
    String[] valueArray = blockValSets[0].getStringValuesSV();
    for (int i = 0; i < length; i++) {
        int groupKey = groupKeyArray[i];
        HyperLogLog hyperLogLog = groupByResultHolder.getResult(groupKey);
        if (hyperLogLog == null) {
            hyperLogLog = new HyperLogLog(_log2m);
            groupByResultHolder.setValueForKey(groupKey, hyperLogLog);
        }
        try {
            hyperLogLog.addAll(HllUtil.convertStringToHll(valueArray[i]));
        } catch (CardinalityMergeException e) {
            throw new RuntimeException("Caught exception while aggregating HyperLogLog.", e);
        }
    }
}
Also used : HyperLogLog(com.clearspring.analytics.stream.cardinality.HyperLogLog) CardinalityMergeException(com.clearspring.analytics.stream.cardinality.CardinalityMergeException)

Example 7 with CardinalityMergeException

use of com.clearspring.analytics.stream.cardinality.CardinalityMergeException in project pinot by linkedin.

the class FastHLLMVAggregationFunction method aggregateGroupBySV.

@Override
public void aggregateGroupBySV(int length, @Nonnull int[] groupKeyArray, @Nonnull GroupByResultHolder groupByResultHolder, @Nonnull BlockValSet... blockValSets) {
    String[][] valuesArray = blockValSets[0].getStringValuesMV();
    for (int i = 0; i < length; i++) {
        int groupKey = groupKeyArray[i];
        HyperLogLog hyperLogLog = groupByResultHolder.getResult(groupKey);
        if (hyperLogLog == null) {
            hyperLogLog = new HyperLogLog(_log2m);
            groupByResultHolder.setValueForKey(groupKey, hyperLogLog);
        }
        try {
            for (String value : valuesArray[i]) {
                hyperLogLog.addAll(HllUtil.convertStringToHll(value));
            }
        } catch (CardinalityMergeException e) {
            throw new RuntimeException("Caught exception while aggregating HyperLogLog.", e);
        }
    }
}
Also used : HyperLogLog(com.clearspring.analytics.stream.cardinality.HyperLogLog) CardinalityMergeException(com.clearspring.analytics.stream.cardinality.CardinalityMergeException)

Example 8 with CardinalityMergeException

use of com.clearspring.analytics.stream.cardinality.CardinalityMergeException in project pinot by linkedin.

the class FastHLLMVAggregationFunction method aggregate.

@Override
public void aggregate(int length, @Nonnull AggregationResultHolder aggregationResultHolder, @Nonnull BlockValSet... blockValSets) {
    String[][] valuesArray = blockValSets[0].getStringValuesMV();
    HyperLogLog hyperLogLog = aggregationResultHolder.getResult();
    if (hyperLogLog == null) {
        hyperLogLog = new HyperLogLog(_log2m);
        aggregationResultHolder.setValue(hyperLogLog);
    }
    for (int i = 0; i < length; i++) {
        try {
            for (String value : valuesArray[i]) {
                hyperLogLog.addAll(HllUtil.convertStringToHll(value));
            }
        } catch (CardinalityMergeException e) {
            throw new RuntimeException("Caught exception while aggregating HyperLogLog.", e);
        }
    }
}
Also used : HyperLogLog(com.clearspring.analytics.stream.cardinality.HyperLogLog) CardinalityMergeException(com.clearspring.analytics.stream.cardinality.CardinalityMergeException)

Example 9 with CardinalityMergeException

use of com.clearspring.analytics.stream.cardinality.CardinalityMergeException in project metron by apache.

the class HyperLogLogPlus method merge.

/**
 * 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);
}
Also used : ICardinality(com.clearspring.analytics.stream.cardinality.ICardinality) CardinalityMergeException(com.clearspring.analytics.stream.cardinality.CardinalityMergeException)

Aggregations

CardinalityMergeException (com.clearspring.analytics.stream.cardinality.CardinalityMergeException)9 HyperLogLog (com.clearspring.analytics.stream.cardinality.HyperLogLog)7 ICardinality (com.clearspring.analytics.stream.cardinality.ICardinality)2