Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
70221b10
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
70221b10
编写于
1月 07, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
partial work
上级
4c70e6a3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
76 addition
and
23 deletion
+76
-23
src/tsdb/src/tsdbCommit.c
src/tsdb/src/tsdbCommit.c
+76
-23
未找到文件。
src/tsdb/src/tsdbCommit.c
浏览文件 @
70221b10
...
...
@@ -280,6 +280,8 @@ static int tsdbCommitToFile(SCommitH *pch, SDFileSet *pOldSet, int fid) {
for
(
size_t
tid
=
0
;
tid
<
pMem
->
maxTables
;
tid
++
)
{
SCommitIter
*
pIter
=
pch
->
iters
+
tid
;
// No table exists, continue
if
(
pIter
->
pTable
==
NULL
)
continue
;
if
(
tsdbCommitToTable
(
pch
,
tid
)
<
0
)
{
...
...
@@ -452,45 +454,96 @@ static int tsdbCommitToTable(SCommitH *pch, int tid) {
tsdbSetCommitTable
(
pch
,
pIter
->
pTable
);
// No memory data and no disk data, just return
if
(
pIter
->
pIter
==
NULL
&&
pch
->
readh
.
pBl
oc
kIdx
==
NULL
)
{
if
(
pIter
->
pIter
==
NULL
&&
pch
->
readh
.
pBlkIdx
==
NULL
)
{
TSDB_RUNLOCK_TABLE
(
pIter
->
pTable
);
return
0
;
}
tsdbLoadBlockInfo
(
&
(
pch
->
readh
),
NULL
);
if
(
tsdbLoadBlockInfo
(
&
(
pch
->
readh
),
NULL
)
<
0
)
{
TSDB_RUNLOCK_TABLE
(
pIter
->
pTable
);
return
-
1
;
}
if
(
pIter
->
pIter
==
NULL
)
{
// No memory data but has disk data
// TODO
}
else
{
TSKEY
nextKey
=
tsdbNextIterKey
(
pIter
->
pIter
);
int
cidx
=
0
;
SBlock
*
pBlock
=
NULL
;
// Process merge commit
int
nBlocks
=
(
pch
->
readh
.
pBlkIdx
==
NULL
)
?
0
:
pch
->
readh
.
pBlkIdx
->
numOfBlocks
;
TSKEY
nextKey
=
tsdbNextIterKey
(
pIter
->
pIter
);
int
cidx
=
0
;
void
*
ptr
=
NULL
;
SBlock
*
pBlock
=
NULL
;
void
*
ptr
=
taosbsearch
((
void
*
)(
&
nextKey
),
pch
->
readh
.
pBlkInfo
->
blocks
,
pch
->
readh
.
pBlockIdx
->
numOfBlocks
,
sizeof
(
SBlock
),
tsdbComparKeyBlock
,
TD_GE
);
while
(
true
)
{
if
((
nextKey
==
TSDB_DATA_TIMESTAMP_NULL
||
nextKey
>
pch
->
maxKey
)
&&
(
cidx
>=
nBlocks
))
break
;
if
((
nextKey
==
TSDB_DATA_TIMESTAMP_NULL
||
nextKey
>
pch
->
maxKey
)
||
((
cidx
<
nBlocks
)
&&
(
!
pBlock
->
last
)
&&
tsdbComparKeyBlock
((
void
*
)(
&
nextKey
),
pBlock
)
>
0
))
{
// TODO: move the block
cidx
++
;
}
else
if
((
cidx
<
nBlocks
)
&&
(
pBlock
->
last
||
tsdbComparKeyBlock
((
void
*
)(
&
nextKey
),
pBlock
)
==
0
))
{
// TODO: process merge commit
cidx
++
;
}
else
{
if
(
pBlock
==
NULL
)
{
// commit memory data until pch->maxKey and write to the appropriate file
}
else
{
// commit memory data until pBlock->keyFirst and write to only data file
}
}
while
(
true
)
{
if
((
nextKey
==
TSDB_DATA_TIMESTAMP_NULL
||
nextKey
>
pch
->
maxKey
)
&&
(
cidx
>=
pch
->
readh
.
pBlockIdx
->
numOfBlocks
))
break
;
if
(
tsdbComparKeyBlock
((
void
*
)(
&
nextKey
),
pBlock
)
<
0
)
{
#if 0
if (/* Key end */) {
tsdbMoveBlock(); =============
} else {
if (/*block end*/) {
// process append commit until pch->maxKey >>>>>>>
} else {
if (pBlock->last) {
//
merge with the last block
//
TODO: merge the block ||||||||||||||||||||||
} else {
// Commit until pch->maxKey or (pBlock[1].keyFirst-1)
if (pBlock > nextKey) {
// process append commit until pBlock->keyFirst-1 >>>>>>
} else if (pBlock < nextKey) {
// tsdbMoveBlock() ============
} else {
// merge the block ||||||||||||
}
}
}
else
if
(
tsdbComparKeyBlock
((
void
*
)(
&
nextKey
),
pBlock
)
==
0
)
{
// merge the block
}
else
{
}
}
#endif
}
// if (pIter->pIter == NULL) {
// // No memory data but has disk data
// // TODO
// } else {
// TSKEY nextKey = tsdbNextIterKey(pIter->pIter);
// int cidx = 0;
// SBlock *pBlock = NULL;
// void *ptr = taosbsearch((void *)(&nextKey), pch->readh.pBlkInfo->blocks, pch->readh.pBlkIdx->numOfBlocks,
// sizeof(SBlock), tsdbComparKeyBlock, TD_GE);
// while (true) {
// if ((nextKey == TSDB_DATA_TIMESTAMP_NULL || nextKey > pch->maxKey) && (cidx >= pch->readh.pBlkIdx->numOfBlocks))
// break;
// if (tsdbComparKeyBlock((void *)(&nextKey), pBlock) < 0) {
// if (pBlock->last) {
// // merge with the last block
// } else {
// // Commit until pch->maxKey or (pBlock[1].keyFirst-1)
// }
// } else if (tsdbComparKeyBlock((void *)(&nextKey), pBlock) == 0) { // merge the block
// } else {
// }
// }
// }
TSDB_RUNLOCK_TABLE
(
pIter
->
pTable
);
tsdbWriteBlockInfo
(
pch
)
;
if
(
tsdbWriteBlockInfo
(
pch
)
<
0
)
return
-
1
;
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录