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
de6ba77b
Commit
de6ba77b
authored
May 15, 2011
by
antirez
Browse files
Fixed misuse of the new iterator semantics in ZUNIONSTORE
parent
5d64f217
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/t_zset.c
View file @
de6ba77b
...
@@ -1527,6 +1527,8 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
...
@@ -1527,6 +1527,8 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
score
=
src
[
0
].
weight
*
zval
.
score
;
score
=
src
[
0
].
weight
*
zval
.
score
;
for
(
j
=
1
;
j
<
setnum
;
j
++
)
{
for
(
j
=
1
;
j
<
setnum
;
j
++
)
{
/* It is not safe to access the hash we zset we are
* iterating, so explicitly check for equal object. */
if
(
src
[
j
].
subject
==
src
[
0
].
subject
)
{
if
(
src
[
j
].
subject
==
src
[
0
].
subject
)
{
value
=
zval
.
score
*
src
[
j
].
weight
;
value
=
zval
.
score
*
src
[
j
].
weight
;
zunionInterAggregate
(
&
score
,
value
,
aggregate
);
zunionInterAggregate
(
&
score
,
value
,
aggregate
);
...
@@ -1570,7 +1572,12 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
...
@@ -1570,7 +1572,12 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
/* Because the inputs are sorted by size, it's only possible
/* Because the inputs are sorted by size, it's only possible
* for sets at larger indices to hold this element. */
* for sets at larger indices to hold this element. */
for
(
j
=
(
i
+
1
);
j
<
setnum
;
j
++
)
{
for
(
j
=
(
i
+
1
);
j
<
setnum
;
j
++
)
{
if
(
zuiFind
(
&
src
[
j
],
&
zval
,
&
value
))
{
/* It is not safe to access the hash we zset we are
* iterating, so explicitly check for equal object. */
if
(
src
[
j
].
subject
==
src
[
i
].
subject
)
{
value
=
zval
.
score
*
src
[
j
].
weight
;
zunionInterAggregate
(
&
score
,
value
,
aggregate
);
}
else
if
(
zuiFind
(
&
src
[
j
],
&
zval
,
&
value
))
{
value
*=
src
[
j
].
weight
;
value
*=
src
[
j
].
weight
;
zunionInterAggregate
(
&
score
,
value
,
aggregate
);
zunionInterAggregate
(
&
score
,
value
,
aggregate
);
}
}
...
...
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