Add encoding-specific APPROX and APPROX+LIMIT tests for SUNIONCARD

The existing APPROX tests only used string-element sets (hashtable
encoding). The HLL path has a distinct code branch for intset-encoded
sets where elements are converted via ll2string() before being fed to
hllAdd(). Add tests inside the encoding foreach loop to exercise both
regular (listpack/hashtable) and intset encodings for APPROX and
APPROX+LIMIT.
This commit is contained in:
Hristo Staykov 2026-03-16 12:32:45 +02:00
parent 1e8c9ea8fc
commit 3c3d49f3b2

View file

@ -439,6 +439,18 @@ foreach type {single multiple single_multiple} {
assert_equal $expected [r sunioncard 4 nokey1{t} set1{t} set2{t} nokey2{t}]
}
test "SUNIONCARD APPROX with two sets - $type" {
set exact [r sunioncard 2 set1{t} set2{t}]
set approx [r sunioncard 2 set1{t} set2{t} APPROX]
set error_pct [expr {abs($approx - $exact) * 100.0 / $exact}]
assert {$error_pct < 5.0}
}
test "SUNIONCARD APPROX with LIMIT - $type" {
assert_equal 0 [r sunioncard 2 set1{t} set2{t} APPROX LIMIT 0]
assert_equal 10 [r sunioncard 2 set1{t} set2{t} APPROX LIMIT 10]
}
test "SUNIONSTORE with two sets - $type" {
r sunionstore setres{t} set1{t} set2{t}
assert_encoding $bigenc setres{t}