Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Turbo码先生
redis
提交
26d4f8e3
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,发现更多精彩内容 >>
提交
26d4f8e3
编写于
9月 15, 2017
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Streams: AOF rewriting + minor iterator improvements.
上级
01ea018c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
42 addition
and
5 deletion
+42
-5
src/aof.c
src/aof.c
+33
-0
src/t_stream.c
src/t_stream.c
+9
-5
未找到文件。
src/aof.c
浏览文件 @
26d4f8e3
...
...
@@ -1031,6 +1031,37 @@ int rewriteHashObject(rio *r, robj *key, robj *o) {
return
1
;
}
/* Emit the commands needed to rebuild a stream object.
* The function returns 0 on error, 1 on success. */
int
rewriteStreamObject
(
rio
*
r
,
robj
*
key
,
robj
*
o
)
{
streamIterator
si
;
streamIteratorStart
(
&
si
,
o
->
ptr
,
NULL
,
NULL
);
streamID
id
;
int64_t
numfields
;
while
(
streamIteratorGetID
(
&
si
,
&
id
,
&
numfields
))
{
/* Emit a two elements array for each item. The first is
* the ID, the second is an array of field-value pairs. */
/* Emit the XADD <key> <id> ...fields... command. */
if
(
rioWriteBulkCount
(
r
,
'*'
,
3
+
numfields
*
2
)
==
0
)
return
0
;
if
(
rioWriteBulkString
(
r
,
"XADD"
,
4
)
==
0
)
return
0
;
if
(
rioWriteBulkObject
(
r
,
key
)
==
0
)
return
0
;
sds
replyid
=
sdscatfmt
(
sdsempty
(),
"%U.%U"
,
id
.
ms
,
id
.
seq
);
if
(
rioWriteBulkString
(
r
,
replyid
,
sdslen
(
replyid
))
==
0
)
return
0
;
sdsfree
(
replyid
);
while
(
numfields
--
)
{
unsigned
char
*
field
,
*
value
;
int64_t
field_len
,
value_len
;
streamIteratorGetField
(
&
si
,
&
field
,
&
value
,
&
field_len
,
&
value_len
);
if
(
rioWriteBulkString
(
r
,(
char
*
)
field
,
field_len
)
==
0
)
return
0
;
if
(
rioWriteBulkString
(
r
,(
char
*
)
value
,
value_len
)
==
0
)
return
0
;
}
}
streamIteratorStop
(
&
si
);
return
1
;
}
/* Call the module type callback in order to rewrite a data type
* that is exported by a module and is not handled by Redis itself.
* The function returns 0 on error, 1 on success. */
...
...
@@ -1111,6 +1142,8 @@ int rewriteAppendOnlyFileRio(rio *aof) {
if
(
rewriteSortedSetObject
(
aof
,
&
key
,
o
)
==
0
)
goto
werr
;
}
else
if
(
o
->
type
==
OBJ_HASH
)
{
if
(
rewriteHashObject
(
aof
,
&
key
,
o
)
==
0
)
goto
werr
;
}
else
if
(
o
->
type
==
OBJ_STREAM
)
{
if
(
rewriteStreamObject
(
aof
,
&
key
,
o
)
==
0
)
goto
werr
;
}
else
if
(
o
->
type
==
OBJ_MODULE
)
{
if
(
rewriteModuleObject
(
aof
,
&
key
,
o
)
==
0
)
goto
werr
;
}
else
{
...
...
src/t_stream.c
浏览文件 @
26d4f8e3
...
...
@@ -218,19 +218,23 @@ int streamAppendItem(stream *s, robj **argv, int numfields, streamID *added_id,
void
streamIteratorStart
(
streamIterator
*
si
,
stream
*
s
,
streamID
*
start
,
streamID
*
end
)
{
/* Intialize the iterator and translates the iteration start/stop
* elements into a 128 big big-endian number. */
streamEncodeID
(
si
->
start_key
,
start
);
if
(
start
)
{
streamEncodeID
(
si
->
start_key
,
start
);
}
else
{
si
->
start_key
[
0
]
=
0
;
si
->
start_key
[
0
]
=
0
;
}
if
(
end
)
{
streamEncodeID
(
si
->
end_key
,
end
);
}
else
{
/* We assume that UINT64_MAX is the same in little and big
* endian, that is, all bits set. */
si
->
end_key
[
0
]
=
UINT64_MAX
;
si
->
end_key
[
0
]
=
UINT64_MAX
;
}
raxStart
(
&
si
->
ri
,
s
->
rax
);
/* Seek the correct node in the radix tree. */
if
(
start
->
ms
||
start
->
seq
)
{
raxStart
(
&
si
->
ri
,
s
->
rax
);
if
(
start
&&
(
start
->
ms
||
start
->
seq
))
{
raxSeek
(
&
si
->
ri
,
"<="
,(
unsigned
char
*
)
si
->
start_key
,
sizeof
(
si
->
start_key
));
if
(
raxEOF
(
&
si
->
ri
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录