本文整理汇总了Java中com.clearspring.analytics.stream.cardinality.HyperLogLog.addAll方法的典型用法代码示例。如果您正苦于以下问题:Java HyperLogLog.addAll方法的具体用法?Java HyperLogLog.addAll怎么用?Java HyperLogLog.addAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.clearspring.analytics.stream.cardinality.HyperLogLog
的用法示例。
在下文中一共展示了HyperLogLog.addAll方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: count
import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的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();
}
示例2: combine
import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的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;
}
示例3: combineTwoValues
import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的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;
}
示例4: reduce
import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的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();
}
示例5: main
import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的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());
}
示例6: mergeTest
import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的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());
}
示例7: merge
import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的package包/类
@Nonnull
@Override
public HyperLogLog merge(@Nonnull HyperLogLog intermediateResult1, @Nonnull HyperLogLog intermediateResult2) {
try {
intermediateResult1.addAll(intermediateResult2);
} catch (CardinalityMergeException e) {
throw new RuntimeException("Caught exception while merging HyperLogLog.", e);
}
return intermediateResult1;
}
示例8: clone
import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的package包/类
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);
}
}
示例9: mergeHLLResultsToFirstInList
import com.clearspring.analytics.stream.cardinality.HyperLogLog; //导入方法依赖的package包/类
/**
* 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;
}