本文整理了Java中com.clearspring.analytics.stream.cardinality.HyperLogLog.addAll()
方法的一些代码示例,展示了HyperLogLog.addAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HyperLogLog.addAll()
方法的具体详情如下:
包路径:com.clearspring.analytics.stream.cardinality.HyperLogLog
类名称:HyperLogLog
方法名:addAll
[英]Add all the elements of the other set to this set.
This operation does not imply a loss of precision.
[中]将其他集合的所有元素添加到此集合。
此操作并不意味着精度损失。
代码示例来源:origin: apache/incubator-pinot
@Override
public HyperLogLog applyAggregatedValue(HyperLogLog value, HyperLogLog aggregatedValue) {
try {
value.addAll(aggregatedValue);
return value;
} catch (CardinalityMergeException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: apache/incubator-pinot
@Nonnull
@Override
public HyperLogLog merge(@Nonnull HyperLogLog intermediateResult1, @Nonnull HyperLogLog intermediateResult2) {
try {
intermediateResult1.addAll(intermediateResult2);
} catch (Exception e) {
throw new RuntimeException("Caught exception while merging HyperLogLog", e);
}
return intermediateResult1;
}
代码示例来源:origin: apache/incubator-pinot
@Nonnull
@Override
public HyperLogLog merge(@Nonnull HyperLogLog intermediateResult1, @Nonnull HyperLogLog intermediateResult2) {
try {
intermediateResult1.addAll(intermediateResult2);
} catch (Exception e) {
throw new RuntimeException("Caught exception while merging HyperLogLog", e);
}
return intermediateResult1;
}
代码示例来源:origin: apache/incubator-pinot
/**
* Helper method to set HyperLogLog value for a groupKey into the result holder.
*
* @param groupByResultHolder Result holder
* @param groupKey Group-key for which to set the value
* @param value HyperLogLog value for the group key
*/
private static void setValueForGroupKey(@Nonnull GroupByResultHolder groupByResultHolder, int groupKey,
HyperLogLog value)
throws CardinalityMergeException {
HyperLogLog hyperLogLog = getHyperLogLog(groupByResultHolder, groupKey);
hyperLogLog.addAll(value);
}
代码示例来源:origin: apache/incubator-pinot
public static HyperLogLog clone(HyperLogLog hll, int log2m) {
try {
HyperLogLog ret = new HyperLogLog(log2m);
ret.addAll(hll);
return ret;
} catch (CardinalityMergeException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: apache/incubator-pinot
/**
* Merge all HLLs in list to the first HLL in the list, the list must contain at least one element
* @param resultList
* @return
*/
public static HyperLogLog mergeHLLResultsToFirstInList(List<HyperLogLog> resultList) {
HyperLogLog hllResult = resultList.get(0);
for (int i = 1; i < resultList.size(); ++i) {
try {
hllResult.addAll(resultList.get(i));
} catch (CardinalityMergeException e) {
Utils.rethrowException(e);
}
}
return hllResult;
}
代码示例来源:origin: apache/incubator-pinot
@Override
public void aggregateGroupBySV(int length, @Nonnull int[] groupKeyArray,
@Nonnull GroupByResultHolder groupByResultHolder, @Nonnull BlockValSet... blockValSets) {
String[] valueArray = blockValSets[0].getStringValuesSV();
try {
for (int i = 0; i < length; i++) {
HyperLogLog hyperLogLog = getHyperLogLog(groupByResultHolder, groupKeyArray[i]);
hyperLogLog.addAll(HllUtil.convertStringToHll(valueArray[i]));
}
} catch (Exception e) {
throw new RuntimeException("Caught exception while aggregating HyperLogLog", e);
}
}
代码示例来源:origin: apache/incubator-pinot
@Override
public void aggregateGroupByMV(int length, @Nonnull int[][] groupKeysArray,
@Nonnull GroupByResultHolder groupByResultHolder, @Nonnull BlockValSet... blockValSets) {
String[] valueArray = blockValSets[0].getStringValuesSV();
try {
for (int i = 0; i < length; i++) {
HyperLogLog value = HllUtil.convertStringToHll(valueArray[i]);
for (int groupKey : groupKeysArray[i]) {
HyperLogLog hyperLogLog = getHyperLogLog(groupByResultHolder, groupKey);
hyperLogLog.addAll(value);
}
}
} catch (Exception e) {
throw new RuntimeException("Caught exception while aggregating HyperLogLog", e);
}
}
代码示例来源:origin: apache/incubator-pinot
@Override
public HyperLogLog applyRawValue(HyperLogLog value, Object rawValue) {
if (rawValue instanceof byte[]) {
try {
value.addAll(deserializeAggregatedValue((byte[]) rawValue));
} catch (CardinalityMergeException e) {
throw new RuntimeException(e);
}
} else {
value.offer(rawValue);
}
return value;
}
代码示例来源:origin: apache/incubator-pinot
@Override
public void aggregate(int length, @Nonnull AggregationResultHolder aggregationResultHolder,
@Nonnull BlockValSet... blockValSets) {
String[] valueArray = blockValSets[0].getStringValuesSV();
HyperLogLog hyperLogLog = getHyperLogLog(aggregationResultHolder);
try {
for (int i = 0; i < length; i++) {
hyperLogLog.addAll(HllUtil.convertStringToHll(valueArray[i]));
}
} catch (Exception e) {
throw new RuntimeException("Caught exception while aggregating HyperLogLog", e);
}
}
代码示例来源:origin: addthis/stream-lib
@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;
}
代码示例来源:origin: apache/incubator-pinot
public void aggregate(MetricBuffer buffer) {
int numValues = _values.length;
for (int i = 0; i < numValues; i++) {
MetricFieldSpec metricFieldSpec = _metricFieldSpecs.get(i);
switch (metricFieldSpec.getDataType()) {
case INT:
_values[i] = (Integer) _values[i] + (Integer) buffer._values[i];
break;
case LONG:
_values[i] = (Long) _values[i] + (Long) buffer._values[i];
break;
case FLOAT:
_values[i] = (Float) _values[i] + (Float) buffer._values[i];
break;
case DOUBLE:
_values[i] = (Double) _values[i] + (Double) buffer._values[i];
break;
case STRING:
assert metricFieldSpec.getDerivedMetricType() == DerivedMetricType.HLL;
try {
((HyperLogLog) _values[i]).addAll((HyperLogLog) buffer._values[i]);
} catch (CardinalityMergeException e) {
throw new RuntimeException(e);
}
break;
default:
throw new IllegalStateException();
}
}
}
代码示例来源:origin: apache/incubator-pinot
try {
for (int i = 0; i < length; i++) {
hyperLogLog.addAll(ObjectSerDeUtils.HYPER_LOG_LOG_SER_DE.deserialize(bytesValues[i]));
代码示例来源:origin: apache/incubator-pinot
int dictId = _metricValIterators[i].nextIntVal();
HyperLogLog hyperLogLog = hyperLogLogs.get(i);
hyperLogLog.addAll(HllUtil.convertStringToHll(_metricDictionaries[i].getStringValue(dictId)));
hyperLogLogs.set(i, hyperLogLog);
代码示例来源:origin: com.github.ddth/ddth-simplehll-core
/**
* {@inheritDoc}
*/
@Override
public IHLL merge(IHLL hll) {
if (this.hll == null) {
throw new IllegalStateException();
}
if (!(hll instanceof AtsHLL)) {
throw new IllegalArgumentException("Argument is not of type [" + AtsHLL.class + "]!");
}
HyperLogLog other = ((AtsHLL) hll).hll;
if (other == null) {
throw new IllegalArgumentException("The supplied object has not been initialized!");
}
try {
this.hll.addAll(other);
} catch (CardinalityMergeException e) {
throw new RuntimeException(e);
}
return this;
}
代码示例来源:origin: com.addthis/stream-lib
@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;
}
内容来源于网络,如有侵权,请联系作者删除!