Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
052d9c6e
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
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看板
提交
052d9c6e
编写于
3月 24, 2023
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
873c9705
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
183 addition
and
76 deletion
+183
-76
source/dnode/vnode/src/tsdb/dev/dev.h
source/dnode/vnode/src/tsdb/dev/dev.h
+21
-0
source/dnode/vnode/src/tsdb/dev/tsdbCommit.c
source/dnode/vnode/src/tsdb/dev/tsdbCommit.c
+1
-1
source/dnode/vnode/src/tsdb/dev/tsdbFS.c
source/dnode/vnode/src/tsdb/dev/tsdbFS.c
+3
-1
source/dnode/vnode/src/tsdb/dev/tsdbFile.c
source/dnode/vnode/src/tsdb/dev/tsdbFile.c
+1
-50
source/dnode/vnode/src/tsdb/dev/tsdbFile.h
source/dnode/vnode/src/tsdb/dev/tsdbFile.h
+46
-3
source/dnode/vnode/src/tsdb/dev/tsdbSttFWriter.c
source/dnode/vnode/src/tsdb/dev/tsdbSttFWriter.c
+106
-17
source/dnode/vnode/src/tsdb/dev/tsdbSttFWriter.h
source/dnode/vnode/src/tsdb/dev/tsdbSttFWriter.h
+2
-1
source/dnode/vnode/src/tsdb/dev/tsdbUtil.c
source/dnode/vnode/src/tsdb/dev/tsdbUtil.c
+3
-1
source/dnode/vnode/src/tsdb/dev/tsdbUtil.h
source/dnode/vnode/src/tsdb/dev/tsdbUtil.h
+0
-2
未找到文件。
source/dnode/vnode/src/tsdb/dev/
tsdbMerge.c
→
source/dnode/vnode/src/tsdb/dev/
dev.h
浏览文件 @
052d9c6e
...
@@ -13,4 +13,25 @@
...
@@ -13,4 +13,25 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#ifndef _TSDB_DEV_H
#define _TSDB_DEV_H
#include "tsdb.h"
#include "tsdb.h"
#ifdef __cplusplus
extern
"C"
{
#endif
#include "tsdbUtil.h"
#include "tsdbFile.h"
#include "tsdbFS.h"
#include "tsdbSttFWriter.h"
#ifdef __cplusplus
}
#endif
#endif
/*_TSDB_DEV_H*/
\ No newline at end of file
source/dnode/vnode/src/tsdb/dev/tsdbCommit.c
浏览文件 @
052d9c6e
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
tsdbSttFWriter
.h"
#include "
dev
.h"
// extern dependencies
// extern dependencies
typedef
struct
{
typedef
struct
{
...
...
source/dnode/vnode/src/tsdb/dev/tsdbFS.c
浏览文件 @
052d9c6e
...
@@ -11,4 +11,6 @@
...
@@ -11,4 +11,6 @@
*
*
* You should have received a copy of the GNU Affero General Public License
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
\ No newline at end of file
#include "dev.h"
\ No newline at end of file
source/dnode/vnode/src/tsdb/dev/tsdbFile.c
浏览文件 @
052d9c6e
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
tsdbFile
.h"
#include "
dev
.h"
typedef
enum
{
typedef
enum
{
TSDB_FOP_CREATE
=
-
2
,
// create a file
TSDB_FOP_CREATE
=
-
2
,
// create a file
...
@@ -24,59 +24,10 @@ typedef enum {
...
@@ -24,59 +24,10 @@ typedef enum {
TSDB_FOP_MAX
,
TSDB_FOP_MAX
,
}
tsdb_fop_t
;
}
tsdb_fop_t
;
typedef
enum
{
TSDB_FTYPE_NONE
=
0
,
// no file type
TSDB_FTYPE_STT
,
// .stt
TSDB_FTYPE_HEAD
,
// .head
TSDB_FTYPE_DATA
,
// .data
TSDB_FTYPE_SMA
,
// .sma
TSDB_FTYPE_TOMB
,
// .tomb
}
tsdb_ftype_t
;
const
char
*
tsdb_ftype_suffix
[]
=
{
const
char
*
tsdb_ftype_suffix
[]
=
{
"none"
,
"stt"
,
"head"
,
"data"
,
"sma"
,
"tomb"
,
"none"
,
"stt"
,
"head"
,
"data"
,
"sma"
,
"tomb"
,
};
};
typedef
struct
SFStt
{
int64_t
offset
;
}
SFStt
;
typedef
struct
SFHead
{
int64_t
offset
;
}
SFHead
;
typedef
struct
SFData
{
// TODO
}
SFData
;
typedef
struct
SFSma
{
// TODO
}
SFSma
;
typedef
struct
SFTomb
{
// TODO
}
SFTomb
;
struct
STFile
{
SDiskID
diskId
;
int64_t
size
;
int64_t
cid
;
int32_t
fid
;
tsdb_ftype_t
type
;
union
{
SFStt
fstt
;
SFHead
fhead
;
SFData
fdata
;
SFSma
fsma
;
SFTomb
ftomb
;
};
};
struct
SFileObj
{
volatile
int32_t
nRef
;
STFile
file
;
};
struct
SFileOp
{
struct
SFileOp
{
tsdb_fop_t
op
;
tsdb_fop_t
op
;
union
{
union
{
...
...
source/dnode/vnode/src/tsdb/dev/tsdbFile.h
浏览文件 @
052d9c6e
...
@@ -23,13 +23,56 @@ extern "C" {
...
@@ -23,13 +23,56 @@ extern "C" {
#endif
#endif
/* Exposed Handle */
/* Exposed Handle */
typedef
struct
STFile
STFile
;
typedef
struct
STFile
STFile
;
typedef
struct
SFileObj
SFileObj
;
typedef
struct
SFileOp
SFileOp
;
typedef
struct
SFileOp
SFileOp
;
typedef
enum
{
TSDB_FTYPE_NONE
=
0
,
// no file type
TSDB_FTYPE_STT
,
// .stt
TSDB_FTYPE_HEAD
,
// .head
TSDB_FTYPE_DATA
,
// .data
TSDB_FTYPE_SMA
,
// .sma
TSDB_FTYPE_TOMB
,
// .tomb
}
tsdb_ftype_t
;
/* Exposed APIs */
/* Exposed APIs */
/* Exposed Structs */
/* Exposed Structs */
typedef
struct
SFStt
{
int64_t
offset
;
}
SFStt
;
typedef
struct
SFHead
{
int64_t
offset
;
}
SFHead
;
typedef
struct
SFData
{
// TODO
}
SFData
;
typedef
struct
SFSma
{
// TODO
}
SFSma
;
typedef
struct
SFTomb
{
// TODO
}
SFTomb
;
struct
STFile
{
char
fname
[
TSDB_FILENAME_LEN
];
SDiskID
diskId
;
int64_t
size
;
int64_t
cid
;
int32_t
fid
;
int32_t
ref
;
tsdb_ftype_t
type
;
union
{
SFStt
fstt
;
SFHead
fhead
;
SFData
fdata
;
SFSma
fsma
;
SFTomb
ftomb
;
};
};
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/vnode/src/tsdb/dev/tsdbSttFWriter.c
浏览文件 @
052d9c6e
...
@@ -13,8 +13,7 @@
...
@@ -13,8 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "tsdbSttFWriter.h"
#include "dev.h"
#include "tsdbUtil.h"
extern
int32_t
tsdbOpenFile
(
const
char
*
path
,
int32_t
szPage
,
int32_t
flag
,
STsdbFD
**
ppFD
);
extern
int32_t
tsdbOpenFile
(
const
char
*
path
,
int32_t
szPage
,
int32_t
flag
,
STsdbFD
**
ppFD
);
extern
void
tsdbCloseFile
(
STsdbFD
**
ppFD
);
extern
void
tsdbCloseFile
(
STsdbFD
**
ppFD
);
...
@@ -26,7 +25,6 @@ struct SSttFWriter {
...
@@ -26,7 +25,6 @@ struct SSttFWriter {
SSttFWriterConf
config
;
SSttFWriterConf
config
;
// time-series data
// time-series data
SBlockData
bData
;
SBlockData
bData
;
SSttBlk
sttBlk
;
SArray
*
aSttBlk
;
// SArray<SSttBlk>
SArray
*
aSttBlk
;
// SArray<SSttBlk>
// tombstone data
// tombstone data
SDelBlock
dData
;
SDelBlock
dData
;
...
@@ -37,18 +35,34 @@ struct SSttFWriter {
...
@@ -37,18 +35,34 @@ struct SSttFWriter {
STsdbFD
*
pFd
;
STsdbFD
*
pFd
;
};
};
static
int32_t
tsdbSttFWriteTSB
lock
(
SSttFWriter
*
pWriter
)
{
static
int32_t
write_ts_b
lock
(
SSttFWriter
*
pWriter
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
int32_t
lino
;
int32_t
lino
;
SBlockData
*
pBData
=
&
pWriter
->
bData
;
SBlockData
*
pBData
=
&
pWriter
->
bData
;
SSttBlk
*
pSttBlk
=
(
SSttBlk
*
)
taosArrayReserve
(
pWriter
->
aSttBlk
,
1
);
if
(
pSttBlk
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
pSttBlk
->
suid
=
pBData
->
suid
;
pSttBlk
->
minUid
=
pBData
->
aUid
[
0
];
pSttBlk
->
maxUid
=
pBData
->
aUid
[
pBData
->
nRow
-
1
];
pSttBlk
->
minKey
=
pSttBlk
->
maxKey
=
pBData
->
aTSKEY
[
0
];
pSttBlk
->
minVer
=
pSttBlk
->
maxVer
=
pBData
->
aTSKEY
[
0
];
pSttBlk
->
nRow
=
pBData
->
nRow
;
for
(
int32_t
iRow
=
1
;
iRow
<
pBData
->
nRow
;
iRow
++
)
{
pSttBlk
->
minKey
=
TMIN
(
pSttBlk
->
minKey
,
pBData
->
aTSKEY
[
iRow
]);
pSttBlk
->
maxKey
=
TMAX
(
pSttBlk
->
maxKey
,
pBData
->
aTSKEY
[
iRow
]);
pSttBlk
->
minVer
=
TMIN
(
pSttBlk
->
minVer
,
pBData
->
aVersion
[
iRow
]);
pSttBlk
->
maxVer
=
TMAX
(
pSttBlk
->
maxVer
,
pBData
->
aVersion
[
iRow
]);
}
// compress data block
// compress data block
code
=
tCmprBlockData
(
pBData
,
pWriter
->
config
.
cmprAlg
,
NULL
,
NULL
,
NULL
/* TODO */
,
NULL
/* TODO */
);
code
=
tCmprBlockData
(
pBData
,
pWriter
->
config
.
cmprAlg
,
NULL
,
NULL
,
NULL
/* TODO */
,
NULL
/* TODO */
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_NULL
(
taosArrayPush
(
pWriter
->
aSttBlk
,
&
pWriter
->
sttBlk
),
code
,
lino
,
_exit
,
TSDB_CODE_OUT_OF_MEMORY
);
tBlockDataClear
(
pBData
);
tBlockDataClear
(
pBData
);
_exit:
_exit:
...
@@ -59,24 +73,88 @@ _exit:
...
@@ -59,24 +73,88 @@ _exit:
return
code
;
return
code
;
}
}
int32_t
tsdbSttFWriterOpen
(
const
SSttFWriterConf
*
pConf
,
SSttFWriter
**
ppWriter
)
{
static
int32_t
write_del_block
(
SSttFWriter
*
pWriter
)
{
int32_t
code
=
0
;
// TODO
return
code
;
}
static
int32_t
write_stt_blk
(
SSttFWriter
*
pWriter
)
{
int32_t
code
=
0
;
// TODO
return
code
;
}
static
int32_t
write_del_blk
(
SSttFWriter
*
pWriter
)
{
int32_t
code
=
0
;
// TODO
return
code
;
}
static
int32_t
stt_fwriter_create
(
const
SSttFWriterConf
*
pConf
,
SSttFWriter
**
ppWriter
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
int32_t
lino
;
if
((
ppWriter
[
0
]
=
taosMemoryCalloc
(
1
,
sizeof
(
SSttFWriter
)))
==
NULL
)
{
if
((
ppWriter
[
0
]
=
taosMemoryCalloc
(
1
,
sizeof
(
SSttFWriter
)))
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
)
;
goto
_exit
;
}
}
ppWriter
[
0
]
->
config
=
pConf
[
0
];
ppWriter
[
0
]
->
config
=
pConf
[
0
];
if
(
ppWriter
[
0
]
->
config
.
pSkmTb
==
NULL
)
ppWriter
[
0
]
->
config
.
pSkmTb
=
&
ppWriter
[
0
]
->
skmTb
;
if
(
pConf
->
pSkmRow
==
NULL
)
{
if
(
ppWriter
[
0
]
->
config
.
pSkmRow
==
NULL
)
ppWriter
[
0
]
->
config
.
pSkmRow
=
&
ppWriter
[
0
]
->
skmRow
;
ppWriter
[
0
]
->
config
.
pSkmRow
=
&
ppWriter
[
0
]
->
skmRow
;
}
if
(
pConf
->
pSkmTb
==
NULL
)
{
ppWriter
[
0
]
->
config
.
pSkmTb
=
&
ppWriter
[
0
]
->
skmTb
;
}
tBlockDataCreate
(
&
ppWriter
[
0
]
->
bData
);
tBlockDataCreate
(
&
ppWriter
[
0
]
->
bData
);
// tDelBlockCreate(&ppWriter[0]->dData);
ppWriter
[
0
]
->
aSttBlk
=
taosArrayInit
(
64
,
sizeof
(
SSttBlk
));
if
(
ppWriter
[
0
]
->
aSttBlk
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
int32_t
flag
=
TD_FILE_READ
|
TD_FILE_WRITE
|
TD_FILE_CREATE
|
TD_FILE_TRUNC
;
// TODO
_exit:
code
=
tsdbOpenFile
(
NULL
/* TODO */
,
pConf
->
szPage
,
flag
,
&
ppWriter
[
0
]
->
pFd
);
if
(
code
&&
ppWriter
[
0
])
{
taosArrayDestroy
(
ppWriter
[
0
]
->
aSttBlk
);
tBlockDataDestroy
(
&
ppWriter
[
0
]
->
bData
);
taosMemoryFree
(
ppWriter
[
0
]);
ppWriter
[
0
]
=
NULL
;
}
return
code
;
}
static
int32_t
stt_fwriter_destroy
(
SSttFWriter
*
pWriter
)
{
if
(
pWriter
)
{
tDestroyTSchema
(
pWriter
->
skmTb
.
pTSchema
);
tDestroyTSchema
(
pWriter
->
skmRow
.
pTSchema
);
taosArrayDestroy
(
pWriter
->
aSttBlk
);
tBlockDataDestroy
(
&
pWriter
->
bData
);
taosMemoryFree
(
pWriter
);
}
return
0
;
}
static
int32_t
stt_fwriter_open
(
SSttFWriter
*
pWriter
)
{
int32_t
code
=
0
;
// TODO
return
code
;
}
static
int32_t
stt_fwriter_close
(
SSttFWriter
*
pWriter
)
{
int32_t
code
=
0
;
// TODO
return
code
;
}
int32_t
tsdbSttFWriterOpen
(
const
SSttFWriterConf
*
pConf
,
SSttFWriter
**
ppWriter
)
{
int32_t
code
=
0
;
int32_t
lino
;
code
=
stt_fwriter_create
(
pConf
,
ppWriter
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
stt_fwriter_open
(
ppWriter
[
0
]);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
_exit:
_exit:
...
@@ -91,8 +169,19 @@ _exit:
...
@@ -91,8 +169,19 @@ _exit:
}
}
int32_t
tsdbSttFWriterClose
(
SSttFWriter
**
ppWriter
)
{
int32_t
tsdbSttFWriterClose
(
SSttFWriter
**
ppWriter
)
{
int32_t
vgId
=
TD_VID
(
ppWriter
[
0
]
->
config
.
pTsdb
->
pVnode
);
int32_t
code
=
0
;
int32_t
code
=
0
;
// TODO
int32_t
lino
;
code
=
stt_fwriter_close
(
ppWriter
[
0
]);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
stt_fwriter_close
(
ppWriter
[
0
]);
_exit:
if
(
code
)
{
tsdbError
(
"vgId:%d %s failed at line %d since %s"
,
vgId
,
__func__
,
lino
,
tstrerror
(
code
));
}
return
code
;
return
code
;
}
}
...
@@ -102,7 +191,7 @@ int32_t tsdbSttFWriteTSData(SSttFWriter *pWriter, TABLEID *tbid, TSDBROW *pRow)
...
@@ -102,7 +191,7 @@ int32_t tsdbSttFWriteTSData(SSttFWriter *pWriter, TABLEID *tbid, TSDBROW *pRow)
if
(
!
TABLE_SAME_SCHEMA
(
pWriter
->
bData
.
suid
,
pWriter
->
bData
.
uid
,
tbid
->
suid
,
tbid
->
uid
))
{
if
(
!
TABLE_SAME_SCHEMA
(
pWriter
->
bData
.
suid
,
pWriter
->
bData
.
uid
,
tbid
->
suid
,
tbid
->
uid
))
{
if
(
pWriter
->
bData
.
nRow
>
0
)
{
if
(
pWriter
->
bData
.
nRow
>
0
)
{
code
=
tsdbSttFWriteTSB
lock
(
pWriter
);
code
=
write_ts_b
lock
(
pWriter
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
}
...
@@ -124,7 +213,7 @@ int32_t tsdbSttFWriteTSData(SSttFWriter *pWriter, TABLEID *tbid, TSDBROW *pRow)
...
@@ -124,7 +213,7 @@ int32_t tsdbSttFWriteTSData(SSttFWriter *pWriter, TABLEID *tbid, TSDBROW *pRow)
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
pWriter
->
bData
.
nRow
>=
pWriter
->
config
.
maxRow
)
{
if
(
pWriter
->
bData
.
nRow
>=
pWriter
->
config
.
maxRow
)
{
code
=
tsdbSttFWriteTSB
lock
(
pWriter
);
code
=
write_ts_b
lock
(
pWriter
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
}
...
...
source/dnode/vnode/src/tsdb/dev/tsdbSttFWriter.h
浏览文件 @
052d9c6e
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
#ifndef _TSDB_STT_FILE_WRITER_H
#ifndef _TSDB_STT_FILE_WRITER_H
#define _TSDB_STT_FILE_WRITER_H
#define _TSDB_STT_FILE_WRITER_H
#include "tsdb.h"
#include "tsdb
File
.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
@@ -34,6 +34,7 @@ struct SSttFWriterConf {
...
@@ -34,6 +34,7 @@ struct SSttFWriterConf {
STsdb
*
pTsdb
;
STsdb
*
pTsdb
;
SSkmInfo
*
pSkmTb
;
SSkmInfo
*
pSkmTb
;
SSkmInfo
*
pSkmRow
;
SSkmInfo
*
pSkmRow
;
STFile
file
;
int32_t
maxRow
;
int32_t
maxRow
;
int32_t
szPage
;
int32_t
szPage
;
int8_t
cmprAlg
;
int8_t
cmprAlg
;
...
...
source/dnode/vnode/src/tsdb/dev/tsdbUtil.c
浏览文件 @
052d9c6e
...
@@ -11,4 +11,6 @@
...
@@ -11,4 +11,6 @@
*
*
* You should have received a copy of the GNU Affero General Public License
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
\ No newline at end of file
#include "dev.h"
\ No newline at end of file
source/dnode/vnode/src/tsdb/dev/tsdbUtil.h
浏览文件 @
052d9c6e
...
@@ -16,8 +16,6 @@
...
@@ -16,8 +16,6 @@
#ifndef _TSDB_UTIL_H
#ifndef _TSDB_UTIL_H
#define _TSDB_UTIL_H
#define _TSDB_UTIL_H
#include "tsdb.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录