Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
redis
提交
100ed062
R
redis
项目概览
别团等shy哥发育
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
100ed062
编写于
4月 06, 2011
作者:
P
Pieter Noordhuis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Test for ENCODING_SKIPLIST instead of ENCODING_RAW
上级
4cc4d164
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
28 addition
and
28 deletion
+28
-28
src/aof.c
src/aof.c
+1
-1
src/debug.c
src/debug.c
+1
-1
src/object.c
src/object.c
+1
-1
src/rdb.c
src/rdb.c
+1
-1
src/sort.c
src/sort.c
+1
-1
src/t_zset.c
src/t_zset.c
+19
-19
tests/unit/type/zset.tcl
tests/unit/type/zset.tcl
+4
-4
未找到文件。
src/aof.c
浏览文件 @
100ed062
...
...
@@ -460,7 +460,7 @@ int rewriteAppendOnlyFile(char *filename) {
}
zzlNext
(
zl
,
&
eptr
,
&
sptr
);
}
}
else
if
(
o
->
encoding
==
REDIS_ENCODING_
RAW
)
{
}
else
if
(
o
->
encoding
==
REDIS_ENCODING_
SKIPLIST
)
{
zset
*
zs
=
o
->
ptr
;
dictIterator
*
di
=
dictGetIterator
(
zs
->
dict
);
dictEntry
*
de
;
...
...
src/debug.c
浏览文件 @
100ed062
...
...
@@ -159,7 +159,7 @@ void computeDatasetDigest(unsigned char *final) {
xorDigest
(
digest
,
eledigest
,
20
);
zzlNext
(
zl
,
&
eptr
,
&
sptr
);
}
}
else
if
(
o
->
encoding
==
REDIS_ENCODING_
RAW
)
{
}
else
if
(
o
->
encoding
==
REDIS_ENCODING_
SKIPLIST
)
{
zset
*
zs
=
o
->
ptr
;
dictIterator
*
di
=
dictGetIterator
(
zs
->
dict
);
dictEntry
*
de
;
...
...
src/object.c
浏览文件 @
100ed062
...
...
@@ -144,7 +144,7 @@ void freeSetObject(robj *o) {
void
freeZsetObject
(
robj
*
o
)
{
zset
*
zs
;
switch
(
o
->
encoding
)
{
case
REDIS_ENCODING_
RAW
:
case
REDIS_ENCODING_
SKIPLIST
:
zs
=
o
->
ptr
;
dictRelease
(
zs
->
dict
);
zslFree
(
zs
->
zsl
);
...
...
src/rdb.c
浏览文件 @
100ed062
...
...
@@ -308,7 +308,7 @@ int rdbSaveObject(FILE *fp, robj *o) {
if
((
n
=
rdbSaveRawString
(
fp
,
o
->
ptr
,
l
))
==
-
1
)
return
-
1
;
nwritten
+=
n
;
}
else
if
(
o
->
encoding
==
REDIS_ENCODING_
RAW
)
{
}
else
if
(
o
->
encoding
==
REDIS_ENCODING_
SKIPLIST
)
{
zset
*
zs
=
o
->
ptr
;
dictIterator
*
di
=
dictGetIterator
(
zs
->
dict
);
dictEntry
*
de
;
...
...
src/sort.c
浏览文件 @
100ed062
...
...
@@ -200,7 +200,7 @@ void sortCommand(redisClient *c) {
}
/* Destructively convert encoded sorted sets for SORT. */
if
(
sortval
->
type
==
REDIS_ZSET
)
zsetConvert
(
sortval
,
REDIS_ENCODING_
RAW
);
if
(
sortval
->
type
==
REDIS_ZSET
)
zsetConvert
(
sortval
,
REDIS_ENCODING_
SKIPLIST
);
/* Load the sorting vector with all the objects to sort */
switch
(
sortval
->
type
)
{
...
...
src/t_zset.c
浏览文件 @
100ed062
...
...
@@ -721,7 +721,7 @@ unsigned int zsetLength(robj *zobj) {
int
length
=
-
1
;
if
(
zobj
->
encoding
==
REDIS_ENCODING_ZIPLIST
)
{
length
=
zzlLength
(
zobj
->
ptr
);
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
RAW
)
{
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
SKIPLIST
)
{
length
=
((
zset
*
)
zobj
->
ptr
)
->
zsl
->
length
;
}
else
{
redisPanic
(
"Unknown sorted set encoding"
);
...
...
@@ -743,7 +743,7 @@ void zsetConvert(robj *zobj, int encoding) {
unsigned
int
vlen
;
long
long
vlong
;
if
(
encoding
!=
REDIS_ENCODING_
RAW
)
if
(
encoding
!=
REDIS_ENCODING_
SKIPLIST
)
redisPanic
(
"Unknown target encoding"
);
zs
=
zmalloc
(
sizeof
(
*
zs
));
...
...
@@ -772,8 +772,8 @@ void zsetConvert(robj *zobj, int encoding) {
zfree
(
zobj
->
ptr
);
zobj
->
ptr
=
zs
;
zobj
->
encoding
=
REDIS_ENCODING_
RAW
;
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
RAW
)
{
zobj
->
encoding
=
REDIS_ENCODING_
SKIPLIST
;
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
SKIPLIST
)
{
unsigned
char
*
zl
=
ziplistNew
();
if
(
encoding
!=
REDIS_ENCODING_ZIPLIST
)
...
...
@@ -872,9 +872,9 @@ void zaddGenericCommand(redisClient *c, int incr) {
* too long *before* executing zzlInsert. */
zobj
->
ptr
=
zzlInsert
(
zobj
->
ptr
,
ele
,
score
);
if
(
zzlLength
(
zobj
->
ptr
)
>
server
.
zset_max_ziplist_entries
)
zsetConvert
(
zobj
,
REDIS_ENCODING_
RAW
);
zsetConvert
(
zobj
,
REDIS_ENCODING_
SKIPLIST
);
if
(
sdslen
(
ele
->
ptr
)
>
server
.
zset_max_ziplist_value
)
zsetConvert
(
zobj
,
REDIS_ENCODING_
RAW
);
zsetConvert
(
zobj
,
REDIS_ENCODING_
SKIPLIST
);
signalModifiedKey
(
c
->
db
,
key
);
server
.
dirty
++
;
...
...
@@ -884,7 +884,7 @@ void zaddGenericCommand(redisClient *c, int incr) {
else
/* ZADD */
addReply
(
c
,
shared
.
cone
);
}
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
RAW
)
{
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
SKIPLIST
)
{
zset
*
zs
=
zobj
->
ptr
;
zskiplistNode
*
znode
;
dictEntry
*
de
;
...
...
@@ -967,7 +967,7 @@ void zremCommand(redisClient *c) {
addReply
(
c
,
shared
.
czero
);
return
;
}
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
RAW
)
{
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
SKIPLIST
)
{
zset
*
zs
=
zobj
->
ptr
;
dictEntry
*
de
;
double
score
;
...
...
@@ -1013,7 +1013,7 @@ void zremrangebyscoreCommand(redisClient *c) {
if
(
zobj
->
encoding
==
REDIS_ENCODING_ZIPLIST
)
{
zobj
->
ptr
=
zzlDeleteRangeByScore
(
zobj
->
ptr
,
range
,
&
deleted
);
if
(
zzlLength
(
zobj
->
ptr
)
==
0
)
dbDelete
(
c
->
db
,
key
);
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
RAW
)
{
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
SKIPLIST
)
{
zset
*
zs
=
zobj
->
ptr
;
deleted
=
zslDeleteRangeByScore
(
zs
->
zsl
,
range
,
zs
->
dict
);
if
(
htNeedsResize
(
zs
->
dict
))
dictResize
(
zs
->
dict
);
...
...
@@ -1059,7 +1059,7 @@ void zremrangebyrankCommand(redisClient *c) {
/* Correct for 1-based rank. */
zobj
->
ptr
=
zzlDeleteRangeByRank
(
zobj
->
ptr
,
start
+
1
,
end
+
1
,
&
deleted
);
if
(
zzlLength
(
zobj
->
ptr
)
==
0
)
dbDelete
(
c
->
db
,
key
);
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
RAW
)
{
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
SKIPLIST
)
{
zset
*
zs
=
zobj
->
ptr
;
/* Correct for 1-based rank. */
...
...
@@ -1159,7 +1159,7 @@ void zuiInitIterator(zsetopsrc *op) {
it
->
zl
.
sptr
=
ziplistNext
(
it
->
zl
.
zl
,
it
->
zl
.
eptr
);
redisAssert
(
it
->
zl
.
sptr
!=
NULL
);
}
}
else
if
(
op
->
encoding
==
REDIS_ENCODING_
RAW
)
{
}
else
if
(
op
->
encoding
==
REDIS_ENCODING_
SKIPLIST
)
{
it
->
sl
.
zs
=
op
->
subject
->
ptr
;
it
->
sl
.
node
=
it
->
sl
.
zs
->
zsl
->
header
->
level
[
0
].
forward
;
}
else
{
...
...
@@ -1187,7 +1187,7 @@ void zuiClearIterator(zsetopsrc *op) {
iterzset
*
it
=
&
op
->
iter
.
zset
;
if
(
op
->
encoding
==
REDIS_ENCODING_ZIPLIST
)
{
REDIS_NOTUSED
(
it
);
/* skip */
}
else
if
(
op
->
encoding
==
REDIS_ENCODING_
RAW
)
{
}
else
if
(
op
->
encoding
==
REDIS_ENCODING_
SKIPLIST
)
{
REDIS_NOTUSED
(
it
);
/* skip */
}
else
{
redisPanic
(
"Unknown sorted set encoding"
);
...
...
@@ -1214,7 +1214,7 @@ int zuiLength(zsetopsrc *op) {
iterzset
*
it
=
&
op
->
iter
.
zset
;
if
(
op
->
encoding
==
REDIS_ENCODING_ZIPLIST
)
{
return
zzlLength
(
it
->
zl
.
zl
);
}
else
if
(
op
->
encoding
==
REDIS_ENCODING_
RAW
)
{
}
else
if
(
op
->
encoding
==
REDIS_ENCODING_
SKIPLIST
)
{
return
it
->
sl
.
zs
->
zsl
->
length
;
}
else
{
redisPanic
(
"Unknown sorted set encoding"
);
...
...
@@ -1267,7 +1267,7 @@ int zuiNext(zsetopsrc *op, zsetopval *val) {
/* Move to next element. */
zzlNext
(
it
->
zl
.
zl
,
&
it
->
zl
.
eptr
,
&
it
->
zl
.
sptr
);
}
else
if
(
op
->
encoding
==
REDIS_ENCODING_
RAW
)
{
}
else
if
(
op
->
encoding
==
REDIS_ENCODING_
SKIPLIST
)
{
if
(
it
->
sl
.
node
==
NULL
)
return
0
;
val
->
ele
=
it
->
sl
.
node
->
obj
;
...
...
@@ -1379,7 +1379,7 @@ int zuiFind(zsetopsrc *op, zsetopval *val, double *score) {
}
else
{
return
0
;
}
}
else
if
(
op
->
encoding
==
REDIS_ENCODING_
RAW
)
{
}
else
if
(
op
->
encoding
==
REDIS_ENCODING_
SKIPLIST
)
{
dictEntry
*
de
;
if
((
de
=
dictFind
(
it
->
sl
.
zs
->
dict
,
val
->
ele
))
!=
NULL
)
{
*
score
=
*
(
double
*
)
dictGetEntryVal
(
de
);
...
...
@@ -1692,7 +1692,7 @@ void zrangeGenericCommand(redisClient *c, int reverse) {
zzlNext
(
zl
,
&
eptr
,
&
sptr
);
}
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
RAW
)
{
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
SKIPLIST
)
{
zset
*
zs
=
zobj
->
ptr
;
zskiplist
*
zsl
=
zs
->
zsl
;
zskiplistNode
*
ln
;
...
...
@@ -1849,7 +1849,7 @@ void genericZrangebyscoreCommand(redisClient *c, int reverse, int justcount) {
else
zzlNext
(
zl
,
&
eptr
,
&
sptr
);
}
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
RAW
)
{
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
SKIPLIST
)
{
zset
*
zs
=
zobj
->
ptr
;
zskiplist
*
zsl
=
zs
->
zsl
;
zskiplistNode
*
ln
;
...
...
@@ -1943,7 +1943,7 @@ void zscoreCommand(redisClient *c) {
addReplyDouble
(
c
,
score
);
else
addReply
(
c
,
shared
.
nullbulk
);
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
RAW
)
{
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
SKIPLIST
)
{
zset
*
zs
=
zobj
->
ptr
;
dictEntry
*
de
;
...
...
@@ -1997,7 +1997,7 @@ void zrankGenericCommand(redisClient *c, int reverse) {
}
else
{
addReply
(
c
,
shared
.
nullbulk
);
}
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
RAW
)
{
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_
SKIPLIST
)
{
zset
*
zs
=
zobj
->
ptr
;
zskiplist
*
zsl
=
zs
->
zsl
;
dictEntry
*
de
;
...
...
tests/unit/type/zset.tcl
浏览文件 @
100ed062
...
...
@@ -10,7 +10,7 @@ start_server {tags {"zset"}} {
if
{
$encoding
==
"ziplist"
}
{
r config set zset-max-ziplist-entries 128
r config set zset-max-ziplist-value 64
}
elseif
{
$encoding
==
"
raw
"
}
{
}
elseif
{
$encoding
==
"
skiplist
"
}
{
r config set zset-max-ziplist-entries 0
r config set zset-max-ziplist-value 0
}
else
{
...
...
@@ -458,7 +458,7 @@ start_server {tags {"zset"}} {
}
basics ziplist
basics
raw
basics
skiplist
proc stressers
{
encoding
}
{
if
{
$encoding
==
"ziplist"
}
{
...
...
@@ -466,7 +466,7 @@ start_server {tags {"zset"}} {
r config set zset-max-ziplist-entries 256
r config set zset-max-ziplist-value 64
set elements 128
}
elseif
{
$encoding
==
"
raw
"
}
{
}
elseif
{
$encoding
==
"
skiplist
"
}
{
r config set zset-max-ziplist-entries 0
r config set zset-max-ziplist-value 0
set elements 1000
...
...
@@ -684,6 +684,6 @@ start_server {tags {"zset"}} {
tags
{
"slow"
}
{
stressers ziplist
stressers
raw
stressers
skiplist
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录