Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Turbo码先生
redis
提交
db3ade22
R
redis
项目概览
Turbo码先生
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
db3ade22
编写于
4月 21, 2016
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modules: zset lex iterator #2.
上级
2b04f86a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
30 addition
and
6 deletion
+30
-6
src/module.c
src/module.c
+20
-0
src/server.h
src/server.h
+4
-0
src/t_zset.c
src/t_zset.c
+6
-6
未找到文件。
src/module.c
浏览文件 @
db3ade22
...
...
@@ -1286,6 +1286,11 @@ int RM_ZsetRangeNext(RedisModuleKey *key) {
return
0
;
}
next
=
saved_next
;
}
else
if
(
key
->
ztype
==
REDISMODULE_ZSET_RANGE_SCORE
)
{
if
(
!
zzlLexValueLteMax
(
next
,
&
key
->
zlrs
))
{
key
->
zer
=
1
;
return
0
;
}
}
key
->
zcurrent
=
next
;
return
1
;
...
...
@@ -1302,6 +1307,11 @@ int RM_ZsetRangeNext(RedisModuleKey *key) {
{
key
->
zer
=
1
;
return
0
;
}
else
if
(
key
->
ztype
==
REDISMODULE_ZSET_RANGE_SCORE
)
{
if
(
!
zslLexValueLteMax
(
ln
->
ele
,
&
key
->
zlrs
))
{
key
->
zer
=
1
;
return
0
;
}
}
key
->
zcurrent
=
next
;
return
1
;
...
...
@@ -1339,6 +1349,11 @@ int RM_ZsetRangePrev(RedisModuleKey *key) {
return
0
;
}
prev
=
saved_prev
;
}
else
if
(
key
->
ztype
==
REDISMODULE_ZSET_RANGE_SCORE
)
{
if
(
!
zzlLexValueGteMin
(
prev
,
&
key
->
zlrs
))
{
key
->
zer
=
1
;
return
0
;
}
}
key
->
zcurrent
=
prev
;
return
1
;
...
...
@@ -1355,6 +1370,11 @@ int RM_ZsetRangePrev(RedisModuleKey *key) {
{
key
->
zer
=
1
;
return
0
;
}
else
if
(
key
->
ztype
==
REDISMODULE_ZSET_RANGE_SCORE
)
{
if
(
!
zslLexValueGteMin
(
prev
->
ele
,
&
key
->
zlrs
))
{
key
->
zer
=
1
;
return
0
;
}
}
key
->
zcurrent
=
prev
;
return
1
;
...
...
src/server.h
浏览文件 @
db3ade22
...
...
@@ -1353,6 +1353,10 @@ unsigned char *zzlFirstInLexRange(unsigned char *zl, zlexrangespec *range);
unsigned
char
*
zzlLastInLexRange
(
unsigned
char
*
zl
,
zlexrangespec
*
range
);
zskiplistNode
*
zslFirstInLexRange
(
zskiplist
*
zsl
,
zlexrangespec
*
range
);
zskiplistNode
*
zslLastInLexRange
(
zskiplist
*
zsl
,
zlexrangespec
*
range
);
int
zzlLexValueGteMin
(
unsigned
char
*
p
,
zlexrangespec
*
spec
);
int
zzlLexValueLteMax
(
unsigned
char
*
p
,
zlexrangespec
*
spec
);
int
zslLexValueGteMin
(
sds
value
,
zlexrangespec
*
spec
);
int
zslLexValueLteMax
(
sds
value
,
zlexrangespec
*
spec
);
/* Core functions */
int
freeMemoryIfNeeded
(
void
);
...
...
src/t_zset.c
浏览文件 @
db3ade22
...
...
@@ -63,8 +63,8 @@
* Skiplist implementation of the low level API
*----------------------------------------------------------------------------*/
static
int
zslLexValueGteMin
(
sds
value
,
zlexrangespec
*
spec
);
static
int
zslLexValueLteMax
(
sds
value
,
zlexrangespec
*
spec
);
int
zslLexValueGteMin
(
sds
value
,
zlexrangespec
*
spec
);
int
zslLexValueLteMax
(
sds
value
,
zlexrangespec
*
spec
);
/* Create a skiplist node with the specified number of levels.
* The SDS string 'ele' is referenced by the node after the call. */
...
...
@@ -580,13 +580,13 @@ int sdscmplex(sds a, sds b) {
return
sdscmp
(
a
,
b
);
}
static
int
zslLexValueGteMin
(
sds
value
,
zlexrangespec
*
spec
)
{
int
zslLexValueGteMin
(
sds
value
,
zlexrangespec
*
spec
)
{
return
spec
->
minex
?
(
sdscmplex
(
value
,
spec
->
min
)
>
0
)
:
(
sdscmplex
(
value
,
spec
->
min
)
>=
0
);
}
static
int
zslLexValueLteMax
(
sds
value
,
zlexrangespec
*
spec
)
{
int
zslLexValueLteMax
(
sds
value
,
zlexrangespec
*
spec
)
{
return
spec
->
maxex
?
(
sdscmplex
(
value
,
spec
->
max
)
<
0
)
:
(
sdscmplex
(
value
,
spec
->
max
)
<=
0
);
...
...
@@ -852,14 +852,14 @@ unsigned char *zzlLastInRange(unsigned char *zl, zrangespec *range) {
return
NULL
;
}
static
int
zzlLexValueGteMin
(
unsigned
char
*
p
,
zlexrangespec
*
spec
)
{
int
zzlLexValueGteMin
(
unsigned
char
*
p
,
zlexrangespec
*
spec
)
{
sds
value
=
ziplistGetObject
(
p
);
int
res
=
zslLexValueGteMin
(
value
,
spec
);
sdsfree
(
value
);
return
res
;
}
static
int
zzlLexValueLteMax
(
unsigned
char
*
p
,
zlexrangespec
*
spec
)
{
int
zzlLexValueLteMax
(
unsigned
char
*
p
,
zlexrangespec
*
spec
)
{
sds
value
=
ziplistGetObject
(
p
);
int
res
=
zslLexValueLteMax
(
value
,
spec
);
sdsfree
(
value
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录