"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/unit/type/hash.tcl" between
redis-6.2-rc3.tar.gz and redis-6.2.0.tar.gz

About: redis is an advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

hash.tcl  (redis-6.2-rc3):hash.tcl  (redis-6.2.0)
skipping to change at line 99 skipping to change at line 99
# We'll stress different parts of the code, see the implementation # We'll stress different parts of the code, see the implementation
# of HRANDFIELD for more information, but basically there are # of HRANDFIELD for more information, but basically there are
# four different code paths. # four different code paths.
# PATH 1: Use negative count. # PATH 1: Use negative count.
# 1) Check that it returns repeated elements with and without values . # 1) Check that it returns repeated elements with and without values .
set res [r hrandfield myhash -20] set res [r hrandfield myhash -20]
assert_equal [llength $res] 20 assert_equal [llength $res] 20
set res [r hrandfield myhash -1001]
assert_equal [llength $res] 1001
# again with WITHVALUES # again with WITHVALUES
set res [r hrandfield myhash -20 withvalues] set res [r hrandfield myhash -20 withvalues]
assert_equal [llength $res] 40 assert_equal [llength $res] 40
set res [r hrandfield myhash -1001 withvalues]
assert_equal [llength $res] 2002
# Test random uniform distribution
set res [r hrandfield myhash -1000]
assert_equal [check_histogram_distribution $res 0.05 0.15] true
# 2) Check that all the elements actually belong to the original has h. # 2) Check that all the elements actually belong to the original has h.
foreach {key val} $res { foreach {key val} $res {
assert {[dict exists $mydict $key]} assert {[dict exists $mydict $key]}
} }
# 3) Check that eventually all the elements are returned. # 3) Check that eventually all the elements are returned.
# Use both WITHVALUES and without # Use both WITHVALUES and without
unset -nocomplain auxset unset -nocomplain auxset
set iterations 1000 set iterations 1000
skipping to change at line 170 skipping to change at line 178
# 1) Check that all the elements actually belong to the # 1) Check that all the elements actually belong to the
# original set. # original set.
foreach ele [dict keys $res] { foreach ele [dict keys $res] {
assert {[dict exists $mydict $ele]} assert {[dict exists $mydict $ele]}
} }
# 2) Check that eventually all the elements are returned. # 2) Check that eventually all the elements are returned.
# Use both WITHVALUES and without # Use both WITHVALUES and without
unset -nocomplain auxset unset -nocomplain auxset
set iterations 1000 unset -nocomplain allkey
set iterations [expr {1000 / $size}]
set all_ele_return false
while {$iterations != 0} { while {$iterations != 0} {
incr iterations -1 incr iterations -1
if {[expr {$iterations % 2}] == 0} { if {[expr {$iterations % 2}] == 0} {
set res [r hrandfield myhash $size withvalues] set res [r hrandfield myhash $size withvalues]
foreach {key value} $res { foreach {key value} $res {
dict append auxset $key $value dict append auxset $key $value
lappend allkey $key
} }
} else { } else {
set res [r hrandfield myhash $size] set res [r hrandfield myhash $size]
foreach key $res { foreach key $res {
dict append auxset $key dict append auxset $key
lappend allkey $key
} }
} }
if {[lsort [dict keys $mydict]] eq if {[lsort [dict keys $mydict]] eq
[lsort [dict keys $auxset]]} { [lsort [dict keys $auxset]]} {
break; set all_ele_return true
} }
} }
assert {$iterations != 0} assert_equal $all_ele_return true
assert_equal [check_histogram_distribution $allkey 0.05 0.15] tr
ue
} }
} }
r config set hash-max-ziplist-value $original_max_value r config set hash-max-ziplist-value $original_max_value
} }
test {HSET/HLEN - Big hash creation} { test {HSET/HLEN - Big hash creation} {
array set bighash {} array set bighash {}
for {set i 0} {$i < 1024} {incr i} { for {set i 0} {$i < 1024} {incr i} {
set key __avoid_collisions__[randstring 0 8 alpha] set key __avoid_collisions__[randstring 0 8 alpha]
set val __avoid_collisions__[randstring 0 8 alpha] set val __avoid_collisions__[randstring 0 8 alpha]
 End of changes. 7 change blocks. 
3 lines changed or deleted 17 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)