Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2f51c609
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看板
提交
2f51c609
编写于
4月 11, 2023
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
a72633d7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
158 addition
and
68 deletion
+158
-68
source/dnode/vnode/src/tsdb/dev/tsdbCommit.c
source/dnode/vnode/src/tsdb/dev/tsdbCommit.c
+23
-6
source/dnode/vnode/src/tsdb/dev/tsdbSttFWriter.c
source/dnode/vnode/src/tsdb/dev/tsdbSttFWriter.c
+135
-62
未找到文件。
source/dnode/vnode/src/tsdb/dev/tsdbCommit.c
浏览文件 @
2f51c609
...
...
@@ -249,14 +249,27 @@ static int32_t end_commit_file_set(SCommitter *pCommitter) {
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
code
=
tsdbSttFWriterClose
(
&
pCommitter
->
pWriter
,
0
,
pFileOp
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
//
code
=
tsdbSttFWriterClose
(
//
&
pCommitter
->
pWriter
,
//
0
,
//
pFileOp
),
//
lino
,
//
_exit
);
_exit:
if
(
code
)
{
tsdbError
(
"vgId:%d failed at line %d since %s"
,
TD_VID
(
pCommitter
->
pTsdb
->
pVnode
),
lino
,
tstrerror
(
code
));
tsdbError
(
//
"vgId:%d failed at line %d since %s"
,
//
TD_VID
(
pCommitter
->
pTsdb
->
pVnode
),
//
lino
,
//
tstrerror
(
code
));
}
else
{
tsdbDebug
(
"vgId:%d %s done, fid:%d"
,
TD_VID
(
pCommitter
->
pTsdb
->
pVnode
),
__func__
,
pCommitter
->
fid
);
tsdbDebug
(
//
"vgId:%d %s done, fid:%d"
,
//
TD_VID
(
pCommitter
->
pTsdb
->
pVnode
),
//
__func__
,
//
pCommitter
->
fid
);
}
return
code
;
}
...
...
@@ -284,8 +297,12 @@ static int32_t commit_next_file_set(SCommitter *pCommitter) {
_exit:
if
(
code
)
{
tsdbError
(
"vgId:%d %s failed at line %d since %s"
,
TD_VID
(
pCommitter
->
pTsdb
->
pVnode
),
__func__
,
lino
,
tstrerror
(
code
));
tsdbError
(
//
"vgId:%d %s failed at line %d since %s"
,
//
TD_VID
(
pCommitter
->
pTsdb
->
pVnode
),
//
__func__
,
//
lino
,
//
tstrerror
(
code
));
}
return
code
;
}
...
...
source/dnode/vnode/src/tsdb/dev/tsdbSttFWriter.c
浏览文件 @
2f51c609
...
...
@@ -60,8 +60,8 @@ static int32_t write_timeseries_block(struct SSttFWriter *pWriter) {
}
pSttBlk
->
suid
=
pBData
->
suid
;
pSttBlk
->
minUid
=
pBData
->
aUid
[
0
];
pSttBlk
->
maxUid
=
pBData
->
aUid
[
pBData
->
nRow
-
1
];
pSttBlk
->
minUid
=
pBData
->
uid
?
pBData
->
uid
:
pBData
->
aUid
[
0
];
pSttBlk
->
maxUid
=
pBData
->
uid
?
pBData
->
uid
:
pBData
->
aUid
[
pBData
->
nRow
-
1
];
pSttBlk
->
minKey
=
pSttBlk
->
maxKey
=
pBData
->
aTSKEY
[
0
];
pSttBlk
->
minVer
=
pSttBlk
->
maxVer
=
pBData
->
aVersion
[
0
];
pSttBlk
->
nRow
=
pBData
->
nRow
;
...
...
@@ -72,7 +72,6 @@ static int32_t write_timeseries_block(struct SSttFWriter *pWriter) {
if
(
pSttBlk
->
maxVer
<
pBData
->
aVersion
[
iRow
])
pSttBlk
->
maxVer
=
pBData
->
aVersion
[
iRow
];
}
// compress data block
TSDB_CHECK_CODE
(
//
code
=
tCmprBlockData
(
//
pBData
,
//
...
...
@@ -178,6 +177,8 @@ static int32_t write_delete_block(struct SSttFWriter *pWriter) {
int32_t
code
=
0
;
int32_t
lino
;
ASSERTS
(
0
,
"TODO: Not implemented yet"
);
SDelBlk
*
pDelBlk
=
taosArrayReserve
(
pWriter
->
aDelBlk
,
1
);
if
(
pDelBlk
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -195,16 +196,16 @@ static int32_t write_delete_block(struct SSttFWriter *pWriter) {
if
(
pDelBlk
->
maxVer
<
pWriter
->
sData
.
aData
[
2
][
iRow
])
pDelBlk
->
maxVer
=
pWriter
->
sData
.
aData
[
2
][
iRow
];
}
pDelBlk
->
dp
.
offset
=
pWriter
->
config
.
f
ile
.
size
;
pDelBlk
->
dp
.
offset
=
pWriter
->
tF
ile
.
size
;
pDelBlk
->
dp
.
size
=
0
;
// TODO
int64_t
tsize
=
sizeof
(
int64_t
)
*
pWriter
->
dData
.
nRow
;
for
(
int32_t
i
=
0
;
i
<
ARRAY_SIZE
(
pWriter
->
dData
.
aData
);
i
++
)
{
code
=
tsdbWriteFile
(
pWriter
->
pFd
,
pWriter
->
config
.
f
ile
.
size
,
(
const
uint8_t
*
)
pWriter
->
dData
.
aData
[
i
],
tsize
);
code
=
tsdbWriteFile
(
pWriter
->
pFd
,
pWriter
->
tF
ile
.
size
,
(
const
uint8_t
*
)
pWriter
->
dData
.
aData
[
i
],
tsize
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
pDelBlk
->
dp
.
size
+=
tsize
;
pWriter
->
config
.
f
ile
.
size
+=
tsize
;
pWriter
->
tF
ile
.
size
+=
tsize
;
}
tDelBlockDestroy
(
&
pWriter
->
dData
);
...
...
@@ -223,21 +224,30 @@ static int32_t write_stt_blk(struct SSttFWriter *pWriter) {
int32_t
code
=
0
;
int32_t
lino
;
pWriter
->
footer
.
dict
[
1
].
offset
=
pWriter
->
config
.
f
ile
.
size
;
pWriter
->
footer
.
dict
[
1
].
offset
=
pWriter
->
tF
ile
.
size
;
pWriter
->
footer
.
dict
[
1
].
size
=
sizeof
(
SSttBlk
)
*
taosArrayGetSize
(
pWriter
->
aSttBlk
);
if
(
pWriter
->
footer
.
dict
[
1
].
size
)
{
code
=
tsdbWriteFile
(
pWriter
->
pFd
,
pWriter
->
config
.
file
.
size
,
TARRAY_DATA
(
pWriter
->
aSttBlk
),
pWriter
->
footer
.
dict
[
1
].
size
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
//
code
=
tsdbWriteFile
(
//
pWriter
->
pFd
,
//
pWriter
->
tFile
.
size
,
//
TARRAY_DATA
(
pWriter
->
aSttBlk
),
//
pWriter
->
footer
.
dict
[
1
].
size
),
//
lino
,
//
_exit
);
pWriter
->
config
.
f
ile
.
size
+=
pWriter
->
footer
.
dict
[
1
].
size
;
pWriter
->
tF
ile
.
size
+=
pWriter
->
footer
.
dict
[
1
].
size
;
}
_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
;
}
...
...
@@ -246,21 +256,30 @@ static int32_t write_statistics_blk(struct SSttFWriter *pWriter) {
int32_t
code
=
0
;
int32_t
lino
;
pWriter
->
footer
.
dict
[
2
].
offset
=
pWriter
->
config
.
f
ile
.
size
;
pWriter
->
footer
.
dict
[
2
].
offset
=
pWriter
->
tF
ile
.
size
;
pWriter
->
footer
.
dict
[
2
].
size
=
sizeof
(
STbStatisBlock
)
*
taosArrayGetSize
(
pWriter
->
aStatisBlk
);
if
(
pWriter
->
footer
.
dict
[
2
].
size
)
{
code
=
tsdbWriteFile
(
pWriter
->
pFd
,
pWriter
->
config
.
file
.
size
,
TARRAY_DATA
(
pWriter
->
aStatisBlk
),
pWriter
->
footer
.
dict
[
2
].
size
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
//
code
=
tsdbWriteFile
(
//
pWriter
->
pFd
,
//
pWriter
->
tFile
.
size
,
//
TARRAY_DATA
(
pWriter
->
aStatisBlk
),
//
pWriter
->
footer
.
dict
[
2
].
size
),
//
lino
,
//
_exit
);
pWriter
->
config
.
f
ile
.
size
+=
pWriter
->
footer
.
dict
[
2
].
size
;
pWriter
->
tF
ile
.
size
+=
pWriter
->
footer
.
dict
[
2
].
size
;
}
_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
;
}
...
...
@@ -269,29 +288,41 @@ static int32_t write_del_blk(struct SSttFWriter *pWriter) {
int32_t
code
=
0
;
int32_t
lino
;
pWriter
->
footer
.
dict
[
3
].
offset
=
pWriter
->
config
.
f
ile
.
size
;
pWriter
->
footer
.
dict
[
3
].
offset
=
pWriter
->
tF
ile
.
size
;
pWriter
->
footer
.
dict
[
3
].
size
=
sizeof
(
SDelBlk
)
*
taosArrayGetSize
(
pWriter
->
aDelBlk
);
if
(
pWriter
->
footer
.
dict
[
3
].
size
)
{
code
=
tsdbWriteFile
(
pWriter
->
pFd
,
pWriter
->
config
.
file
.
size
,
TARRAY_DATA
(
pWriter
->
aDelBlk
),
pWriter
->
footer
.
dict
[
3
].
size
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
//
code
=
tsdbWriteFile
(
//
pWriter
->
pFd
,
//
pWriter
->
tFile
.
size
,
//
TARRAY_DATA
(
pWriter
->
aDelBlk
),
//
pWriter
->
footer
.
dict
[
3
].
size
),
//
lino
,
//
_exit
);
pWriter
->
config
.
f
ile
.
size
+=
pWriter
->
footer
.
dict
[
3
].
size
;
pWriter
->
tF
ile
.
size
+=
pWriter
->
footer
.
dict
[
3
].
size
;
}
_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
;
}
static
int32_t
write_file_footer
(
struct
SSttFWriter
*
pWriter
)
{
int32_t
code
=
tsdbWriteFile
(
pWriter
->
pFd
,
pWriter
->
config
.
file
.
size
,
(
const
uint8_t
*
)
&
pWriter
->
footer
,
sizeof
(
pWriter
->
footer
));
pWriter
->
config
.
file
.
size
+=
sizeof
(
pWriter
->
footer
);
int32_t
code
=
tsdbWriteFile
(
//
pWriter
->
pFd
,
//
pWriter
->
tFile
.
size
,
//
(
const
uint8_t
*
)
&
pWriter
->
footer
,
//
sizeof
(
pWriter
->
footer
));
pWriter
->
tFile
.
size
+=
sizeof
(
pWriter
->
footer
);
return
code
;
}
...
...
@@ -350,18 +381,19 @@ _exit:
static
int32_t
destroy_stt_fwriter
(
struct
SSttFWriter
*
pWriter
)
{
if
(
pWriter
)
{
for
(
int32_t
i
=
0
;
ARRAY_SIZE
(
pWriter
->
aBuf
);
i
++
)
tFree
(
pWriter
->
aBuf
[
i
]);
for
(
int32_t
i
=
0
;
i
<
ARRAY_SIZE
(
pWriter
->
aBuf
);
i
++
)
{
tFree
(
pWriter
->
aBuf
[
i
]);
}
tDestroyTSchema
(
pWriter
->
skmRow
.
pTSchema
);
tDestroyTSchema
(
pWriter
->
skmTb
.
pTSchema
);
// statistics data block
taosArrayDestroy
(
pWriter
->
aStatisBlk
);
tTbStatisBlockDestroy
(
&
pWriter
->
sData
);
// deleted data block
taosArrayDestroy
(
pWriter
->
aDelBlk
);
tDelBlockDestroy
(
&
pWriter
->
dData
);
// time-series data block
taosArrayDestroy
(
pWriter
->
aSttBlk
);
tBlockDataDestroy
(
&
pWriter
->
bData
);
taosArrayDestroy
(
pWriter
->
aStatisBlk
);
taosArrayDestroy
(
pWriter
->
aDelBlk
);
taosArrayDestroy
(
pWriter
->
aSttBlk
);
taosMemoryFree
(
pWriter
);
}
return
0
;
...
...
@@ -453,45 +485,86 @@ int32_t tsdbSttFWriterClose(struct SSttFWriter **ppWriter, int8_t abort, struct
int32_t
code
=
0
;
int32_t
lino
;
if
(
ppWriter
[
0
]
->
bData
.
nRow
>
0
)
{
code
=
write_timeseries_block
(
ppWriter
[
0
]);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
if
(
!
abort
)
{
if
(
ppWriter
[
0
]
->
bData
.
nRow
>
0
)
{
TSDB_CHECK_CODE
(
//
code
=
write_timeseries_block
(
ppWriter
[
0
]),
//
lino
,
//
_exit
);
}
if
(
ppWriter
[
0
]
->
sData
.
nRow
>
0
)
{
code
=
write_statistics_block
(
ppWriter
[
0
]);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
if
(
ppWriter
[
0
]
->
sData
.
nRow
>
0
)
{
TSDB_CHECK_CODE
(
//
code
=
write_statistics_block
(
ppWriter
[
0
]),
//
lino
,
//
_exit
);
}
if
(
ppWriter
[
0
]
->
dData
.
nRow
>
0
)
{
code
=
write_delete_block
(
ppWriter
[
0
]);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
if
(
ppWriter
[
0
]
->
dData
.
nRow
>
0
)
{
TSDB_CHECK_CODE
(
//
code
=
write_delete_block
(
ppWriter
[
0
]),
//
lino
,
//
_exit
);
}
code
=
write_stt_blk
(
ppWriter
[
0
]);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
//
code
=
write_stt_blk
(
ppWriter
[
0
]),
//
lino
,
//
_exit
);
code
=
write_statistics_blk
(
ppWriter
[
0
]);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
//
code
=
write_statistics_blk
(
ppWriter
[
0
]),
//
lino
,
//
_exit
);
code
=
write_del_blk
(
ppWriter
[
0
]);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
//
code
=
write_del_blk
(
ppWriter
[
0
]),
//
lino
,
//
_exit
);
code
=
write_file_footer
(
ppWriter
[
0
]);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
//
code
=
write_file_footer
(
ppWriter
[
0
]),
//
lino
,
//
_exit
);
code
=
write_file_header
(
ppWriter
[
0
]);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
//
code
=
write_file_header
(
ppWriter
[
0
]),
//
lino
,
//
_exit
);
code
=
close_stt_fwriter
(
ppWriter
[
0
]);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
//
code
=
tsdbFsyncFile
(
ppWriter
[
0
]
->
pFd
),
//
lino
,
//
_exit
);
if
(
op
)
{
op
->
oState
=
ppWriter
[
0
]
->
config
.
file
;
op
->
nState
=
ppWriter
[
0
]
->
tFile
;
if
(
op
->
oState
.
size
==
0
)
{
op
->
op
=
TSDB_FOP_CREATE
;
}
else
{
op
->
op
=
TSDB_FOP_EXTEND
;
}
}
}
TSDB_CHECK_CODE
(
//
code
=
close_stt_fwriter
(
ppWriter
[
0
]),
//
lino
,
//
_exit
);
destroy_stt_fwriter
(
ppWriter
[
0
]);
ppWriter
[
0
]
=
NULL
;
_exit:
if
(
code
)
{
tsdbError
(
"vgId:%d %s failed at line %d since %s"
,
vgId
,
__func__
,
lino
,
tstrerror
(
code
));
tsdbError
(
//
"vgId:%d %s failed at line %d since %s"
,
//
vgId
,
//
__func__
,
//
lino
,
//
tstrerror
(
code
));
}
else
{
}
return
code
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录