Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9156b297
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看板
提交
9156b297
编写于
5月 26, 2023
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
fa00d0df
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
119 addition
and
41 deletion
+119
-41
source/dnode/vnode/src/tsdb/dev/tsdbMerge.c
source/dnode/vnode/src/tsdb/dev/tsdbMerge.c
+119
-41
未找到文件。
source/dnode/vnode/src/tsdb/dev/tsdbMerge.c
浏览文件 @
9156b297
...
...
@@ -16,15 +16,33 @@
#include "inc/tsdbMerge.h"
typedef
struct
{
bool
launched
;
bool
launched
;
bool
toData
;
int32_t
level
;
STFileSet
*
fset
;
}
SMergeCtx
;
typedef
struct
{
STsdb
*
tsdb
;
SMergeCtx
ctx
;
STsdb
*
tsdb
;
// config
int32_t
maxRow
;
int32_t
szPage
;
int8_t
cmprAlg
;
int64_t
cid
;
SSkmInfo
skmTb
;
SSkmInfo
skmRow
;
uint8_t
*
aBuf
[
5
];
// context
SMergeCtx
ctx
;
// reader
TARRAY2
(
SSttFileReader
*
)
sttReaderArr
;
SDataFileReader
*
dataReader
;
// writer
SSttFileWriter
*
sttWriter
;
SDataFileWriter
*
dataWriter
;
TFileOpArray
fopArr
;
// operations
TFileOpArray
fopArr
;
}
SMerger
;
static
int32_t
tsdbMergerOpen
(
SMerger
*
merger
)
{
...
...
@@ -58,57 +76,117 @@ _exit:
return
0
;
}
static
int32_t
tsdbMergeFileSet
(
SMerger
*
merger
,
STFileSet
*
fset
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
static
int32_t
tsdbDoMergeFileSet
(
SMerger
*
merger
)
{
// TODO
return
0
;
}
if
(
merger
->
ctx
.
launched
==
false
)
{
code
=
tsdbMergerOpen
(
merger
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
static
int32_t
tsdbMergeFileSetBegin
(
SMerger
*
merger
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
int32_t
vid
=
TD_VID
(
merger
->
tsdb
->
pVnode
);
STFileSet
*
fset
=
merger
->
ctx
.
fset
;
// prepare the merger file set
SSttLvl
*
lvl
;
STFileObj
*
fobj
;
merger
->
ctx
.
toData
=
true
;
merger
->
ctx
.
level
=
0
;
TARRAY2_FOREACH
(
&
fset
->
lvlArr
,
lvl
)
{
if
(
lvl
->
level
!=
merger
->
ctx
.
level
)
{
lvl
=
NULL
;
break
;
}
{
// prepare the merger file set
SSttLvl
*
lvl
;
STFileObj
*
fobj
;
bool
mergerToData
=
true
;
int32_t
level
=
-
1
;
fobj
=
TARRAY2_GET
(
&
lvl
->
farr
,
0
);
if
(
fobj
->
f
.
stt
.
nseg
<
merger
->
tsdb
->
pVnode
->
config
.
sttTrigger
)
{
merger
->
ctx
.
toData
=
false
;
break
;
}
else
{
ASSERT
(
lvl
->
level
==
0
||
TARRAY2_SIZE
(
&
lvl
->
farr
)
==
1
);
merger
->
ctx
.
level
++
;
TARRAY2_FOREACH
(
&
fset
->
lvlArr
,
lvl
)
{
if
(
lvl
->
level
-
level
>
1
)
{
mergerToData
=
false
;
break
;
}
// open the reader
SSttFileReader
*
reader
;
// code = tsdbSttFileReaderOpen(&fobj->f.stt, &reader);
// TSDB_CHECK_CODE(code, lino, _exit);
if
(
lvl
->
level
==
0
)
{
}
else
{
ASSERT
(
TARRAY2_SIZE
(
&
lvl
->
farr
)
==
1
);
code
=
TARRAY2_APPEND
(
&
merger
->
sttReaderArr
,
reader
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
fobj
=
TARRAY2_FIRST
(
&
lvl
->
farr
);
}
// add the operation
STFileOp
op
=
{
.
fid
=
fobj
->
f
.
fid
,
.
optype
=
TSDB_FOP_REMOVE
,
.
of
=
fobj
->
f
,
};
code
=
TARRAY2_APPEND
(
&
merger
->
fopArr
,
op
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
}
// merge to level
level
=
level
+
1
;
lvl
=
tsdbTFileSetGetLvl
(
fset
,
level
);
if
(
lvl
==
NULL
)
{
// open new stt file to merge to
}
else
{
// open existing stt file to merge to
}
// open stt file writer
SSttFileWriterConfig
config
=
{
.
pTsdb
=
merger
->
tsdb
,
.
maxRow
=
merger
->
maxRow
,
.
szPage
=
merger
->
szPage
,
.
cmprAlg
=
merger
->
cmprAlg
,
.
pSkmTb
=
&
merger
->
skmTb
,
.
pSkmRow
=
&
merger
->
skmRow
,
.
aBuf
=
merger
->
aBuf
,
};
if
(
lvl
)
{
config
.
file
=
fobj
->
f
;
}
else
{
config
.
file
=
(
STFile
){
.
type
=
TSDB_FTYPE_STT
,
.
did
=
{.
level
=
0
,
.
id
=
0
},
.
fid
=
fset
->
fid
,
.
cid
=
merger
->
cid
,
.
size
=
0
,
.
stt
=
{.
level
=
merger
->
ctx
.
level
,
.
nseg
=
0
},
};
}
code
=
tsdbSttFWriterOpen
(
&
config
,
&
merger
->
sttWriter
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
mergerToData
)
{
// code = tsdbDataFWriterOpen(SDataFWriter * *ppWriter, STsdb * pTsdb, SDFileSet * pSet);
// TSDB_CHECK_CODE(code, lino, _exit
);
}
// open data file writer
if
(
merger
->
ctx
.
toData
)
{
// code = tsdbDataFWriterOpen(
);
// TSDB_CHECK_CODE(code, lino, _exit);
}
{
// do merge the file set
_exit:
if
(
code
)
{
tsdbError
(
"vgId:%d %s failed at line %d since %s"
,
vid
,
__func__
,
lino
,
tstrerror
(
code
));
}
return
code
;
}
static
int32_t
tsdbMergeFileSetEnd
(
SMerger
*
merger
)
{
// TODO
return
0
;
}
static
int32_t
tsdbMergeFileSet
(
SMerger
*
merger
,
STFileSet
*
fset
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
{
// end merge the file set
if
(
merger
->
ctx
.
launched
==
false
)
{
code
=
tsdbMergerOpen
(
merger
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
merger
->
ctx
.
fset
=
fset
;
code
=
tsdbMergeFileSetBegin
(
merger
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
tsdbDoMergeFileSet
(
merger
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
tsdbMergeFileSetEnd
(
merger
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
_exit:
if
(
code
)
{
tsdbError
(
"vgId:%d %s failed at line %d since %s"
,
TD_VID
(
merger
->
tsdb
->
pVnode
),
__func__
,
lino
,
tstrerror
(
code
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录