Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a09b5b8b
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看板
提交
a09b5b8b
编写于
12月 27, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
4d75c554
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
89 addition
and
45 deletion
+89
-45
source/dnode/vnode/src/tsdb/tsdbCompact.c
source/dnode/vnode/src/tsdb/tsdbCompact.c
+89
-45
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCompact.c
浏览文件 @
a09b5b8b
...
...
@@ -409,37 +409,75 @@ static int32_t tsdbCompactNextRow(STsdbCompactor *pCompactor) {
int32_t
code
=
0
;
int32_t
lino
=
0
;
TABLEID
excludeTableId
;
TABLEID
*
pExcludeTableId
=
NULL
;
for
(;;)
{
code
=
tsdbCompactNextRowImpl
(
pCompactor
,
NULL
);
code
=
tsdbCompactNextRowImpl
(
pCompactor
,
pExcludeTableId
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
// check if the table of the row exists
if
(
pCompactor
->
pIter
)
{
if
(
pCompactor
->
pIter
->
rowInfo
.
suid
==
pCompactor
->
tbSkm
.
suid
&&
pCompactor
->
pIter
->
rowInfo
.
uid
==
pCompactor
->
tbSkm
.
uid
)
{
break
;
}
else
{
SMetaInfo
info
;
if
(
metaGetInfo
(
pCompactor
->
pTsdb
->
pVnode
->
pMeta
,
pCompactor
->
pIter
->
rowInfo
.
uid
,
&
info
,
NULL
)
!=
TSDB_CODE_SUCCESS
)
{
// table not exist
}
else
{
// update table schema
STSchema
*
pTSchema
=
metaGetTbTSchema
(
pCompactor
->
pTsdb
->
pVnode
->
pMeta
,
pCompactor
->
pIter
->
rowInfo
.
uid
,
info
.
version
,
1
);
if
(
pTSchema
==
NULL
)
{
SRowInfo
*
pRowInfo
=
&
pCompactor
->
pIter
->
rowInfo
;
// Table exists, just break out
if
(
pRowInfo
->
uid
==
pCompactor
->
tbSkm
.
uid
)
break
;
SMetaInfo
info
;
if
(
pRowInfo
->
suid
)
{
// child table
// check if super table exists
if
(
pRowInfo
->
suid
!=
pCompactor
->
tbSkm
.
suid
)
{
if
(
metaGetInfo
(
pCompactor
->
pTsdb
->
pVnode
->
pMeta
,
pRowInfo
->
uid
,
&
info
,
NULL
)
!=
TSDB_CODE_SUCCESS
)
{
excludeTableId
.
suid
=
pRowInfo
->
suid
;
excludeTableId
.
uid
=
0
;
pExcludeTableId
=
&
excludeTableId
;
continue
;
}
// super table exists
pCompactor
->
tbSkm
.
suid
=
pRowInfo
->
suid
;
pCompactor
->
tbSkm
.
uid
=
0
;
tDestroyTSchema
(
pCompactor
->
tbSkm
.
pTSchema
);
pCompactor
->
tbSkm
.
pTSchema
=
metaGetTbTSchema
(
pCompactor
->
pTsdb
->
pVnode
->
pMeta
,
pRowInfo
->
suid
,
-
1
,
1
);
if
(
pCompactor
->
tbSkm
.
pTSchema
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
}
pCompactor
->
tbSkm
.
suid
=
pCompactor
->
pIter
->
rowInfo
.
suid
;
pCompactor
->
tbSkm
.
uid
=
pCompactor
->
pIter
->
rowInfo
.
uid
;
tDestroyTSchema
(
pCompactor
->
tbSkm
.
pTSchema
);
pCompactor
->
tbSkm
.
pTSchema
=
pTSchema
;
// check if table exists
if
(
metaGetInfo
(
pCompactor
->
pTsdb
->
pVnode
->
pMeta
,
pRowInfo
->
uid
,
&
info
,
NULL
)
!=
TSDB_CODE_SUCCESS
)
{
excludeTableId
.
suid
=
pRowInfo
->
suid
;
excludeTableId
.
uid
=
pRowInfo
->
uid
;
pExcludeTableId
=
&
excludeTableId
;
continue
;
}
// table exists
pCompactor
->
tbSkm
.
uid
=
pRowInfo
->
uid
;
}
else
{
// normal table
// check if table exists
if
(
metaGetInfo
(
pCompactor
->
pTsdb
->
pVnode
->
pMeta
,
pRowInfo
->
uid
,
&
info
,
NULL
)
!=
TSDB_CODE_SUCCESS
)
{
excludeTableId
.
suid
=
pRowInfo
->
suid
;
excludeTableId
.
uid
=
pRowInfo
->
uid
;
pExcludeTableId
=
&
excludeTableId
;
continue
;
}
break
;
// table exists
pCompactor
->
tbSkm
.
suid
=
pRowInfo
->
suid
;
pCompactor
->
tbSkm
.
uid
=
pRowInfo
->
uid
;
tDestroyTSchema
(
pCompactor
->
tbSkm
.
pTSchema
);
pCompactor
->
tbSkm
.
pTSchema
=
metaGetTbTSchema
(
pCompactor
->
pTsdb
->
pVnode
->
pMeta
,
pRowInfo
->
suid
,
-
1
,
1
);
if
(
pCompactor
->
tbSkm
.
pTSchema
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
}
break
;
}
else
{
// iter end, just break out
break
;
...
...
@@ -447,6 +485,10 @@ static int32_t tsdbCompactNextRow(STsdbCompactor *pCompactor) {
}
_exit:
if
(
code
)
{
tsdbError
(
"vgId:%d %s failed at line %d since %s"
,
TD_VID
(
pCompactor
->
pTsdb
->
pVnode
),
__func__
,
lino
,
tstrerror
(
code
));
}
return
code
;
}
...
...
@@ -460,8 +502,10 @@ static int32_t tsdbCompactGetRow(STsdbCompactor *pCompactor, SRowInfo **ppRowInf
}
if
(
pCompactor
->
pIter
)
{
ASSERT
(
pCompactor
->
pIter
->
rowInfo
.
suid
==
pCompactor
->
tbSkm
.
suid
);
ASSERT
(
pCompactor
->
pIter
->
rowInfo
.
uid
==
pCompactor
->
tbSkm
.
uid
);
*
ppRowInfo
=
&
pCompactor
->
pIter
->
rowInfo
;
*
ppTSchema
=
NULL
;
// TODO
*
ppTSchema
=
pCompactor
->
tbSkm
.
pTSchema
;
}
else
{
*
ppRowInfo
=
NULL
;
*
ppTSchema
=
NULL
;
...
...
@@ -571,31 +615,31 @@ int32_t tsdbCompact(STsdb *pTsdb, int32_t flag) {
nRow
++
;
// write block data if schema changed
if
((
pCompactor
->
bData
.
suid
||
pCompactor
->
bData
.
uid
)
&&
!
TABLE_SAME_SCHEMA
(
pCompactor
->
bData
.
suid
,
pCompactor
->
bData
.
uid
,
pRowInfo
->
suid
,
pRowInfo
->
uid
))
{
// TODO: write block data
ASSERT
(
0
);
// set block data not initialized
tBlockDataReset
(
&
pCompactor
->
bData
);
}
// init the block data if not initialized yet
if
(
pCompactor
->
bData
.
suid
==
0
&&
pCompactor
->
bData
.
uid
==
0
)
{
code
=
tBlockDataInit
(
&
pCompactor
->
bData
,
&
(
TABLEID
){.
suid
=
pRowInfo
->
suid
,
.
uid
=
pRowInfo
->
uid
},
pTSchema
,
NULL
,
0
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
// append row to block data
code
=
tBlockDataAppendRow
(
&
pCompactor
->
bData
,
&
pRowInfo
->
row
,
pTSchema
,
pRowInfo
->
uid
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
// check if block data is full
if
(
pCompactor
->
bData
.
nRow
>=
pCompactor
->
maxRows
)
{
// TODO: write block data
ASSERT
(
0
);
}
//
if ((pCompactor->bData.suid || pCompactor->bData.uid) &&
//
!TABLE_SAME_SCHEMA(pCompactor->bData.suid, pCompactor->bData.uid, pRowInfo->suid, pRowInfo->uid)) {
//
// TODO: write block data
//
ASSERT(0);
//
// set block data not initialized
//
tBlockDataReset(&pCompactor->bData);
//
}
//
//
init the block data if not initialized yet
//
if (pCompactor->bData.suid == 0 && pCompactor->bData.uid == 0) {
//
code = tBlockDataInit(&pCompactor->bData, &(TABLEID){.suid = pRowInfo->suid, .uid = pRowInfo->uid}, pTSchema,
//
NULL, 0);
//
TSDB_CHECK_CODE(code, lino, _exit);
//
}
//
//
append row to block data
//
code = tBlockDataAppendRow(&pCompactor->bData, &pRowInfo->row, pTSchema, pRowInfo->uid);
//
TSDB_CHECK_CODE(code, lino, _exit);
//
//
check if block data is full
//
if (pCompactor->bData.nRow >= pCompactor->maxRows) {
//
// TODO: write block data
//
ASSERT(0);
//
}
// iterate to next row
code
=
tsdbCompactNextRow
(
pCompactor
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录