Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
b26006d3
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b26006d3
编写于
1月 15, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact tsdb commit
上级
44721767
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
22 addition
and
19 deletion
+22
-19
src/tsdb/src/tsdbCommit.c
src/tsdb/src/tsdbCommit.c
+22
-19
未找到文件。
src/tsdb/src/tsdbCommit.c
浏览文件 @
b26006d3
...
...
@@ -739,12 +739,6 @@ static int tsdbWriteBlock(SCommitH *pCommith, SDFile *pDFile, SDataCols *pDataCo
ASSERT
(
rowsToWrite
>
0
&&
rowsToWrite
<=
pCfg
->
maxRowsPerFileBlock
);
ASSERT
((
!
isLast
)
||
rowsToWrite
<
pCfg
->
minRowsPerFileBlock
);
// Seek file
offset
=
tsdbSeekDFile
(
pDFile
,
0
,
SEEK_END
);
if
(
offset
<
0
)
{
return
-
1
;
}
// Make buffer space
if
(
tsdbMakeRoom
((
void
**
)(
&
TSDB_COMMIT_BUF
(
pCommith
)),
TSDB_BLOCK_STATIS_SIZE
(
pDataCols
->
numOfCols
))
<
0
)
{
return
-
1
;
...
...
@@ -842,7 +836,7 @@ static int tsdbWriteBlock(SCommitH *pCommith, SDFile *pDFile, SDataCols *pDataCo
tsdbUpdateDFileMagic
(
pDFile
,
POINTER_SHIFT
(
pBlockData
,
tsize
-
sizeof
(
TSCKSUM
)));
// Write the whole block to file
if
(
tsdb
WriteDFile
(
pDFile
,
(
void
*
)
pBlockData
,
lsize
)
<
lsize
)
{
if
(
tsdb
AppendDFile
(
pDFile
,
(
void
*
)
pBlockData
,
lsize
,
&
offset
)
<
lsize
)
{
return
-
1
;
}
...
...
@@ -1005,8 +999,7 @@ static int tsdbCommitMemData(SCommitH *pCommith, SCommitIter *pIter, TSKEY keyLi
if
(
tsdbWriteBlock
(
pCommith
,
pDFile
,
pCommith
->
pDataCols
,
&
block
,
isLast
,
true
)
<
0
)
return
-
1
;
if
(
taosArrayPush
(
pCommith
->
aSupBlk
,
(
void
*
)(
&
block
))
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
if
(
tsdbCommitAddBlock
(
pCommith
,
&
block
,
NULL
,
0
)
<
0
)
{
return
-
1
;
}
}
...
...
@@ -1076,7 +1069,7 @@ static int tsdbMergeMemData(SCommitH *pCommith, SCommitIter *pIter, int bidx) {
supBlock
.
numOfRows
=
pBlock
->
numOfRows
+
mInfo
.
rowsInserted
-
mInfo
.
rowsDeleteSucceed
;
supBlock
.
offset
=
taosArrayGetSize
(
pCommith
->
aSubBlk
)
*
sizeof
(
SBlock
);
if
(
tsdbCommitAddBlock
(
pCommith
,
&
supBlock
,
subBlocks
,
pBlock
->
numOfSubBlocks
+
1
)
<
0
)
return
-
1
;
if
(
tsdbCommitAddBlock
(
pCommith
,
&
supBlock
,
subBlocks
,
supBlock
.
numOfSubBlocks
)
<
0
)
return
-
1
;
}
else
{
if
(
tsdbLoadBlockData
(
&
(
pCommith
->
readh
),
pBlock
,
NULL
)
<
0
)
return
-
1
;
if
(
tsdbMergeBlockData
(
pCommith
,
pIter
,
pCommith
->
readh
.
pDCols
[
0
],
keyLimit
,
bidx
==
(
nBlocks
-
1
))
<
0
)
return
-
1
;
...
...
@@ -1087,16 +1080,28 @@ static int tsdbMergeMemData(SCommitH *pCommith, SCommitIter *pIter, int bidx) {
static
int
tsdbMoveBlock
(
SCommitH
*
pCommith
,
int
bidx
)
{
SBlock
*
pBlock
=
pCommith
->
readh
.
pBlkInfo
->
blocks
+
bidx
;
SDFile
*
pCommitF
=
(
pBlock
->
last
)
?
TSDB_COMMIT_LAST_FILE
(
pCommith
)
:
TSDB_COMMIT_DATA_FILE
(
pCommith
);
// SDFile *pReadF = (pBlock->last) ? TSDB_READ_LAST_FILE(&(pCommith->readh)) : TSDB_READ_DATA_FILE(&(pCommith->readh));
SDFile
*
pDFile
;
SBlock
block
;
bool
isSameFile
;
ASSERT
(
pBlock
->
numOfSubBlocks
>
0
);
if
((
pBlock
->
last
&&
pCommith
->
isLFileSame
)
||
((
!
pBlock
->
last
)
&&
pCommith
->
isDFileSame
))
{
if
(
pBlock
->
last
)
{
pDFile
=
TSDB_COMMIT_LAST_FILE
(
pCommith
);
isSameFile
=
pCommith
->
isLFileSame
;
}
else
{
pDFile
=
TSDB_COMMIT_DATA_FILE
(
pCommith
);
isSameFile
=
pCommith
->
isDFileSame
;
}
if
(
isSameFile
)
{
if
(
pBlock
->
numOfSubBlocks
==
1
)
{
if
(
tsdbCommitAddBlock
(
pCommith
,
pBlock
,
NULL
,
0
)
<
0
)
return
-
1
;
if
(
tsdbCommitAddBlock
(
pCommith
,
pBlock
,
NULL
,
0
)
<
0
)
{
return
-
1
;
}
}
else
{
block
=
*
pBlock
;
block
.
offset
=
sizeof
(
SBlock
)
*
taosArrayGetSize
(
pCommith
->
aSu
p
Blk
);
block
.
offset
=
sizeof
(
SBlock
)
*
taosArrayGetSize
(
pCommith
->
aSu
b
Blk
);
if
(
tsdbCommitAddBlock
(
pCommith
,
&
block
,
POINTER_SHIFT
(
pCommith
->
readh
.
pBlkInfo
,
pBlock
->
offset
),
pBlock
->
numOfSubBlocks
)
<
0
)
{
...
...
@@ -1105,7 +1110,7 @@ static int tsdbMoveBlock(SCommitH *pCommith, int bidx) {
}
}
else
{
if
(
tsdbLoadBlockData
(
&
(
pCommith
->
readh
),
pBlock
,
NULL
)
<
0
)
return
-
1
;
if
(
tsdbWriteBlock
(
pCommith
,
p
CommitF
,
pCommith
->
readh
.
pDCols
[
0
],
&
block
,
pBlock
->
last
,
true
)
<
0
)
return
-
1
;
if
(
tsdbWriteBlock
(
pCommith
,
p
DFile
,
pCommith
->
readh
.
pDCols
[
0
],
&
block
,
pBlock
->
last
,
true
)
<
0
)
return
-
1
;
if
(
tsdbCommitAddBlock
(
pCommith
,
&
block
,
NULL
,
0
)
<
0
)
return
-
1
;
}
...
...
@@ -1113,14 +1118,12 @@ static int tsdbMoveBlock(SCommitH *pCommith, int bidx) {
}
static
int
tsdbCommitAddBlock
(
SCommitH
*
pCommith
,
const
SBlock
*
pSupBlock
,
const
SBlock
*
pSubBlocks
,
int
nSubBlocks
)
{
ASSERT
(
pSupBlock
!=
NULL
);
if
(
taosArrayPush
(
pCommith
->
aSupBlk
,
pSupBlock
)
<
0
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
-
1
;
}
if
(
pSubBlocks
&&
taosArrayPushBatch
(
pCommith
->
aSu
p
Blk
,
pSubBlocks
,
nSubBlocks
)
<
0
)
{
if
(
pSubBlocks
&&
taosArrayPushBatch
(
pCommith
->
aSu
b
Blk
,
pSubBlocks
,
nSubBlocks
)
<
0
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
-
1
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录