Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b2781802
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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,发现更多精彩内容 >>
提交
b2781802
编写于
6月 27, 2022
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feat/tsdb_refact' of
https://github.com/taosdata/TDengine
into feat/tsdb_refact
上级
d262ca1b
38b7cfe1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
131 addition
and
4 deletion
+131
-4
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+131
-4
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
b2781802
...
...
@@ -729,9 +729,29 @@ _err:
return
code
;
}
static
int32_t
tsdbCommit
MoveDiskBlock
(
SCommitter
*
pCommitter
,
SBlock
*
pBlock
)
{
static
int32_t
tsdbCommit
TableDiskData
(
SCommitter
*
pCommitter
,
SBlock
*
pBlock
)
{
int32_t
code
=
0
;
// TODO
if
(
pBlock
->
last
)
{
// TODO
code
=
tsdbReadBlockData
(
pCommitter
->
pReader
,
NULL
,
pBlock
,
&
pCommitter
->
oBlockData
,
NULL
,
NULL
);
if
(
code
)
goto
_err
;
code
=
tsdbWriteBlockData
(
pCommitter
->
pWriter
,
&
pCommitter
->
oBlockData
,
NULL
,
NULL
,
NULL
,
NULL
,
pCommitter
->
cmprAlg
);
if
(
code
)
goto
_err
;
code
=
tMapDataPutItem
(
&
pCommitter
->
nBlockMap
,
&
pCommitter
->
nBlock
,
tPutBlock
);
if
(
code
)
goto
_err
;
}
else
{
code
=
tMapDataPutItem
(
&
pCommitter
->
nBlockMap
,
pBlock
,
tPutBlock
);
if
(
code
)
goto
_err
;
}
return
code
;
_err:
tsdbError
(
"vgId:%d tsdb commit table disk data failed since %s"
,
TD_VID
(
pCommitter
->
pTsdb
->
pVnode
),
tstrerror
(
code
));
return
code
;
}
...
...
@@ -789,7 +809,7 @@ static int32_t tsdbMergeMemDisk(SCommitter *pCommitter, STbData *pTbData, SBlock
pRow
=
tsdbTbDataIterGet
(
pIter
);
}
else
if
(
c
>
0
)
{
// just move the block (todo)
code
=
tsdbCommit
MoveDiskBlock
(
pCommitter
,
pBlock
);
code
=
tsdbCommit
TableDiskData
(
pCommitter
,
pBlock
);
if
(
code
)
goto
_err
;
iBlock
++
;
...
...
@@ -815,7 +835,7 @@ static int32_t tsdbMergeMemDisk(SCommitter *pCommitter, STbData *pTbData, SBlock
}
}
}
else
if
(
pBlock
)
{
code
=
tsdbCommit
MoveDiskBlock
(
pCommitter
,
pBlock
);
code
=
tsdbCommit
TableDiskData
(
pCommitter
,
pBlock
);
if
(
code
)
goto
_err
;
iBlock
++
;
...
...
@@ -851,6 +871,113 @@ _err:
return
code
;
}
static
int32_t
tsdbCommitTableData
(
SCommitter
*
pCommitter
,
STbData
*
pTbData
,
SBlockIdx
*
pBlockIdx
)
{
int32_t
code
=
0
;
STbDataIter
*
pIter
=
&
(
STbDataIter
){
0
};
TSDBROW
*
pRow
;
int32_t
iBlock
=
0
;
int32_t
nBlock
;
if
(
pTbData
)
{
tsdbTbDataIterOpen
(
pTbData
,
&
(
TSDBKEY
){.
ts
=
pCommitter
->
minKey
,
.
version
=
VERSION_MIN
},
0
,
pIter
);
pRow
=
tsdbTbDataIterGet
(
pIter
);
}
else
{
pIter
=
NULL
;
pRow
=
NULL
;
}
if
(
pBlockIdx
)
{
code
=
tsdbReadBlock
(
pCommitter
->
pReader
,
pBlockIdx
,
&
pCommitter
->
oBlockMap
,
NULL
);
if
(
code
)
goto
_err
;
nBlock
=
pCommitter
->
oBlockMap
.
nItem
;
ASSERT
(
nBlock
>
0
);
}
else
{
nBlock
=
0
;
}
if
((
pRow
==
NULL
||
TSDBROW_TS
(
pRow
)
>
pCommitter
->
maxKey
)
&&
nBlock
==
0
)
goto
_exit
;
// start ===========
tMapDataReset
(
&
pCommitter
->
nBlockMap
);
SBlock
*
pBlock
=
NULL
;
// (todo)
int32_t
c
;
// merge ===========
while
(
true
)
{
if
(((
pRow
==
NULL
)
||
TSDBROW_TS
(
pRow
)
>
pCommitter
->
maxKey
)
&&
pBlock
==
NULL
)
break
;
if
(
pRow
&&
TSDBROW_TS
(
pRow
)
<=
pCommitter
->
maxKey
&&
pBlock
)
{
if
(
pBlock
->
last
)
{
code
=
tsdbMergeBlockAndMem
(
pCommitter
,
pIter
,
pBlockIdx
,
pBlock
,
(
TSDBKEY
){.
ts
=
pCommitter
->
maxKey
+
1
,
.
version
=
VERSION_MIN
},
0
);
if
(
code
)
goto
_err
;
pRow
=
tsdbTbDataIterGet
(
pIter
);
iBlock
++
;
}
else
{
c
=
tBlockCmprFn
(
&
(
SBlock
){},
pBlock
);
if
(
c
>
0
)
{
code
=
tsdbCommitTableDiskData
(
pCommitter
,
pBlock
);
if
(
code
)
goto
_err
;
iBlock
++
;
}
else
if
(
c
<
0
)
{
code
=
tsdbCommitMemoryDataImpl
(
pCommitter
,
pIter
,
pBlock
->
minKey
,
1
);
if
(
code
)
goto
_err
;
pRow
=
tsdbTbDataIterGet
(
pIter
);
}
else
{
int64_t
nOvlp
=
0
;
// (todo)
if
(
pBlock
->
nRow
+
nOvlp
<=
pCommitter
->
maxRow
&&
pBlock
->
nSubBlock
<
TSDB_MAX_SUBBLOCKS
)
{
// add as a subblock
}
else
{
if
(
iBlock
==
nBlock
-
1
)
{
code
=
tsdbMergeBlockAndMem
(
pCommitter
,
pIter
,
pBlockIdx
,
pBlock
,
(
TSDBKEY
){.
ts
=
pCommitter
->
maxKey
+
1
,
.
version
=
VERSION_MIN
},
0
);
if
(
code
)
goto
_err
;
}
else
{
// code = tsdbMergeBlockAndMem(pCommitter, pIter, pBlockIdx, pBlock, pBlock[1].minKey, 1);
if
(
code
)
goto
_err
;
}
}
}
}
}
else
if
(
pBlock
)
{
code
=
tsdbCommitTableDiskData
(
pCommitter
,
pBlock
);
if
(
code
)
goto
_err
;
// move to next block (todo)
}
else
{
code
=
tsdbCommitMemoryDataImpl
(
pCommitter
,
pIter
,
(
TSDBKEY
){.
ts
=
pCommitter
->
maxKey
+
1
,
.
version
=
VERSION_MIN
},
0
);
if
(
code
)
goto
_err
;
pRow
=
tsdbTbDataIterGet
(
pIter
);
ASSERT
(
pRow
==
NULL
||
TSDBROW_TS
(
pRow
)
>
pCommitter
->
maxKey
);
}
}
// end
// code = tsdbWriteBlock();
if
(
code
)
goto
_err
;
code
=
tMapDataPutItem
(
&
pCommitter
->
nBlockIdxMap
,
NULL
,
tPutBlockIdx
);
if
(
code
)
goto
_err
;
_exit:
if
(
pIter
)
{
pRow
=
tsdbTbDataIterGet
(
pIter
);
if
(
pRow
)
pCommitter
->
nextKey
=
TMIN
(
pCommitter
->
nextKey
,
TSDBROW_TS
(
pRow
));
}
return
code
;
_err:
tsdbError
(
"vgId:%d tsdb commit table data failed since %s"
,
TD_VID
(
pCommitter
->
pTsdb
->
pVnode
),
tstrerror
(
code
));
return
code
;
}
static
int32_t
tsdbCommitFileDataImpl
(
SCommitter
*
pCommitter
)
{
int32_t
code
=
0
;
int32_t
c
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录