Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
438d0cae
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
438d0cae
编写于
6月 12, 2023
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mroe code
上级
9a4f6abe
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
164 addition
and
32 deletion
+164
-32
source/dnode/vnode/src/tsdb/dev/inc/tsdbIter.h
source/dnode/vnode/src/tsdb/dev/inc/tsdbIter.h
+2
-1
source/dnode/vnode/src/tsdb/dev/tsdbCommit.c
source/dnode/vnode/src/tsdb/dev/tsdbCommit.c
+104
-31
source/dnode/vnode/src/tsdb/dev/tsdbIter.c
source/dnode/vnode/src/tsdb/dev/tsdbIter.c
+58
-0
未找到文件。
source/dnode/vnode/src/tsdb/dev/inc/tsdbIter.h
浏览文件 @
438d0cae
...
...
@@ -35,6 +35,7 @@ typedef enum {
TSDB_ITER_TYPE_MEMT
,
TSDB_ITER_TYPE_STT_TOMB
,
TSDB_ITER_TYPE_DATA_TOMB
,
TSDB_ITER_TYPE_MEMT_TOMB
,
}
EIterType
;
typedef
struct
{
...
...
@@ -43,7 +44,7 @@ typedef struct {
SSttSegReader
*
sttReader
;
// TSDB_ITER_TYPE_STT || TSDB_ITER_TYPE_STT_TOMB
SDataFileReader
*
dataReader
;
// TSDB_ITER_TYPE_DATA || TSDB_ITER_TYPE_DATA_TOMB
struct
{
SMemTable
*
memt
;
SMemTable
*
memt
;
// TSDB_ITER_TYPE_MEMT_TOMB
TSDBKEY
from
[
1
];
};
// TSDB_ITER_TYPE_MEMT
};
...
...
source/dnode/vnode/src/tsdb/dev/tsdbCommit.c
浏览文件 @
438d0cae
...
...
@@ -455,50 +455,123 @@ _exit:
return
code
;
}
static
int32_t
tsdbCommit
DelData
(
SCommitter2
*
committer
)
{
static
int32_t
tsdbCommit
TombDataToStt
(
SCommitter2
*
committer
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
SMemTable
*
mem
=
committer
->
tsdb
->
imem
;
for
(
STombRecord
*
record
;
(
record
=
tsdbIterMergerGetTombRecord
(
committer
->
iterMerger
));)
{
code
=
tsdbSttFileWriteTombRecord
(
committer
->
sttWriter
,
record
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
mem
->
nDel
==
0
//
||
(
committer
->
ctx
->
fset
==
NULL
//
&&
committer
->
sttWriter
==
NULL
)
//
)
{
committer
->
ctx
->
nextKey
=
committer
->
ctx
->
maxKey
+
1
;
goto
_exit
;
code
=
tsdbIterMergerNext
(
committer
->
iterMerger
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
SRBTreeIter
iter
[
1
]
=
{
tRBTreeIterCreate
(
committer
->
tsdb
->
imem
->
tbDataTree
,
1
)};
_exit:
if
(
code
)
{
TSDB_ERROR_LOG
(
TD_VID
(
committer
->
tsdb
->
pVnode
),
lino
,
code
);
}
return
code
;
}
for
(
SRBTreeNode
*
node
=
tRBTreeIterNext
(
iter
);
node
;
node
=
tRBTreeIterNext
(
iter
))
{
STbData
*
tbData
=
TCONTAINER_OF
(
node
,
STbData
,
rbtn
);
STombRecord
record
[
1
]
=
{{
.
suid
=
tbData
->
suid
,
.
uid
=
tbData
->
uid
,
}};
static
int32_t
tsdbCommitTombDataToData
(
SCommitter2
*
committer
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
for
(
SDelData
*
delData
=
tbData
->
pHead
;
delData
;
delData
=
delData
->
pNext
)
{
if
(
delData
->
eKey
<
committer
->
ctx
->
minKey
)
continue
;
if
(
delData
->
sKey
>
committer
->
ctx
->
maxKey
)
{
committer
->
ctx
->
nextKey
=
TMIN
(
committer
->
ctx
->
nextKey
,
delData
->
sKey
);
continue
;
}
if
(
committer
->
dataWriter
==
NULL
||
tsdbSttFileWriterIsOpened
(
committer
->
sttWriter
))
{
for
(
STombRecord
*
record
;
(
record
=
tsdbIterMergerGetTombRecord
(
committer
->
iterMerger
));)
{
code
=
tsdbSttFileWriteTombRecord
(
committer
->
sttWriter
,
record
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
record
->
version
=
delData
->
version
;
record
->
skey
=
TMAX
(
delData
->
sKey
,
committer
->
ctx
->
minKey
);
if
(
delData
->
eKey
>
committer
->
ctx
->
maxKey
)
{
committer
->
ctx
->
nextKey
=
TMIN
(
committer
->
ctx
->
nextKey
,
committer
->
ctx
->
maxKey
+
1
);
record
->
ekey
=
committer
->
ctx
->
maxKey
;
}
else
{
record
->
ekey
=
delData
->
eKey
;
}
code
=
tsdbIterMergerNext
(
committer
->
iterMerger
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
}
else
{
for
(
STombRecord
*
record
;
(
record
=
tsdbIterMergerGetTombRecord
(
committer
->
iterMerger
));)
{
code
=
tsdbDataFileWriteTombRecord
(
committer
->
dataWriter
,
record
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
tsdbSttFileWriteTombRecord
(
committer
->
sttWriter
,
record
);
code
=
tsdbIterMergerNext
(
committer
->
iterMerger
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
}
_exit:
if
(
code
)
{
TSDB_ERROR_LOG
(
TD_VID
(
committer
->
tsdb
->
pVnode
),
lino
,
code
);
}
return
code
;
}
static
int32_t
tsdbCommitTombDataOpenIter
(
SCommitter2
*
committer
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
STsdbIter
*
iter
;
STsdbIterConfig
config
[
1
];
if
(
committer
->
sttReader
)
{
const
TSttSegReaderArray
*
readerArray
;
tsdbSttFileReaderGetSegReader
(
committer
->
sttReader
,
&
readerArray
);
SSttSegReader
*
segReader
;
TARRAY2_FOREACH
(
readerArray
,
segReader
)
{
config
->
type
=
TSDB_ITER_TYPE_STT_TOMB
;
config
->
sttReader
=
segReader
;
code
=
tsdbIterOpen
(
config
,
&
iter
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
TARRAY2_APPEND
(
committer
->
iterArray
,
iter
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
}
config
->
type
=
TSDB_ITER_TYPE_MEMT_TOMB
;
config
->
memt
=
committer
->
tsdb
->
imem
;
code
=
tsdbIterOpen
(
config
,
&
iter
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
TARRAY2_APPEND
(
committer
->
iterArray
,
iter
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
// open iter
code
=
tsdbIterMergerOpen
(
committer
->
iterArray
,
&
committer
->
iterMerger
,
true
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
_exit:
if
(
code
)
{
TSDB_ERROR_LOG
(
TD_VID
(
committer
->
tsdb
->
pVnode
),
lino
,
code
);
}
return
code
;
}
static
int32_t
tsdbCommitTombDataCloseIter
(
SCommitter2
*
committer
)
{
tsdbIterMergerClose
(
&
committer
->
iterMerger
);
TARRAY2_CLEAR
(
committer
->
iterArray
,
tsdbIterClose
);
return
0
;
}
static
int32_t
tsdbCommitTombData
(
SCommitter2
*
committer
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
code
=
tsdbCommitTombDataOpenIter
(
committer
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
committer
->
sttTrigger
>
1
)
{
code
=
tsdbCommitTombDataToStt
(
committer
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
else
{
code
=
tsdbCommitTombDataToData
(
committer
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
code
=
tsdbCommitTombDataCloseIter
(
committer
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
_exit:
if
(
code
)
{
TSDB_ERROR_LOG
(
TD_VID
(
committer
->
tsdb
->
pVnode
),
lino
,
code
);
...
...
@@ -578,7 +651,7 @@ static int32_t tsdbCommitFileSet(SCommitter2 *committer) {
code
=
tsdbCommitTSData
(
committer
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
tsdbCommit
Del
Data
(
committer
);
code
=
tsdbCommit
Tomb
Data
(
committer
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
// fset commit end
...
...
source/dnode/vnode/src/tsdb/dev/tsdbIter.c
浏览文件 @
438d0cae
...
...
@@ -64,6 +64,12 @@ struct STsdbIter {
STombBlock
tombBlock
[
1
];
int32_t
tombBlockIdx
;
}
dataTomb
[
1
];
struct
{
SMemTable
*
memt
;
SRBTreeIter
rbtIter
[
1
];
STbData
*
tbData
;
SDelData
*
delData
;
}
memtTomb
[
1
];
};
};
...
...
@@ -259,6 +265,45 @@ _exit:
return
0
;
}
static
int32_t
tsdbMemTombIterNext
(
STsdbIter
*
iter
,
const
TABLEID
*
tbid
)
{
while
(
!
iter
->
ctx
->
noMoreData
)
{
for
(;
iter
->
memtTomb
->
delData
;)
{
if
(
tbid
&&
tbid
->
uid
==
iter
->
memtTomb
->
tbData
->
uid
)
{
iter
->
memtTomb
->
delData
=
NULL
;
break
;
}
iter
->
record
->
suid
=
iter
->
memtTomb
->
tbData
->
suid
;
iter
->
record
->
uid
=
iter
->
memtTomb
->
tbData
->
uid
;
iter
->
record
->
version
=
iter
->
memtTomb
->
delData
->
version
;
iter
->
record
->
skey
=
iter
->
memtTomb
->
delData
->
sKey
;
iter
->
record
->
ekey
=
iter
->
memtTomb
->
delData
->
eKey
;
iter
->
memtTomb
->
delData
=
iter
->
memtTomb
->
delData
->
pNext
;
goto
_exit
;
}
for
(;;)
{
SRBTreeNode
*
node
=
tRBTreeIterNext
(
iter
->
memtTomb
->
rbtIter
);
if
(
node
==
NULL
)
{
iter
->
ctx
->
noMoreData
=
true
;
goto
_exit
;
}
iter
->
memtTomb
->
tbData
=
TCONTAINER_OF
(
node
,
STbData
,
rbtn
);
if
(
tbid
&&
tbid
->
uid
==
iter
->
memtTomb
->
tbData
->
uid
)
{
continue
;
}
else
{
iter
->
memtTomb
->
delData
=
iter
->
memtTomb
->
tbData
->
pHead
;
break
;
}
}
}
_exit:
return
0
;
}
static
int32_t
tsdbSttIterOpen
(
STsdbIter
*
iter
)
{
int32_t
code
;
...
...
@@ -330,6 +375,13 @@ static int32_t tsdbDataTombIterOpen(STsdbIter *iter) {
return
tsdbDataTombIterNext
(
iter
,
NULL
);
}
static
int32_t
tsdbMemTombIterOpen
(
STsdbIter
*
iter
)
{
int32_t
code
;
iter
->
memtTomb
->
rbtIter
[
0
]
=
tRBTreeIterCreate
(
iter
->
memtTomb
->
memt
->
tbDataTree
,
1
);
return
tsdbMemTombIterNext
(
iter
,
NULL
);
}
static
int32_t
tsdbDataIterClose
(
STsdbIter
*
iter
)
{
tBrinBlockDestroy
(
iter
->
dataData
->
brinBlock
);
tBlockDataDestroy
(
iter
->
dataData
->
blockData
);
...
...
@@ -432,6 +484,10 @@ int32_t tsdbIterOpen(const STsdbIterConfig *config, STsdbIter **iter) {
iter
[
0
]
->
dataTomb
->
reader
=
config
->
dataReader
;
code
=
tsdbDataTombIterOpen
(
iter
[
0
]);
break
;
case
TSDB_ITER_TYPE_MEMT_TOMB
:
iter
[
0
]
->
memtTomb
->
memt
=
config
->
memt
;
code
=
tsdbMemTombIterOpen
(
iter
[
0
]);
break
;
default:
code
=
TSDB_CODE_INVALID_PARA
;
ASSERTS
(
false
,
"Not implemented"
);
...
...
@@ -471,6 +527,8 @@ int32_t tsdbIterClose(STsdbIter **iter) {
case
TSDB_ITER_TYPE_DATA_TOMB
:
tsdbDataTombIterClose
(
iter
[
0
]);
break
;
case
TSDB_ITER_TYPE_MEMT_TOMB
:
break
;
default:
ASSERT
(
false
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录