Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d31459dc
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d31459dc
编写于
8月 27, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
ffc38e30
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
55 addition
and
65 deletion
+55
-65
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+55
-65
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
d31459dc
...
...
@@ -78,7 +78,7 @@ typedef struct {
SRBTree
rbt
;
SDataIter
dataIter
;
SDataIter
aDataIter
[
TSDB_MAX_LAST_FILE
];
int8_t
toLast
;
int8_t
toLast
Only
;
};
struct
{
SDataFWriter
*
pWriter
;
...
...
@@ -403,30 +403,31 @@ _exit:
static
int32_t
tsdbOpenCommitIter
(
SCommitter
*
pCommitter
)
{
int32_t
code
=
0
;
tRBTreeCreate
(
&
pCommitter
->
rbt
,
tRowInfoCmprFn
);
pCommitter
->
pIter
=
NULL
;
tRBTreeCreate
(
&
pCommitter
->
rbt
,
tRowInfoCmprFn
);
// memory
TSDBKEY
tKey
=
{.
ts
=
pCommitter
->
minKey
,
.
version
=
VERSION_MIN
};
SDataIter
*
pIter
=
&
pCommitter
->
dataIter
;
pIter
->
type
=
MEMORY_DATA_ITER
;
pIter
->
iTbDataP
=
0
;
for
(;
pIter
->
iTbDataP
<
taosArrayGetSize
(
pCommitter
->
aTbDataP
);
pIter
->
iTbDataP
++
)
{
STbData
*
pTbData
=
(
STbData
*
)
taosArrayGetP
(
pCommitter
->
aTbDataP
,
pIter
->
iTbDataP
);
TSDBKEY
tKey
=
{.
ts
=
pCommitter
->
minKey
,
.
version
=
VERSION_MIN
};
tsdbTbDataIterOpen
(
pTbData
,
&
tKey
,
0
,
&
pIter
->
iter
);
TSDBROW
*
pRow
=
tsdbTbDataIterGet
(
&
pIter
->
iter
);
if
(
pRow
&&
TSDBROW_TS
(
pRow
)
>
pCommitter
->
maxKey
)
{
pCommitter
->
nextKey
=
TMIN
(
pCommitter
->
nextKey
,
TSDBROW_TS
(
pRow
));
continue
;
pRow
=
NULL
;
}
if
(
pRow
==
NULL
)
continue
;
pIter
->
r
.
suid
=
pTbData
->
suid
;
pIter
->
r
.
uid
=
pTbData
->
uid
;
pIter
->
r
.
row
=
*
pRow
;
break
;
}
ASSERT
(
pIter
->
iTbDataP
<
taosArrayGetSize
(
pCommitter
->
aTbDataP
));
tRBTreePut
(
&
pCommitter
->
rbt
,
(
SRBTreeNode
*
)
pIter
);
// disk
...
...
@@ -448,17 +449,22 @@ static int32_t tsdbOpenCommitIter(SCommitter *pCommitter) {
code
=
tsdbReadLastBlockEx
(
pCommitter
->
dReader
.
pReader
,
iLast
,
pBlockL
,
&
pIter
->
bData
);
if
(
code
)
goto
_err
;
pIter
->
iRow
=
0
;
pIter
->
r
.
suid
=
pIter
->
bData
.
suid
;
pIter
->
r
.
uid
=
pIter
->
bData
.
uid
;
pIter
->
r
.
uid
=
pIter
->
bData
.
uid
?
pIter
->
bData
.
uid
:
pIter
->
bData
.
aUid
[
0
]
;
pIter
->
r
.
row
=
tsdbRowFromBlockData
(
&
pIter
->
bData
,
0
);
tRBTreePut
(
&
pCommitter
->
rbt
,
(
SRBTreeNode
*
)
pIter
);
iIter
++
;
}
pCommitter
->
toLast
=
0
;
if
(
iIter
>
0
)
{
pCommitter
->
toLastOnly
=
1
;
}
else
{
pCommitter
->
toLastOnly
=
0
;
}
}
else
{
pCommitter
->
toLast
=
1
;
pCommitter
->
toLast
Only
=
0
;
}
code
=
tsdbNextCommitRow
(
pCommitter
);
...
...
@@ -482,8 +488,8 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
pCommitter
->
nextKey
=
TSKEY_MAX
;
// Reader
pRSet
=
(
SDFileSet
*
)
taosArraySearch
(
pCommitter
->
fs
.
aDFileSet
,
&
(
SDFileSet
){.
fid
=
pCommitter
->
commitFid
},
tDFileSetCmprFn
,
TD_EQ
);
SDFileSet
tDFileSet
=
{.
fid
=
pCommitter
->
commitFid
};
pRSet
=
(
SDFileSet
*
)
taosArraySearch
(
pCommitter
->
fs
.
aDFileSet
,
&
tDFileSet
,
tDFileSetCmprFn
,
TD_EQ
);
if
(
pRSet
)
{
code
=
tsdbDataFReaderOpen
(
&
pCommitter
->
dReader
.
pReader
,
pTsdb
,
pRSet
);
if
(
code
)
goto
_err
;
...
...
@@ -493,10 +499,8 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
if
(
code
)
goto
_err
;
pCommitter
->
dReader
.
iBlockIdx
=
0
;
if
(
pCommitter
->
dReader
.
iBlockIdx
<
taosArrayGetSize
(
pCommitter
->
dReader
.
aBlockIdx
))
{
pCommitter
->
dReader
.
pBlockIdx
=
(
SBlockIdx
*
)
taosArrayGet
(
pCommitter
->
dReader
.
aBlockIdx
,
pCommitter
->
dReader
.
iBlockIdx
);
if
(
taosArrayGetSize
(
pCommitter
->
dReader
.
aBlockIdx
)
>
0
)
{
pCommitter
->
dReader
.
pBlockIdx
=
(
SBlockIdx
*
)
taosArrayGet
(
pCommitter
->
dReader
.
aBlockIdx
,
0
);
code
=
tsdbReadBlock
(
pCommitter
->
dReader
.
pReader
,
pCommitter
->
dReader
.
pBlockIdx
,
&
pCommitter
->
dReader
.
mBlock
);
if
(
code
)
goto
_err
;
}
else
{
...
...
@@ -508,47 +512,32 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
}
// Writer
SHeadFile
fHead
;
SDataFile
fData
;
SSmaFile
fSma
;
SLastFile
fLast
;
SDFileSet
wSet
=
{
0
};
SHeadFile
fHead
=
{.
commitID
=
pCommitter
->
commitID
}
;
SDataFile
fData
=
{.
commitID
=
pCommitter
->
commitID
}
;
SSmaFile
fSma
=
{.
commitID
=
pCommitter
->
commitID
}
;
SLastFile
fLast
=
{.
commitID
=
pCommitter
->
commitID
}
;
SDFileSet
wSet
=
{
.
fid
=
pCommitter
->
commitFid
,
.
pHeadF
=
&
fHead
,
.
pDataF
=
&
fData
,
.
pSmaF
=
&
fSma
};
if
(
pRSet
)
{
ASSERT
(
pCommitter
->
maxLast
==
1
||
pRSet
->
nLastF
<
pCommitter
->
maxLast
);
fHead
=
(
SHeadFile
){.
commitID
=
pCommitter
->
commitID
};
ASSERT
(
pRSet
->
nLastF
<=
pCommitter
->
maxLast
);
fData
=
*
pRSet
->
pDataF
;
fSma
=
*
pRSet
->
pSmaF
;
fLast
=
(
SLastFile
){.
commitID
=
pCommitter
->
commitID
};
wSet
.
diskId
=
pRSet
->
diskId
;
wSet
.
fid
=
pCommitter
->
commitFid
;
wSet
.
pHeadF
=
&
fHead
;
wSet
.
pDataF
=
&
fData
;
wSet
.
pSmaF
=
&
fSma
;
for
(
int8_t
iLast
=
0
;
iLast
<
pRSet
->
nLastF
;
iLast
++
)
{
wSet
.
aLastF
[
iLast
]
=
pRSet
->
aLastF
[
iLast
];
if
(
pRSet
->
nLastF
<
pCommitter
->
maxLast
)
{
for
(
int32_t
iLast
=
0
;
iLast
<
pRSet
->
nLastF
;
iLast
++
)
{
wSet
.
aLastF
[
iLast
]
=
pRSet
->
aLastF
[
iLast
];
}
wSet
.
nLastF
=
pRSet
->
nLastF
+
1
;
}
else
{
wSet
.
nLastF
=
1
;
}
wSet
.
nLastF
=
pRSet
->
nLastF
+
1
;
wSet
.
aLastF
[
wSet
.
nLastF
-
1
]
=
&
fLast
;
// todo
}
else
{
fHead
=
(
SHeadFile
){.
commitID
=
pCommitter
->
commitID
};
fData
=
(
SDataFile
){.
commitID
=
pCommitter
->
commitID
};
fSma
=
(
SSmaFile
){.
commitID
=
pCommitter
->
commitID
};
fLast
=
(
SLastFile
){.
commitID
=
pCommitter
->
commitID
};
SDiskID
did
=
{
0
};
tfsAllocDisk
(
pTsdb
->
pVnode
->
pTfs
,
0
,
&
did
);
tfsMkdirRecurAt
(
pTsdb
->
pVnode
->
pTfs
,
pTsdb
->
path
,
did
);
wSet
.
diskId
=
did
;
wSet
.
fid
=
pCommitter
->
commitFid
;
wSet
.
pHeadF
=
&
fHead
;
wSet
.
pDataF
=
&
fData
;
wSet
.
pSmaF
=
&
fSma
;
wSet
.
nLastF
=
1
;
wSet
.
aLastF
[
0
]
=
&
fLast
;
}
wSet
.
aLastF
[
wSet
.
nLastF
-
1
]
=
&
fLast
;
code
=
tsdbDataFWriterOpen
(
&
pCommitter
->
dWriter
.
pWriter
,
pTsdb
,
&
wSet
);
if
(
code
)
goto
_err
;
...
...
@@ -1722,6 +1711,9 @@ static int32_t tsdbMergeTableData(SCommitter *pCommitter, TABLEID id) {
pBlock
=
NULL
;
}
}
code
=
tsdbCommitterNextTableData
(
pCommitter
);
if
(
code
)
goto
_err
;
}
_exit:
...
...
@@ -1791,34 +1783,20 @@ _err:
static
int32_t
tsdbCommitFileDataImpl
(
SCommitter
*
pCommitter
)
{
int32_t
code
=
0
;
SRowInfo
*
pRowInfo
=
NULL
;
SRowInfo
*
pRowInfo
;
TABLEID
id
=
{
0
};
while
(
true
)
{
pRowInfo
=
tsdbGetCommitRow
(
pCommitter
);
if
(
pRowInfo
==
NULL
)
{
/* end remain table data commit*/
code
=
tsdbMoveCommitData
(
pCommitter
,
(
TABLEID
){.
suid
=
INT64_MAX
,
.
uid
=
INT64_MAX
});
if
(
code
)
goto
_err
;
if
(
pCommitter
->
dWriter
.
bDatal
.
nRow
>
0
)
{
code
=
tsdbCommitLastBlock
(
pCommitter
);
if
(
code
)
goto
_err
;
}
break
;
}
while
((
pRowInfo
=
tsdbGetCommitRow
(
pCommitter
))
!=
NULL
)
{
ASSERT
(
pRowInfo
->
suid
!=
id
.
suid
||
pRowInfo
->
uid
!=
id
.
uid
);
/* start new table data commit */
id
.
suid
=
pRowInfo
->
suid
;
id
.
uid
=
pRowInfo
->
uid
;
// reader
code
=
tsdbMoveCommitData
(
pCommitter
,
id
);
if
(
code
)
goto
_err
;
// writer
// start
tMapDataReset
(
&
pCommitter
->
dWriter
.
mBlock
);
// other
// impl
code
=
tsdbCommitterUpdateTableSchema
(
pCommitter
,
id
.
suid
,
id
.
uid
);
if
(
code
)
goto
_err
;
code
=
tBlockDataInit
(
&
pCommitter
->
dReader
.
bData
,
id
.
suid
,
id
.
uid
,
pCommitter
->
skmTable
.
pTSchema
);
...
...
@@ -1834,6 +1812,7 @@ static int32_t tsdbCommitFileDataImpl(SCommitter *pCommitter) {
code
=
tsdbCommitTableData
(
pCommitter
,
id
);
if
(
code
)
goto
_err
;
// end
if
(
pCommitter
->
dWriter
.
mBlock
.
nItem
>
0
)
{
SBlockIdx
blockIdx
=
{.
suid
=
id
.
suid
,
.
uid
=
id
.
uid
};
code
=
tsdbWriteBlock
(
pCommitter
->
dWriter
.
pWriter
,
&
pCommitter
->
dWriter
.
mBlock
,
&
blockIdx
);
...
...
@@ -1846,6 +1825,17 @@ static int32_t tsdbCommitFileDataImpl(SCommitter *pCommitter) {
}
}
id
.
suid
=
INT64_MAX
;
id
.
uid
=
INT64_MAX
;
code
=
tsdbMoveCommitData
(
pCommitter
,
id
);
if
(
code
)
goto
_err
;
// TODO: here may have problem
if
(
pCommitter
->
dWriter
.
bDatal
.
nRow
>
0
)
{
code
=
tsdbCommitLastBlock
(
pCommitter
);
if
(
code
)
goto
_err
;
}
return
code
;
_err:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录