mirror of
http://github.com/valkey-io/valkey
synced 2024-11-22 09:17:20 +00:00
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.
This commit is contained in:
parent
77362b9027
commit
30b324698f
@ -136,10 +136,9 @@ start_server {tags {"hll"}} {
|
||||
r pfcount hll
|
||||
} {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
|
||||
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"
|
||||
@ -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} {
|
||||
r del hll
|
||||
r pfadd hll 1 2 3
|
||||
|
Loading…
Reference in New Issue
Block a user