Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b07ad168
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看板
提交
b07ad168
编写于
5月 26, 2023
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
9156b297
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
126 addition
and
73 deletion
+126
-73
source/dnode/vnode/src/tsdb/dev/inc/tsdbFSet.h
source/dnode/vnode/src/tsdb/dev/inc/tsdbFSet.h
+2
-1
source/dnode/vnode/src/tsdb/dev/inc/tsdbSttFReaderWriter.h
source/dnode/vnode/src/tsdb/dev/inc/tsdbSttFReaderWriter.h
+2
-1
source/dnode/vnode/src/tsdb/dev/tsdbCommit.c
source/dnode/vnode/src/tsdb/dev/tsdbCommit.c
+5
-6
source/dnode/vnode/src/tsdb/dev/tsdbMerge.c
source/dnode/vnode/src/tsdb/dev/tsdbMerge.c
+87
-8
source/dnode/vnode/src/tsdb/dev/tsdbSttFReaderWriter.c
source/dnode/vnode/src/tsdb/dev/tsdbSttFReaderWriter.c
+30
-57
未找到文件。
source/dnode/vnode/src/tsdb/dev/inc/tsdbFSet.h
浏览文件 @
b07ad168
...
...
@@ -30,7 +30,8 @@ typedef TARRAY2(SSttLvl *) TSttLvlArray;
typedef
TARRAY2
(
STFileOp
)
TFileOpArray
;
typedef
enum
{
TSDB_FOP_CREATE
=
1
,
TSDB_FOP_NONE
=
0
,
TSDB_FOP_CREATE
,
TSDB_FOP_REMOVE
,
TSDB_FOP_MODIFY
,
}
tsdb_fop_t
;
...
...
source/dnode/vnode/src/tsdb/dev/inc/tsdbSttFReaderWriter.h
浏览文件 @
b07ad168
...
...
@@ -56,7 +56,8 @@ typedef struct SSttFileWriterConfig SSttFileWriterConfig;
int32_t
tsdbSttFWriterOpen
(
const
SSttFileWriterConfig
*
config
,
SSttFileWriter
**
ppWriter
);
int32_t
tsdbSttFWriterClose
(
SSttFileWriter
**
ppWriter
,
int8_t
abort
,
struct
STFileOp
*
op
);
int32_t
tsdbSttFWriteTSData
(
SSttFileWriter
*
pWriter
,
TABLEID
*
tbid
,
TSDBROW
*
pRow
);
int32_t
tsdbSttFWriteTSData
(
SSttFileWriter
*
pWriter
,
SRowInfo
*
pRowInfo
);
int32_t
tsdbSttFWriteTSDataBlock
(
SSttFileWriter
*
pWriter
,
SBlockData
*
pBlockData
);
int32_t
tsdbSttFWriteDLData
(
SSttFileWriter
*
pWriter
,
TABLEID
*
tbid
,
SDelData
*
pDelData
);
struct
SSttFileWriterConfig
{
...
...
source/dnode/vnode/src/tsdb/dev/tsdbCommit.c
浏览文件 @
b07ad168
...
...
@@ -133,7 +133,7 @@ static int32_t open_committer_writer(SCommitter *pCommitter) {
}
}
static
int32_t
tsdbCommitWriteTSData
(
SCommitter
*
pCommitter
,
TABLEID
*
tbid
,
TSDBROW
*
pRow
)
{
static
int32_t
tsdbCommitWriteTSData
(
SCommitter
*
pCommitter
,
SRowInfo
*
pRowInfo
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
int32_t
vid
=
TD_VID
(
pCommitter
->
pTsdb
->
pVnode
);
...
...
@@ -143,15 +143,12 @@ static int32_t tsdbCommitWriteTSData(SCommitter *pCommitter, TABLEID *tbid, TSDB
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
code
=
tsdbSttFWriteTSData
(
pCommitter
->
pWriter
,
tbid
,
pRow
);
code
=
tsdbSttFWriteTSData
(
pCommitter
->
pWriter
,
pRowInfo
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
_exit:
if
(
code
)
{
tsdbError
(
"vgId:%d failed at line %d since %s"
,
vid
,
lino
,
tstrerror
(
code
));
}
else
{
tsdbTrace
(
"vgId:%d %s done, fid:%d suid:%"
PRId64
" uid:%"
PRId64
" ts:%"
PRId64
" version:%"
PRId64
,
vid
,
__func__
,
pCommitter
->
fid
,
tbid
->
suid
,
tbid
->
uid
,
TSDBROW_KEY
(
pRow
).
ts
,
TSDBROW_KEY
(
pRow
).
version
);
}
return
0
;
}
...
...
@@ -177,6 +174,7 @@ static int32_t commit_timeseries_data(SCommitter *pCommitter) {
for
(
int32_t
iTbData
=
0
;
iTbData
<
taosArrayGetSize
(
pCommitter
->
aTbDataP
);
iTbData
++
)
{
STbDataIter
iter
;
STbData
*
pTbData
=
(
STbData
*
)
taosArrayGetP
(
pCommitter
->
aTbDataP
,
iTbData
);
SRowInfo
rowInfo
=
{.
suid
=
pTbData
->
suid
,
.
uid
=
pTbData
->
uid
};
tsdbTbDataIterOpen
(
pTbData
,
&
from
,
0
,
&
iter
);
...
...
@@ -188,7 +186,8 @@ static int32_t commit_timeseries_data(SCommitter *pCommitter) {
break
;
}
code
=
tsdbCommitWriteTSData
(
pCommitter
,
(
TABLEID
*
)
pTbData
,
pRow
);
rowInfo
.
row
=
*
pRow
;
code
=
tsdbCommitWriteTSData
(
pCommitter
,
&
rowInfo
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
nRow
++
;
...
...
source/dnode/vnode/src/tsdb/dev/tsdbMerge.c
浏览文件 @
b07ad168
...
...
@@ -20,10 +20,14 @@ typedef struct {
bool
toData
;
int32_t
level
;
STFileSet
*
fset
;
SRowInfo
*
pRowInfo
;
SBlockData
bData
;
}
SMergeCtx
;
typedef
struct
{
STsdb
*
tsdb
;
// context
SMergeCtx
ctx
;
// config
int32_t
maxRow
;
int32_t
szPage
;
...
...
@@ -32,9 +36,6 @@ typedef struct {
SSkmInfo
skmTb
;
SSkmInfo
skmRow
;
uint8_t
*
aBuf
[
5
];
// context
SMergeCtx
ctx
;
// reader
TARRAY2
(
SSttFileReader
*
)
sttReaderArr
;
SDataFileReader
*
dataReader
;
...
...
@@ -76,11 +77,62 @@ _exit:
return
0
;
}
static
int32_t
tsdb
DoMergeFileSet
(
SMerger
*
merger
)
{
static
int32_t
tsdb
MergeNextRow
(
SMerger
*
merger
)
{
// TODO
return
0
;
}
static
int32_t
tsdbMergeToData
(
SMerger
*
merger
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
int32_t
vid
=
TD_VID
(
merger
->
tsdb
->
pVnode
);
for
(;;)
{
code
=
tsdbMergeNextRow
(
merger
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
!
merger
->
ctx
.
pRowInfo
)
break
;
code
=
tBlockDataAppendRow
(
&
merger
->
ctx
.
bData
,
&
merger
->
ctx
.
pRowInfo
->
row
,
NULL
,
merger
->
ctx
.
pRowInfo
->
uid
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
merger
->
ctx
.
bData
.
nRow
>=
merger
->
maxRow
)
{
// code = tsdbDataFWriteTSDataBlock(merger->dataWriter, &merger->ctx.bData);
// TSDB_CHECK_CODE(code, lino, _exit);
tBlockDataReset
(
&
merger
->
ctx
.
bData
);
}
}
_exit:
if
(
code
)
{
tsdbError
(
"vid:%d %s failed at line %d since %s"
,
vid
,
__func__
,
lino
,
tstrerror
(
code
));
}
return
code
;
}
static
int32_t
tsdbMergeToUpperLevel
(
SMerger
*
merger
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
int32_t
vid
=
TD_VID
(
merger
->
tsdb
->
pVnode
);
for
(;;)
{
code
=
tsdbMergeNextRow
(
merger
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
!
merger
->
ctx
.
pRowInfo
)
break
;
code
=
tsdbSttFWriteTSData
(
merger
->
sttWriter
,
merger
->
ctx
.
pRowInfo
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
_exit:
if
(
code
)
{
tsdbError
(
"vid:%d %s failed at line %d since %s"
,
vid
,
__func__
,
lino
,
tstrerror
(
code
));
}
return
code
;
}
static
int32_t
tsdbMergeFileSetBegin
(
SMerger
*
merger
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
...
...
@@ -164,8 +216,29 @@ _exit:
return
code
;
}
static
int32_t
tsdbMergeFileSetEnd
(
SMerger
*
merger
)
{
// TODO
return
0
;
int32_t
code
=
0
;
int32_t
lino
=
0
;
int32_t
vid
=
TD_VID
(
merger
->
tsdb
->
pVnode
);
STFileOp
op
;
code
=
tsdbSttFWriterClose
(
&
merger
->
sttWriter
,
0
,
&
op
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
op
.
optype
!=
TSDB_FOP_NONE
)
{
code
=
TARRAY2_APPEND
(
&
merger
->
fopArr
,
op
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
if
(
merger
->
ctx
.
toData
)
{
// code = tsdbDataFWriterClose();
// TSDB_CHECK_CODE(code, lino, _exit);
}
_exit:
if
(
code
)
{
tsdbError
(
"vgId:%d %s failed at line %d since %s"
,
vid
,
__func__
,
lino
,
tstrerror
(
code
));
}
return
code
;
}
static
int32_t
tsdbMergeFileSet
(
SMerger
*
merger
,
STFileSet
*
fset
)
{
int32_t
code
=
0
;
...
...
@@ -181,8 +254,14 @@ static int32_t tsdbMergeFileSet(SMerger *merger, STFileSet *fset) {
code
=
tsdbMergeFileSetBegin
(
merger
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
tsdbDoMergeFileSet
(
merger
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
// do merge
if
(
merger
->
ctx
.
toData
)
{
code
=
tsdbMergeToData
(
merger
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
else
{
code
=
tsdbMergeToUpperLevel
(
merger
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
code
=
tsdbMergeFileSetEnd
(
merger
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
...
...
source/dnode/vnode/src/tsdb/dev/tsdbSttFReaderWriter.c
浏览文件 @
b07ad168
...
...
@@ -601,25 +601,23 @@ _exit:
return
code
;
}
int32_t
tsdbSttFWriteTSData
(
SSttFileWriter
*
pWriter
,
TABLEID
*
tbid
,
TSDBROW
*
pRow
)
{
int32_t
tsdbSttFWriteTSData
(
SSttFileWriter
*
pWriter
,
SRowInfo
*
pRowInfo
)
{
int32_t
code
=
0
;
int32_t
lino
;
TSDBKEY
key
=
TSDBROW_KEY
(
pRow
);
TABLEID
*
tbid
=
(
TABLEID
*
)
pRowInfo
;
TSDBROW
*
pRow
=
&
pRowInfo
->
row
;
TSDBKEY
key
=
TSDBROW_KEY
(
pRow
);
if
(
!
TABLE_SAME_SCHEMA
(
pWriter
->
bData
.
suid
,
pWriter
->
bData
.
uid
,
tbid
->
suid
,
tbid
->
uid
))
{
if
(
pWriter
->
bData
.
nRow
>
0
)
{
TSDB_CHECK_CODE
(
//
code
=
write_timeseries_block
(
pWriter
),
//
lino
,
//
_exit
);
code
=
write_timeseries_block
(
pWriter
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
if
(
pWriter
->
sData
.
nRow
>=
pWriter
->
config
.
maxRow
)
{
TSDB_CHECK_CODE
(
//
code
=
write_statistics_block
(
pWriter
),
//
lino
,
//
_exit
);
code
=
write_statistics_block
(
pWriter
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
pWriter
->
sData
.
aData
[
0
][
pWriter
->
sData
.
nRow
]
=
tbid
->
suid
;
// suid
...
...
@@ -631,54 +629,28 @@ int32_t tsdbSttFWriteTSData(SSttFileWriter *pWriter, TABLEID *tbid, TSDBROW *pRo
pWriter
->
sData
.
aData
[
6
][
pWriter
->
sData
.
nRow
]
=
1
;
// count
pWriter
->
sData
.
nRow
++
;
TSDB_CHECK_CODE
(
//
code
=
tsdbUpdateSkmTb
(
//
pWriter
->
config
.
pTsdb
,
//
tbid
,
//
pWriter
->
config
.
pSkmTb
),
//
lino
,
//
_exit
);
code
=
tsdbUpdateSkmTb
(
pWriter
->
config
.
pTsdb
,
tbid
,
pWriter
->
config
.
pSkmTb
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TABLEID
id
=
{.
suid
=
tbid
->
suid
,
//
.
uid
=
tbid
->
suid
//
?
0
:
tbid
->
uid
};
TSDB_CHECK_CODE
(
//
code
=
tBlockDataInit
(
//
&
pWriter
->
bData
,
//
&
id
,
//
pWriter
->
config
.
pSkmTb
->
pTSchema
,
//
NULL
,
//
0
),
//
lino
,
//
_exit
);
TABLEID
id
=
{
.
suid
=
tbid
->
suid
,
.
uid
=
tbid
->
uid
?
0
:
tbid
->
uid
,
};
code
=
tBlockDataInit
(
&
pWriter
->
bData
,
&
id
,
pWriter
->
config
.
pSkmTb
->
pTSchema
,
NULL
,
0
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
if
(
pRow
->
type
==
TSDBROW_ROW_FMT
)
{
TSDB_CHECK_CODE
(
//
code
=
tsdbUpdateSkmRow
(
//
pWriter
->
config
.
pTsdb
,
//
tbid
,
//
TSDBROW_SVERSION
(
pRow
),
//
pWriter
->
config
.
pSkmRow
),
//
lino
,
//
_exit
);
if
(
pRowInfo
->
row
.
type
==
TSDBROW_ROW_FMT
)
{
code
=
tsdbUpdateSkmRow
(
pWriter
->
config
.
pTsdb
,
tbid
,
TSDBROW_SVERSION
(
pRow
),
pWriter
->
config
.
pSkmRow
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
TSDB_CHECK_CODE
(
//
code
=
tBlockDataAppendRow
(
//
&
pWriter
->
bData
,
//
pRow
,
//
pWriter
->
config
.
pSkmRow
->
pTSchema
,
//
tbid
->
uid
),
//
lino
,
//
_exit
);
code
=
tBlockDataAppendRow
(
&
pWriter
->
bData
,
pRow
,
pWriter
->
config
.
pSkmRow
->
pTSchema
,
tbid
->
uid
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
pWriter
->
bData
.
nRow
>=
pWriter
->
config
.
maxRow
)
{
TSDB_CHECK_CODE
(
//
code
=
write_timeseries_block
(
pWriter
),
//
lino
,
//
_exit
);
code
=
write_timeseries_block
(
pWriter
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
if
(
key
.
ts
>
pWriter
->
sData
.
aData
[
4
][
pWriter
->
sData
.
nRow
-
1
])
{
...
...
@@ -694,16 +666,17 @@ int32_t tsdbSttFWriteTSData(SSttFileWriter *pWriter, TABLEID *tbid, TSDBROW *pRo
_exit:
if
(
code
)
{
tsdbError
(
//
"vgId:%d %s failed at line %d since %s"
,
//
TD_VID
(
pWriter
->
config
.
pTsdb
->
pVnode
),
//
__func__
,
//
lino
,
//
tstrerror
(
code
));
tsdbError
(
"vgId:%d %s failed at line %d since %s"
,
TD_VID
(
pWriter
->
config
.
pTsdb
->
pVnode
),
__func__
,
lino
,
tstrerror
(
code
));
}
return
code
;
}
int32_t
tsdbSttFWriteTSDataBlock
(
SSttFileWriter
*
pWriter
,
SBlockData
*
pBlockData
)
{
// TODO
return
0
;
}
int32_t
tsdbSttFWriteDLData
(
SSttFileWriter
*
pWriter
,
TABLEID
*
tbid
,
SDelData
*
pDelData
)
{
ASSERTS
(
0
,
"TODO: Not implemented yet"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录