redict/tests/unit/type
Yang Bodong b9a0500f16
Add HRANDFIELD and ZRANDMEMBER. improvements to SRANDMEMBER (#8297)
New commands:
`HRANDFIELD [<count> [WITHVALUES]]`
`ZRANDMEMBER [<count> [WITHSCORES]]`
Algorithms are similar to the one in SRANDMEMBER.

Both return a simple bulk response when no arguments are given, and an array otherwise.
In case values/scores are requested, RESP2 returns a long array, and RESP3 a nested array.
note: in all 3 commands, the only option that also provides random order is the one with negative count.

Changes to SRANDMEMBER
* Optimization when count is 1, we can use the more efficient algorithm of non-unique random
* optimization: work with sds strings rather than robj

Other changes:
* zzlGetScore: when zset needs to convert string to double, we use safer memcpy (in
  case the buffer is too small)
* Solve a "bug" in SRANDMEMBER test: it intended to test a positive count (case 3 or
  case 4) and by accident used a negative count

Co-authored-by: xinluton <xinluton@qq.com>
Co-authored-by: Oran Agra <oran@redislabs.com>
2021-01-29 10:47:28 +02:00
..
hash.tcl Add HRANDFIELD and ZRANDMEMBER. improvements to SRANDMEMBER (#8297) 2021-01-29 10:47:28 +02:00
incr.tcl skip a test that uses +inf on valgrind (#7440) 2020-07-10 08:29:02 +03:00
list-2.tcl Minor improvements for list-2 test (#8156) 2020-12-08 16:26:38 +02:00
list-3.tcl Test: new randomized stress tester for #3343 alike bugs. 2016-06-28 09:42:20 +02:00
list-common.tcl list test split into smaller parts 2011-07-11 11:30:46 +02:00
list.tcl Adds count to L/RPOP (#8179) 2020-12-25 21:49:24 +02:00
set.tcl Add HRANDFIELD and ZRANDMEMBER. improvements to SRANDMEMBER (#8297) 2021-01-29 10:47:28 +02:00
stream-cgroups.tcl Add XAUTOCLAIM (#7973) 2021-01-06 10:34:27 +02:00
stream.tcl XADD and XTRIM, Trim by MINID, and new LIMIT argument (#8169) 2021-01-08 18:13:25 +02:00
string.tcl GETEX, GETDEL and SET PXAT/EXAT (#8327) 2021-01-27 19:47:26 +02:00
zset.tcl Add HRANDFIELD and ZRANDMEMBER. improvements to SRANDMEMBER (#8297) 2021-01-29 10:47:28 +02:00