提交 9cd1cd66 编写于 作者: A antirez

Test: improve PFCOUNT with multiple keys testing.

An user raised a question about a given behavior of PFCOUNT. Added a
test to show the behavior (union) is correct when most of the items are
in common.
上级 db1df454
...@@ -136,10 +136,9 @@ start_server {tags {"hll"}} { ...@@ -136,10 +136,9 @@ start_server {tags {"hll"}} {
r pfcount hll r pfcount hll
} {5} } {5}
test {PFCOUNT multiple-keys merge returns cardinality of union} { test {PFCOUNT multiple-keys merge returns cardinality of union #1} {
r del hll1 hll2 hll3 r del hll1 hll2 hll3
for {set x 1} {$x < 10000} {incr x} { for {set x 1} {$x < 10000} {incr x} {
# Force dense representation of hll2
r pfadd hll1 "foo-$x" r pfadd hll1 "foo-$x"
r pfadd hll2 "bar-$x" r pfadd hll2 "bar-$x"
r pfadd hll3 "zap-$x" r pfadd hll3 "zap-$x"
...@@ -151,6 +150,22 @@ start_server {tags {"hll"}} { ...@@ -151,6 +150,22 @@ start_server {tags {"hll"}} {
} }
} }
test {PFCOUNT multiple-keys merge returns cardinality of union #2} {
r del hll1 hll2 hll3
set elements {}
for {set x 1} {$x < 10000} {incr x} {
for {set j 1} {$j <= 3} {incr j} {
set rint [randomInt 20000]
r pfadd hll$j $rint
lappend elements $rint
}
}
set realcard [llength [lsort -unique $elements]]
set card [r pfcount hll1 hll2 hll3]
set err [expr {abs($card-$realcard)}]
assert {$err < (double($card)/100)*5}
}
test {PFDEBUG GETREG returns the HyperLogLog raw registers} { test {PFDEBUG GETREG returns the HyperLogLog raw registers} {
r del hll r del hll
r pfadd hll 1 2 3 r pfadd hll 1 2 3
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册