Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
b056ca39
Commit
b056ca39
authored
Jul 06, 2010
by
antirez
Browse files
improved random dataset creation in test: del, sunionstore, zunionstore
parent
8b654e54
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/support/util.tcl
View file @
b056ca39
...
@@ -127,9 +127,23 @@ proc randomKey {} {
...
@@ -127,9 +127,23 @@ proc randomKey {} {
}
}
}
}
proc findKeyWithType
{
r type
}
{
for
{
set j 0
}
{
$j
< 20
}
{
incr j
}
{
set k
[
$r
randomkey
]
if
{
$k
eq
{}}
{
return
{}
}
if
{[
$r
type $k
]
eq $type
}
{
return $k
}
}
return
{}
}
proc createComplexDataset
{
r ops
}
{
proc createComplexDataset
{
r ops
}
{
for
{
set j 0
}
{
$j
< $ops
}
{
incr j
}
{
for
{
set j 0
}
{
$j
< $ops
}
{
incr j
}
{
set k
[
randomKey
]
set k
[
randomKey
]
set k2
[
randomKey
]
set f
[
randomValue
]
set f
[
randomValue
]
set v
[
randomValue
]
set v
[
randomValue
]
randpath
{
randpath
{
...
@@ -158,6 +172,8 @@ proc createComplexDataset {r ops} {
...
@@ -158,6 +172,8 @@ proc createComplexDataset {r ops} {
$r zadd $k $d $v
$r zadd $k $d $v
}
{
}
{
$r hset $k $f $v
$r hset $k $f $v
}
{
$r del $k
}
}
set t
[
$r
type $k
]
set t
[
$r
type $k
]
}
}
...
@@ -175,11 +191,23 @@ proc createComplexDataset {r ops} {
...
@@ -175,11 +191,23 @@ proc createComplexDataset {r ops} {
}
}
{
set
}
{
{
set
}
{
randpath
{
$r
sadd $k $v
}
\
randpath
{
$r
sadd $k $v
}
\
{
$r
srem $k $v
}
{
$r
srem $k $v
}
\
{
set otherset
[
findKeyWithType r set
]
if
{
$otherset
ne
{}}
{
$r sunionstore $k2 $k $otherset
}
}
}
}
{
zset
}
{
{
zset
}
{
randpath
{
$r
zadd $k $d $v
}
\
randpath
{
$r
zadd $k $d $v
}
\
{
$r
zrem $k $v
}
{
$r
zrem $k $v
}
\
{
set otherzset
[
findKeyWithType r zset
]
if
{
$otherzset
ne
{}}
{
$r zunionstore $k2 2 $k $otherzset
}
}
}
}
{
hash
}
{
{
hash
}
{
randpath
{
$r
hset $k $f $v
}
\
randpath
{
$r
hset $k $f $v
}
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment