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
bdbb5a02
Commit
bdbb5a02
authored
Apr 19, 2016
by
antirez
Browse files
Modules: put zset iterator current element in auto memory pool.
parent
6eeeda39
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
bdbb5a02
...
@@ -1051,6 +1051,8 @@ int RM_ZsetFirstInRange(RedisModuleKey *key, RedisModuleZsetRange *zr) {
...
@@ -1051,6 +1051,8 @@ int RM_ZsetFirstInRange(RedisModuleKey *key, RedisModuleZsetRange *zr) {
* or NULL if the range specified in the iterator does not include any
* or NULL if the range specified in the iterator does not include any
* element. */
* element. */
RedisModuleString
*
RM_ZsetRangeCurrentElement
(
RedisModuleKey
*
key
,
double
*
score
)
{
RedisModuleString
*
RM_ZsetRangeCurrentElement
(
RedisModuleKey
*
key
,
double
*
score
)
{
RedisModuleString
*
str
;
if
(
key
->
zcurrent
==
NULL
)
return
NULL
;
if
(
key
->
zcurrent
==
NULL
)
return
NULL
;
if
(
key
->
value
->
encoding
==
OBJ_ENCODING_ZIPLIST
)
{
if
(
key
->
value
->
encoding
==
OBJ_ENCODING_ZIPLIST
)
{
unsigned
char
*
eptr
,
*
sptr
;
unsigned
char
*
eptr
,
*
sptr
;
...
@@ -1060,14 +1062,16 @@ RedisModuleString *RM_ZsetRangeCurrentElement(RedisModuleKey *key, double *score
...
@@ -1060,14 +1062,16 @@ RedisModuleString *RM_ZsetRangeCurrentElement(RedisModuleKey *key, double *score
sptr
=
ziplistNext
(
key
->
value
->
ptr
,
eptr
);
sptr
=
ziplistNext
(
key
->
value
->
ptr
,
eptr
);
*
score
=
zzlGetScore
(
sptr
);
*
score
=
zzlGetScore
(
sptr
);
}
}
return
createObject
(
OBJ_STRING
,
ele
);
str
=
createObject
(
OBJ_STRING
,
ele
);
}
else
if
(
key
->
value
->
encoding
==
OBJ_ENCODING_SKIPLIST
)
{
}
else
if
(
key
->
value
->
encoding
==
OBJ_ENCODING_SKIPLIST
)
{
zskiplistNode
*
ln
=
key
->
zcurrent
;
zskiplistNode
*
ln
=
key
->
zcurrent
;
if
(
score
)
*
score
=
ln
->
score
;
if
(
score
)
*
score
=
ln
->
score
;
return
createStringObject
(
ln
->
ele
,
sdslen
(
ln
->
ele
));
str
=
createStringObject
(
ln
->
ele
,
sdslen
(
ln
->
ele
));
}
else
{
}
else
{
serverPanic
(
"Unsupported zset encoding"
);
serverPanic
(
"Unsupported zset encoding"
);
}
}
RM_AutoMemoryAdd
(
key
->
ctx
,
REDISMODULE_AM_STRING
,
str
);
return
str
;
}
}
/* Go to the next element of the sorted set iterator. Returns 1 if there was
/* Go to the next element of the sorted set iterator. Returns 1 if there was
...
...
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