if {$encoding == "ziplist"} {
r config set zset-max-ziplist-entries 128
r config set zset-max-ziplist-value 64
- } elseif {$encoding == "raw"} {
+ } elseif {$encoding == "skiplist"} {
r config set zset-max-ziplist-entries 0
r config set zset-max-ziplist-value 0
} else {
assert_equal 0 [r zcard zdoesntexist]
}
+ test "ZREM removes key after last element is removed" {
+ r del ztmp
+ r zadd ztmp 10 x
+ r zadd ztmp 20 y
+
+ assert_equal 1 [r exists ztmp]
+ assert_equal 0 [r zrem ztmp z]
+ assert_equal 1 [r zrem ztmp y]
+ assert_equal 1 [r zrem ztmp x]
+ assert_equal 0 [r exists ztmp]
+ }
+
test "ZRANGE basics - $encoding" {
r del ztmp
r zadd ztmp 1 a
test "ZREMRANGEBYSCORE basics" {
proc remrangebyscore {min max} {
create_zset zset {1 a 2 b 3 c 4 d 5 e}
+ assert_equal 1 [r exists zset]
r zremrangebyscore zset $min $max
}
# exclusive min and max
assert_equal 3 [remrangebyscore (1 (5]
assert_equal {a e} [r zrange zset 0 -1]
+
+ # destroy when empty
+ assert_equal 5 [remrangebyscore 1 5]
+ assert_equal 0 [r exists zset]
}
test "ZREMRANGEBYSCORE with non-value min or max" {
test "ZREMRANGEBYRANK basics" {
proc remrangebyrank {min max} {
create_zset zset {1 a 2 b 3 c 4 d 5 e}
+ assert_equal 1 [r exists zset]
r zremrangebyrank zset $min $max
}
# end overflow
assert_equal 5 [remrangebyrank 0 10]
assert_equal {} [r zrange zset 0 -1]
+
+ # destroy when empty
+ assert_equal 5 [remrangebyrank 0 4]
+ assert_equal 0 [r exists zset]
}
test "ZUNIONSTORE against non-existing key doesn't set destination - $encoding" {
assert_equal 0 [r exists dst_key]
}
+ test "ZUNIONSTORE with empty set - $encoding" {
+ r del zseta zsetb
+ r zadd zseta 1 a
+ r zadd zseta 2 b
+ r zunionstore zsetc 2 zseta zsetb
+ r zrange zsetc 0 -1 withscores
+ } {a 1 b 2}
+
test "ZUNIONSTORE basics - $encoding" {
r del zseta zsetb zsetc
r zadd zseta 1 a
}
basics ziplist
- basics raw
+ basics skiplist
+
+ test {ZINTERSTORE regression with two sets, intset+hashtable} {
+ r del seta setb setc
+ r sadd set1 a
+ r sadd set2 10
+ r zinterstore set3 2 set1 set2
+ } {0}
proc stressers {encoding} {
if {$encoding == "ziplist"} {
r config set zset-max-ziplist-entries 256
r config set zset-max-ziplist-value 64
set elements 128
- } elseif {$encoding == "raw"} {
+ } elseif {$encoding == "skiplist"} {
r config set zset-max-ziplist-entries 0
r config set zset-max-ziplist-value 0
set elements 1000
tags {"slow"} {
stressers ziplist
- stressers raw
+ stressers skiplist
}
}