Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
01f6823b
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看板
提交
01f6823b
编写于
12月 29, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
52f1f272
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
81 addition
and
2 deletion
+81
-2
source/dnode/vnode/src/tsdb/tsdbCompact.c
source/dnode/vnode/src/tsdb/tsdbCompact.c
+81
-2
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCompact.c
浏览文件 @
01f6823b
...
...
@@ -62,6 +62,13 @@ typedef struct {
int32_t
fid
;
SDFileSet
*
pDFileSet
;
// Tombstone
SDelFReader
*
pDelFReader
;
SArray
*
aDelIdx
;
// SArray<SDelIdx>
SArray
*
aDelData
;
// SArray<SDelData>
SArray
*
aSkyLine
;
// SArray<TSDBKEY>
TSDBKEY
*
aTSDBKEY
;
// Reader
SDataFReader
*
pReader
;
STsdbDataIter
*
iterList
;
// list of iterators
...
...
@@ -314,6 +321,33 @@ static int32_t tsdbBeginCompact(STsdb *pTsdb, STsdbCompactor *pCompactor) {
code
=
tBlockDataCreate
(
&
pCompactor
->
bData
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
// tombstone
if
(
pCompactor
->
fs
.
pDelFile
)
{
code
=
tsdbDelFReaderOpen
(
&
pCompactor
->
pDelFReader
,
pCompactor
->
fs
.
pDelFile
,
pTsdb
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
pCompactor
->
aDelIdx
=
taosArrayInit
(
0
,
sizeof
(
SDelIdx
));
if
(
pCompactor
->
aDelIdx
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
pCompactor
->
aDelData
=
taosArrayInit
(
0
,
sizeof
(
SDelData
));
if
(
pCompactor
->
aDelData
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
pCompactor
->
aSkyLine
=
taosArrayInit
(
0
,
sizeof
(
TSDBKEY
));
if
(
pCompactor
->
aSkyLine
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
code
=
tsdbReadDelIdx
(
pCompactor
->
pDelFReader
,
pCompactor
->
aDelIdx
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
_exit:
if
(
code
)
{
tsdbError
(
"vgId:%d %s failed at line %d since %s"
,
TD_VID
(
pTsdb
->
pVnode
),
__func__
,
lino
,
tstrerror
(
code
));
...
...
@@ -322,6 +356,10 @@ _exit:
}
static
void
tsdbEndCompact
(
STsdbCompactor
*
pCompactor
)
{
taosArrayDestroy
(
pCompactor
->
aSkyLine
);
taosArrayDestroy
(
pCompactor
->
aDelData
);
taosArrayDestroy
(
pCompactor
->
aDelIdx
);
tsdbDelFReaderClose
(
&
pCompactor
->
pDelFReader
);
tsdbFSDestroy
(
&
pCompactor
->
fs
);
tBlockDataDestroy
(
&
pCompactor
->
bData
);
tDestroyTSchema
(
pCompactor
->
tbSkm
.
pTSchema
);
...
...
@@ -451,6 +489,21 @@ _exit:
return
code
;
}
static
int32_t
tDelIdxCmprFn
(
const
SDelIdx
*
pDelIdx1
,
const
SDelIdx
*
pDelIdx2
)
{
if
(
pDelIdx1
->
suid
<
pDelIdx2
->
suid
)
{
return
-
1
;
}
else
if
(
pDelIdx1
->
suid
>
pDelIdx2
->
suid
)
{
return
1
;
}
if
(
pDelIdx1
->
uid
<
pDelIdx2
->
uid
)
{
return
-
1
;
}
else
if
(
pDelIdx1
->
uid
>
pDelIdx2
->
uid
)
{
return
1
;
}
return
0
;
}
static
int32_t
tsdbCompactNextRow
(
STsdbCompactor
*
pCompactor
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
...
...
@@ -466,8 +519,15 @@ static int32_t tsdbCompactNextRow(STsdbCompactor *pCompactor) {
if
(
pCompactor
->
pIter
)
{
SRowInfo
*
pRowInfo
=
&
pCompactor
->
pIter
->
rowInfo
;
// Table exists, just break out
if
(
pRowInfo
->
uid
==
pCompactor
->
tbSkm
.
uid
)
break
;
// Table exists
if
(
pRowInfo
->
uid
==
pCompactor
->
tbSkm
.
uid
)
{
if
(
pCompactor
->
aTSDBKEY
)
{
// TODO: check if the row is deleted. if deleted, continue, else break
ASSERT
(
0
);
}
else
{
break
;
}
}
SMetaInfo
info
;
if
(
pRowInfo
->
suid
)
{
// child table
...
...
@@ -523,6 +583,25 @@ static int32_t tsdbCompactNextRow(STsdbCompactor *pCompactor) {
}
}
// load delData and build the skyline
if
(
pCompactor
->
pDelFReader
)
{
SDelIdx
*
pDelIdx
=
taosArraySearch
(
pCompactor
->
aDelIdx
,
&
(
SDelIdx
){.
suid
=
pRowInfo
->
suid
,
.
uid
=
pRowInfo
->
uid
},
(
__compar_fn_t
)
tDelIdxCmprFn
,
TD_EQ
);
if
(
pDelIdx
)
{
code
=
tsdbReadDelData
(
pCompactor
->
pDelFReader
,
pDelIdx
,
pCompactor
->
aDelData
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
tsdbBuildDeleteSkyline
(
pCompactor
->
aDelData
,
0
,
taosArrayGetSize
(
pCompactor
->
aDelData
)
-
1
,
pCompactor
->
aSkyLine
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
pCompactor
->
aTSDBKEY
=
(
TSDBKEY
*
)
TARRAY_DATA
(
pCompactor
->
aDelData
);
}
else
{
pCompactor
->
aTSDBKEY
=
NULL
;
}
}
break
;
}
else
{
// iter end, just break out
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录