Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cc0727ae
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看板
提交
cc0727ae
编写于
6月 25, 2023
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
014bfc4a
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
129 addition
and
15 deletion
+129
-15
source/dnode/vnode/src/tsdb/tsdbFSet2.c
source/dnode/vnode/src/tsdb/tsdbFSet2.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbSttFileRW.c
source/dnode/vnode/src/tsdb/tsdbSttFileRW.c
+4
-11
source/dnode/vnode/src/tsdb/tsdbSttFileRW.h
source/dnode/vnode/src/tsdb/tsdbSttFileRW.h
+7
-0
source/dnode/vnode/src/tsdb/tsdbUpgrade.c
source/dnode/vnode/src/tsdb/tsdbUpgrade.c
+117
-3
未找到文件。
source/dnode/vnode/src/tsdb/tsdbFSet2.c
浏览文件 @
cc0727ae
...
...
@@ -15,7 +15,7 @@
#include "tsdbFSet2.h"
static
int32_t
tsdbSttLvlInit
(
int32_t
level
,
SSttLvl
**
lvl
)
{
int32_t
tsdbSttLvlInit
(
int32_t
level
,
SSttLvl
**
lvl
)
{
if
(
!
(
lvl
[
0
]
=
taosMemoryMalloc
(
sizeof
(
SSttLvl
))))
return
TSDB_CODE_OUT_OF_MEMORY
;
lvl
[
0
]
->
level
=
level
;
TARRAY2_INIT
(
lvl
[
0
]
->
fobjArr
);
...
...
source/dnode/vnode/src/tsdb/tsdbSttFileRW.c
浏览文件 @
cc0727ae
...
...
@@ -15,13 +15,6 @@
#include "tsdbSttFileRW.h"
typedef
struct
{
SFDataPtr
sttBlkPtr
[
1
];
SFDataPtr
statisBlkPtr
[
1
];
SFDataPtr
tombBlkPtr
[
1
];
SFDataPtr
rsrvd
[
2
];
}
SSttFooter
;
// SSttFReader ============================================================
struct
SSttFileReader
{
SSttFileReaderConfig
config
[
1
];
...
...
@@ -602,7 +595,7 @@ _exit:
return
code
;
}
int32_t
tsdbFile
Do
WriteSttBlk
(
STsdbFD
*
fd
,
const
TSttBlkArray
*
sttBlkArray
,
SFDataPtr
*
ptr
,
int64_t
*
fileSize
)
{
int32_t
tsdbFileWriteSttBlk
(
STsdbFD
*
fd
,
const
TSttBlkArray
*
sttBlkArray
,
SFDataPtr
*
ptr
,
int64_t
*
fileSize
)
{
ptr
->
size
=
TARRAY2_DATA_LEN
(
sttBlkArray
);
if
(
ptr
->
size
>
0
)
{
ptr
->
offset
=
*
fileSize
;
...
...
@@ -621,7 +614,7 @@ static int32_t tsdbSttFileDoWriteSttBlk(SSttFileWriter *writer) {
int32_t
code
=
0
;
int32_t
lino
;
code
=
tsdbFile
Do
WriteSttBlk
(
writer
->
fd
,
writer
->
sttBlkArray
,
writer
->
footer
->
sttBlkPtr
,
&
writer
->
file
->
size
);
code
=
tsdbFileWriteSttBlk
(
writer
->
fd
,
writer
->
sttBlkArray
,
writer
->
footer
->
sttBlkPtr
,
&
writer
->
file
->
size
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
_exit:
...
...
@@ -680,7 +673,7 @@ _exit:
return
code
;
}
int32_t
tsdb
SttFileDoWriteFooterImpl
(
STsdbFD
*
fd
,
const
SSttFooter
*
footer
,
int64_t
*
fileSize
)
{
int32_t
tsdb
FileWriteSttFooter
(
STsdbFD
*
fd
,
const
SSttFooter
*
footer
,
int64_t
*
fileSize
)
{
int32_t
code
=
tsdbWriteFile
(
fd
,
*
fileSize
,
(
const
uint8_t
*
)
footer
,
sizeof
(
*
footer
));
if
(
code
)
return
code
;
*
fileSize
+=
sizeof
(
*
footer
);
...
...
@@ -688,7 +681,7 @@ int32_t tsdbSttFileDoWriteFooterImpl(STsdbFD *fd, const SSttFooter *footer, int6
}
static
int32_t
tsdbSttFileDoWriteFooter
(
SSttFileWriter
*
writer
)
{
return
tsdb
SttFileDoWriteFooterImpl
(
writer
->
fd
,
writer
->
footer
,
&
writer
->
file
->
size
);
return
tsdb
FileWriteSttFooter
(
writer
->
fd
,
writer
->
footer
,
&
writer
->
file
->
size
);
}
static
int32_t
tsdbSttFWriterDoOpen
(
SSttFileWriter
*
writer
)
{
...
...
source/dnode/vnode/src/tsdb/tsdbSttFileRW.h
浏览文件 @
cc0727ae
...
...
@@ -26,6 +26,13 @@ extern "C" {
typedef
TARRAY2
(
SSttBlk
)
TSttBlkArray
;
typedef
TARRAY2
(
SStatisBlk
)
TStatisBlkArray
;
typedef
struct
{
SFDataPtr
sttBlkPtr
[
1
];
SFDataPtr
statisBlkPtr
[
1
];
SFDataPtr
tombBlkPtr
[
1
];
SFDataPtr
rsrvd
[
2
];
}
SSttFooter
;
// SSttFileReader ==========================================
typedef
struct
SSttFileReader
SSttFileReader
;
typedef
struct
SSttFileReaderConfig
SSttFileReaderConfig
;
...
...
source/dnode/vnode/src/tsdb/tsdbUpgrade.c
浏览文件 @
cc0727ae
...
...
@@ -26,6 +26,9 @@ extern int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, int8_t
TBrinBlkArray
*
brinBlkArray
,
uint8_t
**
bufArr
);
extern
int32_t
tsdbFileWriteBrinBlk
(
STsdbFD
*
fd
,
TBrinBlkArray
*
brinBlkArray
,
SFDataPtr
*
ptr
,
int64_t
*
fileSize
);
extern
int32_t
tsdbFileWriteHeadFooter
(
STsdbFD
*
fd
,
int64_t
*
fileSize
,
const
SHeadFooter
*
footer
);
extern
int32_t
tsdbSttLvlInit
(
int32_t
level
,
SSttLvl
**
lvl
);
extern
int32_t
tsdbFileWriteSttBlk
(
STsdbFD
*
fd
,
const
TSttBlkArray
*
sttBlkArray
,
SFDataPtr
*
ptr
,
int64_t
*
fileSize
);
extern
int32_t
tsdbFileWriteSttFooter
(
STsdbFD
*
fd
,
const
SSttFooter
*
footer
,
int64_t
*
fileSize
);
static
int32_t
tsdbUpgradeHead
(
STsdb
*
tsdb
,
SDFileSet
*
pDFileSet
,
SDataFReader
*
reader
,
STFileSet
*
fset
)
{
int32_t
code
=
0
;
...
...
@@ -170,7 +173,20 @@ static int32_t tsdbUpgradeData(STsdb *tsdb, SDFileSet *pDFileSet, SDataFReader *
int32_t
code
=
0
;
int32_t
lino
=
0
;
// TODO
if
(
fset
->
farr
[
TSDB_FTYPE_HEAD
]
==
NULL
)
{
return
0
;
}
STFile
file
=
{
.
type
=
TSDB_FTYPE_DATA
,
.
did
=
pDFileSet
->
diskId
,
.
fid
=
fset
->
fid
,
.
cid
=
pDFileSet
->
pDataF
->
commitID
,
.
size
=
pDFileSet
->
pDataF
->
size
,
};
code
=
tsdbTFileObjInit
(
tsdb
,
&
file
,
&
fset
->
farr
[
TSDB_FTYPE_DATA
]);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
_exit:
if
(
code
)
{
...
...
@@ -183,7 +199,20 @@ static int32_t tsdbUpgradeSma(STsdb *tsdb, SDFileSet *pDFileSet, SDataFReader *r
int32_t
code
=
0
;
int32_t
lino
=
0
;
// TODO
if
(
fset
->
farr
[
TSDB_FTYPE_HEAD
]
==
NULL
)
{
return
0
;
}
STFile
file
=
{
.
type
=
TSDB_FTYPE_SMA
,
.
did
=
pDFileSet
->
diskId
,
.
fid
=
fset
->
fid
,
.
cid
=
pDFileSet
->
pSmaF
->
commitID
,
.
size
=
pDFileSet
->
pSmaF
->
size
,
};
code
=
tsdbTFileObjInit
(
tsdb
,
&
file
,
&
fset
->
farr
[
TSDB_FTYPE_SMA
]);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
_exit:
if
(
code
)
{
...
...
@@ -192,11 +221,96 @@ _exit:
return
code
;
}
static
int32_t
tsdbUpgradeSttFile
(
STsdb
*
tsdb
,
SDFileSet
*
pDFileSet
,
SDataFReader
*
reader
,
STFileSet
*
fset
,
int32_t
iStt
,
SSttLvl
*
lvl
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
SArray
*
aSttBlk
=
taosArrayInit
(
0
,
sizeof
(
SSttBlk
));
if
(
aSttBlk
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
code
=
tsdbReadSttBlk
(
reader
,
iStt
,
aSttBlk
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
taosArrayGetSize
(
aSttBlk
)
>
0
)
{
SSttFile
*
pSttF
=
pDFileSet
->
aSttF
[
iStt
];
STFileObj
*
fobj
;
struct
{
int32_t
szPage
;
// writer
STsdbFD
*
fd
;
TSttBlkArray
sttBlkArray
[
1
];
SSttFooter
footer
[
1
];
}
ctx
[
1
]
=
{{
.
szPage
=
tsdb
->
pVnode
->
config
.
tsdbPageSize
,
}};
STFile
file
=
{
.
type
=
TSDB_FTYPE_STT
,
.
did
=
pDFileSet
->
diskId
,
.
fid
=
fset
->
fid
,
.
cid
=
pSttF
->
commitID
,
.
size
=
pSttF
->
size
,
};
code
=
tsdbTFileObjInit
(
tsdb
,
&
file
,
&
fobj
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit1
);
code
=
tsdbOpenFile
(
fobj
->
fname
,
ctx
->
szPage
,
TD_FILE_READ
|
TD_FILE_WRITE
,
&
ctx
->
fd
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit1
);
for
(
int32_t
iSttBlk
=
0
;
iSttBlk
<
taosArrayGetSize
(
aSttBlk
);
iSttBlk
++
)
{
code
=
TARRAY2_APPEND_PTR
(
ctx
->
sttBlkArray
,
(
SSttBlk
*
)
taosArrayGet
(
aSttBlk
,
iSttBlk
));
TSDB_CHECK_CODE
(
code
,
lino
,
_exit1
);
}
code
=
tsdbFileWriteSttBlk
(
ctx
->
fd
,
ctx
->
sttBlkArray
,
ctx
->
footer
->
sttBlkPtr
,
&
fobj
->
f
->
size
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit1
);
code
=
tsdbFileWriteSttFooter
(
ctx
->
fd
,
ctx
->
footer
,
&
fobj
->
f
->
size
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit1
);
code
=
tsdbFsyncFile
(
ctx
->
fd
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit1
);
tsdbCloseFile
(
&
ctx
->
fd
);
code
=
TARRAY2_APPEND
(
lvl
->
fobjArr
,
fobj
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit1
);
_exit1:
TARRAY2_DESTROY
(
ctx
->
sttBlkArray
,
NULL
);
}
_exit:
if
(
code
)
{
TSDB_ERROR_LOG
(
TD_VID
(
tsdb
->
pVnode
),
lino
,
code
);
}
taosArrayDestroy
(
aSttBlk
);
return
code
;
}
static
int32_t
tsdbUpgradeStt
(
STsdb
*
tsdb
,
SDFileSet
*
pDFileSet
,
SDataFReader
*
reader
,
STFileSet
*
fset
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
// TODO
if
(
pDFileSet
->
nSttF
==
0
)
{
return
0
;
}
SSttLvl
*
lvl
;
code
=
tsdbSttLvlInit
(
0
,
&
lvl
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
for
(
int32_t
iStt
=
0
;
iStt
<
pDFileSet
->
nSttF
;
++
iStt
)
{
code
=
tsdbUpgradeSttFile
(
tsdb
,
pDFileSet
,
reader
,
fset
,
iStt
,
lvl
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
code
=
TARRAY2_APPEND
(
fset
->
lvlArr
,
lvl
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
_exit:
if
(
code
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录