提交 c273298a 编写于 作者: X Xavier Léauté

don't discard current maxOverflow if offset is high enough

上级 d96d8225
......@@ -299,8 +299,12 @@ public abstract class HyperLogLogCollector implements Comparable<HyperLogLogColl
if (positionOf1 <= registerOffset) {
return;
} else if (positionOf1 > (registerOffset + range)) {
byte currMax = getMaxOverflowValue();
final byte currMax = getMaxOverflowValue();
if (positionOf1 > currMax) {
if(currMax <= (registerOffset + range)) {
// this could be optimized by having an add without sanity checks
add(getMaxOverflowRegister(), currMax);
}
setMaxOverflowValue(positionOf1);
setMaxOverflowRegister(bucket);
}
......
......@@ -844,29 +844,16 @@ public class HyperLogLogCollectorTest
);
Collection<List<HyperLogLogCollector>> permutations = Collections2.permutations(collectors);
Collection<List<HyperLogLogCollector>> selectPermutations = Lists.<List<HyperLogLogCollector>>newArrayList(
Iterables.get(
permutations,
3
)
);
selectPermutations = permutations;
// ArrayList<List<HyperLogLogCollector>> selectPermutations = Lists.<List<HyperLogLogCollector>>newArrayList(
// Iterables.get(
// permutations,
// 1
// )
// );
for(List<HyperLogLogCollector> permutation : selectPermutations) {
for(List<HyperLogLogCollector> permutation : permutations) {
HyperLogLogCollector collector = HyperLogLogCollector.makeLatestCollector();
for (HyperLogLogCollector foldee : permutation) {
collector.fold(foldee);
}
System.err.println(collector.estimateCardinality());
Assert.assertEquals(29, collector.getMaxOverflowValue());
Assert.assertEquals(366, collector.getMaxOverflowRegister());
Assert.assertEquals(1.0429189446653817E7, collector.estimateCardinality(), 1);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册