Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8c45b028
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
“131af1718fd02badc654da4e9c3ec24c51e55eed”上不存在“include/common/tglobal.h”
提交
8c45b028
编写于
7月 10, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
finish tsdb snapshot
上级
53a13db8
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
108 addition
and
48 deletion
+108
-48
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
+108
-48
未找到文件。
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
浏览文件 @
8c45b028
...
...
@@ -312,6 +312,9 @@ struct STsdbSnapWriter {
// config
int32_t
minutes
;
int8_t
precision
;
int32_t
minRow
;
int32_t
maxRow
;
int8_t
cmprAlg
;
// for data file
int32_t
fid
;
...
...
@@ -321,14 +324,18 @@ struct STsdbSnapWriter {
SBlockIdx
*
pBlockIdx
;
SMapData
mBlock
;
int32_t
iBlock
;
SBlock
*
pBlock
;
SBlock
block
;
SBlockData
blockData
;
int32_t
iRow
;
SDataFWriter
*
pDataFWriter
;
SArray
*
aBlockIdxN
;
SBlockIdx
*
pBlockIdxN
;
SBlockIdx
blockIdx
;
SMapData
mBlockN
;
SBlock
block
;
SBlock
*
pBlockN
;
SBlock
blockN
;
SBlockData
nBlockData
;
// for del file
...
...
@@ -394,17 +401,112 @@ _err:
return
code
;
}
static
int32_t
tsdbSnapWriteTableData
(
STsdbSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
)
{
static
int32_t
tsdbSnapWriteTableData
End
(
STsdbSnapWriter
*
pWrite
)
{
int32_t
code
=
0
;
// TODO
return
code
;
}
static
int32_t
tsdbSnapWriteTableData
(
STsdbSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
)
{
int32_t
code
=
0
;
TABLEID
id
=
{
0
};
// TODO
// skip
while
(
pWriter
->
pBlockIdx
&&
tTABLEIDCmprFn
(
&
id
,
pWriter
->
pBlockIdx
)
<
0
)
{
code
=
tsdbSnapWriteTableDataEnd
(
pWriter
);
if
(
code
)
goto
_err
;
pWriter
->
iBlockIdx
++
;
if
(
pWriter
->
iBlockIdx
<
taosArrayGetSize
(
pWriter
->
aBlockIdx
))
{
pWriter
->
pBlockIdx
=
(
SBlockIdx
*
)
taosArrayGet
(
pWriter
->
aBlockIdx
,
pWriter
->
iBlockIdx
);
}
else
{
pWriter
->
pBlockIdx
=
NULL
;
}
}
// new or merge
if
(
pWriter
->
pBlockIdx
==
NULL
||
tTABLEIDCmprFn
(
&
id
,
pWriter
->
pBlockIdx
)
<
0
)
{
int32_t
c
;
if
(
pWriter
->
pBlockIdxN
&&
((
c
=
tTABLEIDCmprFn
(
&
id
,
pWriter
->
pBlockIdxN
))
!=
0
))
{
ASSERT
(
c
>
0
);
code
=
tsdbSnapWriteTableDataEnd
(
pWriter
);
if
(
code
)
goto
_err
;
}
if
(
pWriter
->
pBlockIdxN
==
NULL
)
{
pWriter
->
pBlockIdx
=
&
pWriter
->
blockIdx
;
pWriter
->
pBlockIdx
->
suid
=
id
.
suid
;
pWriter
->
pBlockIdx
->
uid
=
id
.
uid
;
}
// loop to write the data
TSDBROW
*
pRow
=
NULL
;
// todo
int32_t
nRow
=
0
;
// todo
SBlockData
*
pBlockData
=
NULL
;
// todo
for
(
int32_t
iRow
=
0
;
iRow
<
nRow
;
iRow
++
)
{
code
=
tBlockDataAppendRow
(
&
pWriter
->
nBlockData
,
&
tsdbRowFromBlockData
(
pBlockData
,
iRow
),
NULL
);
if
(
code
)
goto
_err
;
if
(
pWriter
->
nBlockData
.
nRow
>
pWriter
->
maxRow
*
4
/
5
)
{
code
=
tsdbWriteBlockData
(
pWriter
->
pDataFWriter
,
&
pWriter
->
nBlockData
,
NULL
,
NULL
,
pWriter
->
pBlockIdxN
,
pWriter
->
pBlockN
,
pWriter
->
cmprAlg
);
if
(
code
)
goto
_err
;
}
}
}
else
{
// skip
while
(
true
)
{
if
(
pWriter
->
pBlock
==
NULL
)
break
;
if
(
pWriter
->
pBlock
->
last
)
break
;
if
(
tBlockCmprFn
(
&
(
SBlock
){.
minKey
=
{
0
},
.
maxKey
=
{
0
}},
pWriter
->
pBlock
)
>=
0
)
break
;
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockN
,
pWriter
->
pBlock
,
tPutBlock
);
if
(
code
)
goto
_err
;
}
if
(
pWriter
->
pBlock
)
{
if
(
pWriter
->
pBlock
->
last
)
{
// load the last block and merge with the data (todo)
}
else
{
int32_t
c
=
tBlockCmprFn
(
&
(
SBlock
){
/*TODO*/
},
pWriter
->
pBlock
);
if
(
c
>
0
)
{
// commit until pWriter->pBlock (todo)
}
else
{
// load the block and merge with the data (todo)
}
}
}
else
{
int32_t
nRow
=
0
;
SBlockData
*
pBlockData
=
NULL
;
for
(
int32_t
iRow
=
0
;
iRow
<
nRow
;
iRow
++
)
{
code
=
tBlockDataAppendRow
(
&
pWriter
->
nBlockData
,
&
tsdbRowFromBlockData
(
pBlockData
,
iRow
),
NULL
);
if
(
code
)
goto
_err
;
if
(
pWriter
->
nBlockData
.
nRow
>=
pWriter
->
maxRow
*
4
/
5
)
{
code
=
tsdbWriteBlockData
(
pWriter
->
pDataFWriter
,
&
pWriter
->
nBlockData
,
NULL
,
NULL
,
pWriter
->
pBlockIdxN
,
pWriter
->
pBlockN
,
pWriter
->
cmprAlg
);
if
(
code
)
goto
_err
;
tBlockDataClearData
(
&
pWriter
->
nBlockData
);
}
}
}
}
return
code
;
_err:
tsdbError
(
"vgId:%d tsdb snapshot write table data failed since %s"
,
TD_VID
(
pWriter
->
pTsdb
->
pVnode
),
tstrerror
(
code
));
return
code
;
}
static
int32_t
tsdbSnapWriteData
(
STsdbSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
)
{
int32_t
code
=
0
;
STsdb
*
pTsdb
=
pWriter
->
pTsdb
;
int64_t
suid
=
0
;
// todo
int64_t
uid
=
0
;
// todo
int64_t
skey
;
// todo
int64_t
ekey
;
// todo
...
...
@@ -449,48 +551,6 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3
code
=
tsdbSnapWriteTableData
(
pWriter
,
pData
,
nData
);
if
(
code
)
goto
_err
;
// // process
// TABLEID id = {0}; // TODO
// TSKEY minKey = 0; // TODO
// TSKEY maxKey = 0; // TODO
// while (true) {
// if (pWriter->pBlockIdx) {
// int32_t c = tTABLEIDCmprFn(&id, pWriter->pBlockIdx);
// if (c == 0) {
// } else if (c < 0) {
// // keep merge
// } else {
// // code = tsdbSnapWriteTableDataEnd(pWriter);
// if (code) goto _err;
// pWriter->iBlockIdx++;
// if (pWriter->iBlockIdx < taosArrayGetSize(pWriter->aBlockIdx)) {
// pWriter->pBlockIdx = (SBlockIdx*)taosArrayGet(pWriter->aBlockIdx, pWriter->iBlockIdx);
// } else {
// pWriter->pBlockIdx = NULL;
// }
// if (pWriter->pBlockIdx) {
// code = tsdbReadBlock(pWriter->pDataFReader, pWriter->pBlockIdx, &pWriter->mBlock, NULL);
// if (code) goto _err;
// }
// }
// } else {
// int32_t c = tTABLEIDCmprFn(&id, &pWriter->blockIdx);
// if (c == 0) {
// // merge commit the block data
// } else if (c > 0) {
// // code = tsdbSnapWriteTableDataEnd(pWriter);
// if (code) goto _err;
// } else {
// ASSERT(0);
// }
// }
// }
return
code
;
_err:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录