Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
705310a9
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看板
提交
705310a9
编写于
6月 08, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact commit
上级
95d94887
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
66 addition
and
75 deletion
+66
-75
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+66
-48
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
+0
-27
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
705310a9
...
...
@@ -28,6 +28,8 @@ typedef struct {
int
niters
;
// memory iterators
SCommitIter
*
iters
;
bool
isRFileSet
;
// read and commit FSET
int32_t
fid
;
SDFileSet
*
pSet
;
SReadH
readh
;
SDFileSet
wSet
;
bool
isDFileSame
;
...
...
@@ -71,7 +73,6 @@ static void tsdbDestroyCommitH(SCommitH *pCommith);
static
int32_t
tsdbCreateCommitIters
(
SCommitH
*
pCommith
);
static
void
tsdbDestroyCommitIters
(
SCommitH
*
pCommith
);
static
int
tsdbCommitToFile
(
SCommitH
*
pCommith
,
SDFileSet
*
pSet
,
int
fid
);
static
void
tsdbResetCommitFile
(
SCommitH
*
pCommith
);
static
int
tsdbSetAndOpenCommitFile
(
SCommitH
*
pCommith
,
SDFileSet
*
pSet
,
int
fid
);
static
int
tsdbCommitToTable
(
SCommitH
*
pCommith
,
int
tid
);
static
bool
tsdbCommitIsSameFile
(
SCommitH
*
pCommith
,
int
bidx
);
...
...
@@ -404,34 +405,73 @@ static void tsdbDestroyCommitH(SCommitH *pCommith) {
tsdbCloseDFileSet
(
TSDB_COMMIT_WRITE_FSET
(
pCommith
));
}
static
int
tsdbCommitToFile
(
SCommitH
*
pCommith
,
SDFileSet
*
pSet
,
int
fid
)
{
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
static
int32_t
tsdbCommitToFileStart
(
SCommitH
*
pCHandle
,
SDFileSet
*
pSet
,
int32_t
fid
)
{
int32_t
code
=
0
;
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCHandle
);
STsdbKeepCfg
*
pCfg
=
REPO_KEEP_CFG
(
pRepo
);
ASSERT
(
pSet
==
NULL
||
pSet
->
fid
==
fid
);
tsdbResetCommitFile
(
pCommith
);
tsdbGetFidKeyRange
(
pCfg
->
days
,
pCfg
->
precision
,
fid
,
&
(
pCommith
->
minKey
),
&
(
pCommith
->
maxKey
));
pCHandle
->
fid
=
fid
;
pCHandle
->
pSet
=
pSet
;
pCHandle
->
isRFileSet
=
false
;
pCHandle
->
isDFileSame
=
false
;
pCHandle
->
isLFileSame
=
false
;
taosArrayClear
(
pCHandle
->
aBlkIdx
);
tsdbGetFidKeyRange
(
pCfg
->
days
,
pCfg
->
precision
,
fid
,
&
(
pCHandle
->
minKey
),
&
(
pCHandle
->
maxKey
));
code
=
tsdbSetAndOpenCommitFile
(
pCHandle
,
pSet
,
fid
);
return
code
;
}
static
int32_t
tsdbCommitToFileImpl
(
SCommitH
*
pCHandle
)
{
int32_t
code
=
0
;
// TODO
return
code
;
}
static
int32_t
tsdbCommitToFileEnd
(
SCommitH
*
pCommith
)
{
int32_t
code
=
0
;
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
// Set and open files
if
(
tsdbSetAndOpenCommitFile
(
pCommith
,
pSet
,
fid
)
<
0
)
{
if
(
tsdbWriteBlockIdx
(
TSDB_COMMIT_HEAD_FILE
(
pCommith
),
pCommith
->
aBlkIdx
,
(
void
**
)(
&
(
TSDB_COMMIT_BUF
(
pCommith
))))
<
0
)
{
tsdbError
(
"vgId:%d, failed to write SBlockIdx part to FSET %d since %s"
,
REPO_ID
(
pRepo
),
pCommith
->
fid
,
tstrerror
(
terrno
));
tsdbCloseCommitFile
(
pCommith
,
true
);
// revert the file change
tsdbApplyDFileSetChange
(
TSDB_COMMIT_WRITE_FSET
(
pCommith
),
pCommith
->
pSet
);
return
-
1
;
}
#if 0
// Loop to commit each table data
for (int tid = 0; tid < pCommith->niters; tid++) {
SCommitIter *pIter = pCommith->iters + tid;
if (pIter->pTable == NULL) continue;
if
(
tsdbUpdateDFileSetHeader
(
&
(
pCommith
->
wSet
))
<
0
)
{
tsdbError
(
"vgId:%d, failed to update FSET %d header since %s"
,
REPO_ID
(
pRepo
),
pCommith
->
fid
,
tstrerror
(
terrno
));
tsdbCloseCommitFile
(
pCommith
,
true
);
// revert the file change
tsdbApplyDFileSetChange
(
TSDB_COMMIT_WRITE_FSET
(
pCommith
),
pCommith
->
pSet
);
return
-
1
;
}
if (tsdbCommitToTable(pCommith, tid) < 0) {
tsdbCloseCommitFile(pCommith, true);
// revert the file change
tsdbApplyDFileSetChange(TSDB_COMMIT_WRITE_FSET(pCommith), pSet);
return -1;
}
// Close commit file
tsdbCloseCommitFile
(
pCommith
,
false
);
if
(
tsdbUpdateDFileSet
(
REPO_FS
(
pRepo
),
&
(
pCommith
->
wSet
))
<
0
)
{
return
-
1
;
}
#endif
return
code
;
}
static
int32_t
tsdbCommitToFile
(
SCommitH
*
pCommith
,
SDFileSet
*
pSet
,
int
fid
)
{
int32_t
code
=
0
;
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
STsdbKeepCfg
*
pCfg
=
REPO_KEEP_CFG
(
pRepo
);
// commit to file start
code
=
tsdbCommitToFileStart
(
pCommith
,
pSet
,
fid
);
if
(
code
)
{
goto
_err
;
}
// Loop to commit each table data in mem and file
int
mIter
=
0
,
fIter
=
0
;
int
nBlkIdx
=
taosArrayGetSize
(
pCommith
->
readh
.
aBlkIdx
);
...
...
@@ -476,31 +516,16 @@ static int tsdbCommitToFile(SCommitH *pCommith, SDFileSet *pSet, int fid) {
}
}
if
(
tsdbWriteBlockIdx
(
TSDB_COMMIT_HEAD_FILE
(
pCommith
),
pCommith
->
aBlkIdx
,
(
void
**
)(
&
(
TSDB_COMMIT_BUF
(
pCommith
))))
<
0
)
{
tsdbError
(
"vgId:%d, failed to write SBlockIdx part to FSET %d since %s"
,
REPO_ID
(
pRepo
),
fid
,
tstrerror
(
terrno
));
tsdbCloseCommitFile
(
pCommith
,
true
);
// revert the file change
tsdbApplyDFileSetChange
(
TSDB_COMMIT_WRITE_FSET
(
pCommith
),
pSet
);
return
-
1
;
}
if
(
tsdbUpdateDFileSetHeader
(
&
(
pCommith
->
wSet
))
<
0
)
{
tsdbError
(
"vgId:%d, failed to update FSET %d header since %s"
,
REPO_ID
(
pRepo
),
fid
,
tstrerror
(
terrno
));
tsdbCloseCommitFile
(
pCommith
,
true
);
// revert the file change
tsdbApplyDFileSetChange
(
TSDB_COMMIT_WRITE_FSET
(
pCommith
),
pSet
);
return
-
1
;
// commit to file end
code
=
tsdbCommitToFileEnd
(
pCommith
);
if
(
code
)
{
goto
_err
;
}
// Close commit file
tsdbCloseCommitFile
(
pCommith
,
false
);
if
(
tsdbUpdateDFileSet
(
REPO_FS
(
pRepo
),
&
(
pCommith
->
wSet
))
<
0
)
{
return
-
1
;
}
return
code
;
return
0
;
_err:
return
code
;
}
static
int32_t
tsdbCreateCommitIters
(
SCommitH
*
pCommith
)
{
...
...
@@ -557,13 +582,6 @@ static void tsdbDestroyCommitIters(SCommitH *pCommith) {
pCommith
->
niters
=
0
;
}
static
void
tsdbResetCommitFile
(
SCommitH
*
pCommith
)
{
pCommith
->
isRFileSet
=
false
;
pCommith
->
isDFileSame
=
false
;
pCommith
->
isLFileSame
=
false
;
taosArrayClear
(
pCommith
->
aBlkIdx
);
}
static
int
tsdbSetAndOpenCommitFile
(
SCommitH
*
pCommith
,
SDFileSet
*
pSet
,
int
fid
)
{
SDiskID
did
;
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
...
...
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
浏览文件 @
705310a9
...
...
@@ -196,33 +196,6 @@ int tsdbSetReadTable(SReadH *pReadh, STable *pTable) {
}
else
{
pReadh
->
pBlkIdx
=
(
SBlockIdx
*
)
p
;
}
// size_t size = taosArrayGetSize(pReadh->aBlkIdx);
// if (size > 0) {
// while (true) {
// if (pReadh->cidx >= size) {
// pReadh->pBlkIdx = NULL;
// break;
// }
// SBlockIdx *pBlkIdx = taosArrayGet(pReadh->aBlkIdx, pReadh->cidx);
// if (pBlkIdx->uid == TABLE_TID(pTable)) {
// if (pBlkIdx->uid == TABLE_UID(pTable)) {
// pReadh->pBlkIdx = pBlkIdx;
// } else {
// pReadh->pBlkIdx = NULL;
// }
// pReadh->cidx++;
// break;
// } else if (pBlkIdx->uid > TABLE_TID(pTable)) {
// pReadh->pBlkIdx = NULL;
// break;
// } else {
// pReadh->cidx++;
// }
// }
// } else {
// pReadh->pBlkIdx = NULL;
// }
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录