Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
de97c925
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看板
提交
de97c925
编写于
8月 19, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make it compile
上级
98bc07bb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
64 addition
and
85 deletion
+64
-85
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
+64
-85
未找到文件。
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
浏览文件 @
de97c925
...
...
@@ -439,26 +439,6 @@ struct STsdbSnapWriter {
SArray
*
aDelIdxW
;
};
#if 0
static int32_t tsdbSnapWriteAppendData(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
int32_t code = 0;
int32_t iRow = 0; // todo
int32_t nRow = 0; // todo
SBlockData* pBlockData = NULL; // todo
while (iRow < nRow) {
code = tBlockDataAppendRow(&pWriter->bDataW, &tsdbRowFromBlockData(pBlockData, iRow), NULL);
if (code) goto _err;
}
return code;
_err:
tsdbError("vgId:%d, tsdb snapshot write append data for %s failed since %s", TD_VID(pWriter->pTsdb->pVnode),
pWriter->pTsdb->path, tstrerror(code));
return code;
}
static
int32_t
tsdbSnapWriteTableDataEnd
(
STsdbSnapWriter
*
pWriter
)
{
int32_t
code
=
0
;
...
...
@@ -470,13 +450,14 @@ static int32_t tsdbSnapWriteTableDataEnd(STsdbSnapWriter* pWriter) {
if
(
pWriter
->
pBlockData
)
{
ASSERT
(
pWriter
->
iRow
<
pWriter
->
pBlockData
->
nRow
);
while
(
pWriter
->
iRow
<
pWriter
->
pBlockData
->
nRow
)
{
code = tBlockDataAppendRow(&pWriter->bDataW, &tsdbRowFromBlockData(pWriter->pBlockData, pWriter->iRow), NULL);
code
=
tBlockDataAppendRow
(
&
pWriter
->
bDataW
,
&
tsdbRowFromBlockData
(
pWriter
->
pBlockData
,
pWriter
->
iRow
),
NULL
,
0
);
// todo
if
(
code
)
goto
_err
;
if
(
pWriter
->
bDataW
.
nRow
>=
pWriter
->
maxRow
*
4
/
5
)
{
pWriter->blockW.last = 0;
code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataW, NULL, NULL, pWriter->pBlockIdxW,
&pWriter->blockW, pWriter->cmprAlg);
//
pWriter->blockW.last = 0;
//
code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataW, NULL, NULL, pWriter->pBlockIdxW,
//
&pWriter->blockW, pWriter->cmprAlg);
if
(
code
)
goto
_err
;
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
pWriter
->
blockW
,
tPutBlock
);
...
...
@@ -492,16 +473,16 @@ static int32_t tsdbSnapWriteTableDataEnd(STsdbSnapWriter* pWriter) {
// write remain data if has
if
(
pWriter
->
bDataW
.
nRow
>
0
)
{
pWriter->blockW.last = 0;
//
pWriter->blockW.last = 0;
if
(
pWriter
->
bDataW
.
nRow
<
pWriter
->
minRow
)
{
if
(
pWriter
->
iBlock
>
pWriter
->
mBlock
.
nItem
)
{
pWriter->blockW.last = 1;
//
pWriter->blockW.last = 1;
}
}
code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataW, NULL, NULL, pWriter->pBlockIdxW,
&pWriter->blockW, pWriter->cmprAlg);
if (code) goto _err;
//
code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataW, NULL, NULL, pWriter->pBlockIdxW,
//
&pWriter->blockW, pWriter->cmprAlg);
//
if (code) goto _err;
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
pWriter
->
blockW
,
tPutBlock
);
if
(
code
)
goto
_err
;
...
...
@@ -513,16 +494,16 @@ static int32_t tsdbSnapWriteTableDataEnd(STsdbSnapWriter* pWriter) {
SBlock
block
;
tMapDataGetItemByIdx
(
&
pWriter
->
mBlock
,
pWriter
->
iBlock
,
&
block
,
tGetBlock
);
if (block.last) {
code = tsdbReadBlockData(pWriter->pDataFReader, pWriter->pBlockIdx, &block, &pWriter->bDataR, NULL, NULL);
if (code) goto _err;
//
if (block.last) {
//
code = tsdbReadBlockData(pWriter->pDataFReader, pWriter->pBlockIdx, &block, &pWriter->bDataR, NULL, NULL);
//
if (code) goto _err;
tBlockReset(&block);
block.last = 1;
code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataR, NULL, NULL, pWriter->pBlockIdxW, &block,
pWriter->cmprAlg);
if (code) goto _err;
}
//
tBlockReset(&block);
//
block.last = 1;
//
code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataR, NULL, NULL, pWriter->pBlockIdxW, &block,
//
pWriter->cmprAlg);
//
if (code) goto _err;
//
}
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
block
,
tPutBlock
);
if
(
code
)
goto
_err
;
...
...
@@ -531,8 +512,8 @@ static int32_t tsdbSnapWriteTableDataEnd(STsdbSnapWriter* pWriter) {
}
// SBlock
code = tsdbWriteBlock(pWriter->pDataFWriter, &pWriter->mBlockW, NULL, pWriter->pBlockIdxW);
if (code) goto _err;
//
code = tsdbWriteBlock(pWriter->pDataFWriter, &pWriter->mBlockW, NULL, pWriter->pBlockIdxW);
//
if (code) goto _err;
// SBlockIdx
if
(
taosArrayPush
(
pWriter
->
aBlockIdxW
,
pWriter
->
pBlockIdxW
)
==
NULL
)
{
...
...
@@ -562,16 +543,17 @@ static int32_t tsdbSnapMoveWriteTableData(STsdbSnapWriter* pWriter, SBlockIdx* p
for
(
int32_t
iBlock
=
0
;
iBlock
<
pWriter
->
mBlock
.
nItem
;
iBlock
++
)
{
tMapDataGetItemByIdx
(
&
pWriter
->
mBlock
,
iBlock
,
&
block
,
tGetBlock
);
if (block.last) {
code = tsdbReadBlockData(pWriter->pDataFReader, pBlockIdx, &block, &pWriter->bDataR, NULL, NULL);
if (code) goto _err;
//
if (block.last) {
//
code = tsdbReadBlockData(pWriter->pDataFReader, pBlockIdx, &block, &pWriter->bDataR, NULL, NULL);
//
if (code) goto _err;
tBlockReset(&block);
block.last = 1;
code =
tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataR, NULL, NULL, pBlockIdx, &block, pWriter->cmprAlg);
if (code) goto _err;
}
// tBlockReset(&block);
// block.last = 1;
// code =
// tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataR, NULL, NULL, pBlockIdx, &block,
// pWriter->cmprAlg);
// if (code) goto _err;
// }
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
block
,
tPutBlock
);
if
(
code
)
goto
_err
;
...
...
@@ -579,7 +561,7 @@ static int32_t tsdbSnapMoveWriteTableData(STsdbSnapWriter* pWriter, SBlockIdx* p
// SBlock
SBlockIdx
blockIdx
=
{.
suid
=
pBlockIdx
->
suid
,
.
uid
=
pBlockIdx
->
uid
};
code = tsdbWriteBlock(pWriter->pDataFWriter, &pWriter->mBlockW,
NULL,
&blockIdx);
code
=
tsdbWriteBlock
(
pWriter
->
pDataFWriter
,
&
pWriter
->
mBlockW
,
&
blockIdx
);
if
(
code
)
goto
_err
;
// SBlockIdx
...
...
@@ -604,9 +586,9 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) {
TSDBROW
row
;
TSDBROW
*
pRow
=
&
row
;
// correct schema
code = tBlockDataCorrectSchema(&pWriter->bDataW, pBlockData);
if (code) goto _err;
//
//
correct schema
//
code = tBlockDataCorrectSchema(&pWriter->bDataW, pBlockData);
//
if (code) goto _err;
// loop to merge
*
pRow
=
tsdbRowFromBlockData
(
pBlockData
,
iRow
);
...
...
@@ -621,8 +603,8 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) {
ASSERT
(
c
);
if
(
c
<
0
)
{
code = tBlockDataAppendRow(&pWriter->bDataW, pRow, NULL);
if (code) goto _err;
//
code = tBlockDataAppendRow(&pWriter->bDataW, pRow, NULL);
//
if (code) goto _err;
iRow
++
;
if
(
iRow
<
pWriter
->
pBlockData
->
nRow
)
{
...
...
@@ -631,8 +613,8 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) {
pRow
=
NULL
;
}
}
else
if
(
c
>
0
)
{
code = tBlockDataAppendRow(&pWriter->bDataW, &tsdbRowFromBlockData(pWriter->pBlockData, pWriter->iRow), NULL);
if (code) goto _err;
// code = tBlockDataAppendRow(&pWriter->bDataW, &tsdbRowFromBlockData(pWriter->pBlockData, pWriter->iRow),
// NULL);
if (code) goto _err;
pWriter
->
iRow
++
;
if
(
pWriter
->
iRow
>=
pWriter
->
pBlockData
->
nRow
)
{
...
...
@@ -650,16 +632,15 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) {
tMapDataGetItemByIdx
(
&
pWriter
->
mBlock
,
pWriter
->
iBlock
,
&
block
,
tGetBlock
);
if (block.last) {
pWriter->pBlockData = &pWriter->bDataR;
//
if (block.last) {
//
pWriter->pBlockData = &pWriter->bDataR;
code = tsdbReadBlockData(pWriter->pDataFReader, pWriter->pBlockIdx, &block, pWriter->pBlockData, NULL, NULL);
if (code) goto _err;
pWriter->iRow = 0;
// code = tsdbReadBlockData(pWriter->pDataFReader, pWriter->pBlockIdx, &block, pWriter->pBlockData, NULL,
// NULL); if (code) goto _err; pWriter->iRow = 0;
pWriter->iBlock++;
break;
}
//
pWriter->iBlock++;
//
break;
//
}
c
=
tsdbKeyCmprFn
(
&
block
.
maxKey
,
&
key
);
...
...
@@ -667,10 +648,10 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) {
if
(
c
<
0
)
{
if
(
pWriter
->
bDataW
.
nRow
)
{
pWriter->blockW.last = 0;
code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataW, NULL, NULL, pWriter->pBlockIdxW,
&pWriter->blockW, pWriter->cmprAlg);
if (code) goto _err;
//
pWriter->blockW.last = 0;
//
code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataW, NULL, NULL, pWriter->pBlockIdxW,
//
&pWriter->blockW, pWriter->cmprAlg);
//
if (code) goto _err;
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
pWriter
->
blockW
,
tPutBlock
);
if
(
code
)
goto
_err
;
...
...
@@ -690,9 +671,10 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) {
if
(
c
>
0
)
{
pWriter
->
pBlockData
=
&
pWriter
->
bDataR
;
code =
tsdbReadBlockData(pWriter->pDataFReader, pWriter->pBlockIdx, &block, pWriter->pBlockData, NULL, NULL);
if (code) goto _err;
// code =
// tsdbReadBlockData(pWriter->pDataFReader, pWriter->pBlockIdx, &block, pWriter->pBlockData, NULL,
// NULL);
// if (code) goto _err;
pWriter
->
iRow
=
0
;
pWriter
->
iBlock
++
;
...
...
@@ -703,8 +685,8 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) {
if
(
pWriter
->
pBlockData
)
continue
;
code = tBlockDataAppendRow(&pWriter->bDataW, pRow, NULL);
if (code) goto _err;
//
code = tBlockDataAppendRow(&pWriter->bDataW, pRow, NULL);
//
if (code) goto _err;
iRow
++
;
if
(
iRow
<
pBlockData
->
nRow
)
{
...
...
@@ -718,9 +700,9 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) {
if
(
pWriter
->
bDataW
.
nRow
<
pWriter
->
maxRow
*
4
/
5
)
continue
;
_write_block:
code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataW, NULL, NULL, pWriter->pBlockIdxW,
&pWriter->blockW, pWriter->cmprAlg);
if (code) goto _err;
//
code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataW, NULL, NULL, pWriter->pBlockIdxW,
//
&pWriter->blockW, pWriter->cmprAlg);
//
if (code) goto _err;
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
pWriter
->
blockW
,
tPutBlock
);
if
(
code
)
goto
_err
;
...
...
@@ -876,8 +858,8 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3
// decode
SBlockData
*
pBlockData
=
&
pWriter
->
bData
;
n = tGetBlockData(pData + sizeof(SSnapDataHdr) + sizeof(TABLEID), pBlockData);
ASSERT(n + sizeof(SSnapDataHdr) + sizeof(TABLEID) == nData);
//
n = tGetBlockData(pData + sizeof(SSnapDataHdr) + sizeof(TABLEID), pBlockData);
//
ASSERT(n + sizeof(SSnapDataHdr) + sizeof(TABLEID) == nData);
// open file
TSDBKEY
keyFirst
=
tBlockDataFirstKey
(
pBlockData
);
...
...
@@ -922,16 +904,16 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3
if
(
pSet
)
{
wSet
.
diskId
=
pSet
->
diskId
;
wSet
.
fid
=
fid
;
fHead = (SHeadFile){.commitID = pWriter->commitID, .offset = 0, .size = 0, .
l
offset = 0};
fHead
=
(
SHeadFile
){.
commitID
=
pWriter
->
commitID
,
.
offset
=
0
,
.
size
=
0
,
.
offset
=
0
};
fData
=
*
pSet
->
pDataF
;
fLast
=
(
SLastFile
){.
commitID
=
pWriter
->
commitID
,
.
size
=
0
};
fSma
=
*
pSet
->
pSmaF
;
}
else
{
wSet
.
diskId
=
(
SDiskID
){.
level
=
0
,
.
id
=
0
};
wSet
.
fid
=
fid
;
fHead = (SHeadFile){.commitID = pWriter->commitID, .offset = 0, .size = 0
, .loffset = 0
};
fHead
=
(
SHeadFile
){.
commitID
=
pWriter
->
commitID
,
.
offset
=
0
,
.
size
=
0
};
fData
=
(
SDataFile
){.
commitID
=
pWriter
->
commitID
,
.
size
=
0
};
fLast = (SLastFile){.commitID = pWriter->commitID, .size = 0};
fLast
=
(
SLastFile
){.
commitID
=
pWriter
->
commitID
,
.
size
=
0
,
.
offset
=
0
};
fSma
=
(
SSmaFile
){.
commitID
=
pWriter
->
commitID
,
.
size
=
0
};
}
...
...
@@ -956,7 +938,6 @@ _err:
tstrerror
(
code
));
return
code
;
}
#endif
static
int32_t
tsdbSnapWriteDel
(
STsdbSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
)
{
int32_t
code
=
0
;
...
...
@@ -1206,7 +1187,6 @@ int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData)
int32_t
code
=
0
;
SSnapDataHdr
*
pHdr
=
(
SSnapDataHdr
*
)
pData
;
#if 0
// ts data
if
(
pHdr
->
type
==
SNAP_DATA_TSDB
)
{
code
=
tsdbSnapWriteData
(
pWriter
,
pData
,
nData
);
...
...
@@ -1219,7 +1199,6 @@ int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData)
if
(
code
)
goto
_err
;
}
}
#endif
// del data
if
(
pHdr
->
type
==
SNAP_DATA_DEL
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录