Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b977626a
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b977626a
编写于
8月 23, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
f43bae0d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
137 deletion
+27
-137
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+27
-137
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
b977626a
...
...
@@ -778,160 +778,51 @@ _err:
return
code
;
}
static
int32_t
tsdbMergeCommitLast
(
SCommitter
*
pCommitter
,
STbDataIter
*
pIter
)
{
int32_t
code
=
0
;
#if 0
STbData *pTbData = pIter->pTbData;
int32_t nRow = tsdbGetNumOfRowsLessThan(pIter, (TSDBKEY){.ts = pCommitter->maxKey + 1, .version = VERSION_MIN});
if (pCommitter->dReader.pRowInfo && tTABLEIDCmprFn(pTbData, pCommitter->dReader.pRowInfo) == 0) {
if (pCommitter->dReader.pRowInfo->suid) { // super table
for (int32_t iRow = pCommitter->dReader.iRow; iRow < pCommitter->dReader.bDatal.nRow; iRow++) {
if (pTbData->uid != pCommitter->dReader.bDatal.aUid[iRow]) break;
nRow++;
}
} else { // normal table
ASSERT(pCommitter->dReader.iRow == 0);
nRow += pCommitter->dReader.bDatal.nRow;
}
}
if (nRow == 0) goto _exit;
static
int32_t
tsdbCommitLastFile
(
SCommitter
*
pCommitter
,
STbDataIter
*
pIter
)
{
int32_t
code
=
0
;
STbData
*
pTbData
=
pIter
->
pTbData
;
SBlockData
*
pBlockData
=
&
pCommitter
->
dWriter
.
bDatal
;
TSDBROW
*
pRow
=
tsdbTbDataIterGet
(
pIter
);
TSDBROW *pRow = tsdbTbDataIterGet(pIter);
if
(
pRow
&&
TSDBROW_TS
(
pRow
)
>
pCommitter
->
maxKey
)
{
pRow
=
NULL
;
}
SRowInfo *pRowInfo = pCommitter->dReader.pRowInfo;
if (pRowInfo && pRowInfo->uid != pTbData->uid) {
pRowInfo = NULL;
}
while (nRow) {
SBlockData *pBlockData;
int8_t toData;
if (nRow < pCommitter->minRow) { // to .last
toData = 0;
pBlockData = &pCommitter->dWriter.bDatal;
// commit and reset block data schema if need
// QUESTION: Is there a case that pBlockData->nRow == 0 but need to change schema ?
if (pBlockData->suid || pBlockData->uid) {
if (pBlockData->suid != pTbData->suid || pBlockData->suid == 0) {
if (pBlockData->nRow > 0) {
code = tsdbCommitLastBlock(pCommitter);
if (code) goto _err;
}
tBlockDataReset(pBlockData);
}
}
// set block data schema if need
if (pBlockData->suid == 0 && pBlockData->uid == 0) {
code =
tBlockDataInit(pBlockData, pTbData->suid, pTbData->suid ? 0 : pTbData->uid, pCommitter->skmTable.pTSchema);
if (code) goto _err;
}
if
(
pRow
==
NULL
)
goto
_exit
;
if (pBlockData->nRow + nRow > pCommitter->maxRow) {
if
(
pBlockData
->
suid
||
pBlockData
->
uid
)
{
if
(
pBlockData
->
suid
!=
pTbData
->
suid
||
pBlockData
->
suid
==
0
)
{
if
(
pBlockData
->
nRow
>
0
)
{
code
=
tsdbCommitLastBlock
(
pCommitter
);
if
(
code
)
goto
_err
;
}
} else { // to .data
toData = 1;
pBlockData = &pCommitter->dWriter.bData;
ASSERT(pBlockData->nRow == 0);
}
while (pRow && pRowInfo) {
int32_t c = tsdbRowCmprFn(pRow, &pRowInfo->row);
if (c < 0) {
code = tsdbCommitterUpdateRowSchema(pCommitter, pTbData->suid, pTbData->uid, TSDBROW_SVERSION(pRow));
if (code) goto _err;
code = tBlockDataAppendRow(pBlockData, pRow, pCommitter->skmRow.pTSchema, pTbData->uid);
if (code) goto _err;
tsdbTbDataIterNext(pIter);
pRow = tsdbTbDataIterGet(pIter);
if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) {
pRow = NULL;
}
} else if (c > 0) {
code = tBlockDataAppendRow(pBlockData, &pRowInfo->row, NULL, pTbData->uid);
if (code) goto _err;
code = tsdbCommitterNextLastRow(pCommitter);
if (code) goto _err;
pRowInfo = pCommitter->dReader.pRowInfo;
if (pRowInfo && pRowInfo->uid != pTbData->uid) {
pRowInfo = NULL;
}
} else {
ASSERT(0);
}
nRow--;
if (toData) {
if (nRow == 0 || pBlockData->nRow >= pCommitter->maxRow * 4 / 5) {
code = tsdbCommitDataBlock(pCommitter, NULL);
if (code) goto _err;
goto _outer_break;
}
}
tBlockDataReset
(
pBlockData
);
}
}
while (pRow) {
code = tsdbCommitterUpdateRowSchema(pCommitter, pTbData->suid, pTbData->uid, TSDBROW_SVERSION(pRow));
if (code) goto _err;
if
(
!
pBlockData
->
suid
&&
!
pBlockData
->
uid
)
{
code
=
tBlockDataInit
(
pBlockData
,
pTbData
->
suid
,
pTbData
->
uid
,
pCommitter
->
skmTable
.
pTSchema
);
if
(
code
)
goto
_err
;
}
code = tBlockDataAppendRow(pBlockData, pRow, pCommitter->skmRow.pTSchema, pTbData->uid);
if (code) goto _err;
while
(
pRow
)
{
code
=
tsdbCommitterUpdateRowSchema
(
pCommitter
,
pTbData
->
suid
,
pTbData
->
uid
,
TSDBROW_SVERSION
(
pRow
));
if
(
code
)
goto
_err
;
tsdbTbDataIterNext(pIter);
pRow = tsdbTbDataIterGet(pIter);
if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) {
pRow = NULL;
}
code
=
tBlockDataAppendRow
(
pBlockData
,
pRow
,
pCommitter
->
skmRow
.
pTSchema
,
pTbData
->
uid
);
if
(
code
)
goto
_err
;
nRow--;
if (toData) {
if (nRow == 0 || pBlockData->nRow >= pCommitter->maxRow * 4 / 5) {
code = tsdbCommitDataBlock(pCommitter, NULL);
if (code) goto _err;
goto _outer_break;
}
}
tsdbTbDataIterNext
(
pIter
);
pRow
=
tsdbTbDataIterGet
(
pIter
);
if
(
pRow
&&
TSDBROW_TS
(
pRow
)
>
pCommitter
->
maxKey
)
{
pRow
=
NULL
;
}
while (pRowInfo
) {
code = t
BlockDataAppendRow(pBlockData, &pRowInfo->row, NULL, pTbData->uid
);
if
(
pBlockData
->
nRow
>=
pCommitter
->
maxRow
)
{
code
=
t
sdbCommitLastBlock
(
pCommitter
);
if
(
code
)
goto
_err
;
code = tsdbCommitterNextLastRow(pCommitter);
if (code) goto _err;
pRowInfo = pCommitter->dReader.pRowInfo;
if (pRowInfo && pRowInfo->uid != pTbData->uid) {
pRowInfo = NULL;
}
nRow--;
if (toData) {
if (nRow == 0 || pBlockData->nRow >= pCommitter->maxRow * 4 / 5) {
code = tsdbCommitDataBlock(pCommitter, NULL);
if (code) goto _err;
goto _outer_break;
}
}
}
_outer_break:
ASSERT(nRow >= 0);
}
_exit:
...
...
@@ -939,7 +830,6 @@ _exit:
_err:
tsdbError
(
"vgId:%d tsdb merge commit last failed since %s"
,
TD_VID
(
pCommitter
->
pTsdb
->
pVnode
),
tstrerror
(
code
));
#endif
return
code
;
}
...
...
@@ -1061,7 +951,7 @@ static int32_t tsdbCommitTableData(SCommitter *pCommitter, STbData *pTbData) {
if
(
code
)
goto
_err
;
// commit last
code
=
tsdb
MergeCommitLast
(
pCommitter
,
&
iter
);
code
=
tsdb
CommitLastFile
(
pCommitter
,
&
iter
);
if
(
code
)
goto
_err
;
_exit:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录