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);
}
}
}
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);
}
}
}
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);
}
}
}
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);
}
Aggregations