summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-04-18 12:36:33 +0200
committerantirez <antirez@gmail.com>2014-04-18 16:16:20 +0200
commit115782b1d7ef48fb113ebef64795d2c551fa16ab (patch)
tree1cfe8f1e675135ba7cd946cd064db4d237f28007
parent2cd20d3c4c68e34672ce625f7bd172df7b4455d7 (diff)
downloadredis-115782b1d7ef48fb113ebef64795d2c551fa16ab.tar.gz
PFCOUNT multi-key test added.
-rw-r--r--tests/unit/hyperloglog.tcl15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/unit/hyperloglog.tcl b/tests/unit/hyperloglog.tcl
index 47e3db2a1..af86e68e5 100644
--- a/tests/unit/hyperloglog.tcl
+++ b/tests/unit/hyperloglog.tcl
@@ -136,6 +136,21 @@ start_server {tags {"hll"}} {
r pfcount hll
} {5}
+ test {PFCOUNT multiple-keys merge returns cardinality of union} {
+ r del hll1 hll2 hll3
+ for {set x 1} {$x < 10000} {incr x} {
+ # Force dense representation of hll2
+ r pfadd hll1 "foo-$x"
+ r pfadd hll2 "bar-$x"
+ r pfadd hll3 "zap-$x"
+
+ set card [r pfcount hll1 hll2 hll3]
+ set realcard [expr {$x*3}]
+ set err [expr {abs($card-$realcard)}]
+ assert {$err < (double($card)/100)*5}
+ }
+ }
+
test {PFDEBUG GETREG returns the HyperLogLog raw registers} {
r del hll
r pfadd hll 1 2 3