Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
43e78919
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
43e78919
编写于
6月 09, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact
上级
fe12c092
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
69 addition
and
68 deletion
+69
-68
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+69
-68
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
43e78919
...
@@ -41,7 +41,7 @@ typedef struct {
...
@@ -41,7 +41,7 @@ typedef struct {
SArray
*
aSupBlk
;
// Table super-block array
SArray
*
aSupBlk
;
// Table super-block array
SArray
*
aSubBlk
;
// table sub-block array
SArray
*
aSubBlk
;
// table sub-block array
SDataCols
*
pDataCols
;
SDataCols
*
pDataCols
;
}
SCommit
H
;
}
SCommit
ter
;
#define TSDB_DEFAULT_BLOCK_ROWS(maxRows) ((maxRows)*4 / 5)
#define TSDB_DEFAULT_BLOCK_ROWS(maxRows) ((maxRows)*4 / 5)
...
@@ -60,42 +60,11 @@ typedef struct {
...
@@ -60,42 +60,11 @@ typedef struct {
#define TSDB_COMMIT_DEFAULT_ROWS(ch) TSDB_DEFAULT_BLOCK_ROWS(TSDB_COMMIT_REPO(ch)->pVnode->config.tsdbCfg.maxRows)
#define TSDB_COMMIT_DEFAULT_ROWS(ch) TSDB_DEFAULT_BLOCK_ROWS(TSDB_COMMIT_REPO(ch)->pVnode->config.tsdbCfg.maxRows)
#define TSDB_COMMIT_TXN_VERSION(ch) FS_TXN_VERSION(REPO_FS(TSDB_COMMIT_REPO(ch)))
#define TSDB_COMMIT_TXN_VERSION(ch) FS_TXN_VERSION(REPO_FS(TSDB_COMMIT_REPO(ch)))
static
int32_t
tsdbCommitData
(
SCommitH
*
pCommith
);
static
int32_t
tsdbCommitData
(
SCommitter
*
pCommith
);
static
int32_t
tsdbCommitDel
(
SCommitH
*
pCommith
);
static
int32_t
tsdbCommitDel
(
SCommitter
*
pCommith
);
static
int32_t
tsdbCommitCache
(
SCommitH
*
pCommith
);
static
int32_t
tsdbCommitCache
(
SCommitter
*
pCommith
);
static
int32_t
tsdbStartCommit
(
STsdb
*
pTsdb
,
SCommitH
*
pCHandle
);
static
int32_t
tsdbStartCommit
(
STsdb
*
pTsdb
,
SCommitter
*
pCHandle
);
static
int32_t
tsdbEndCommit
(
SCommitH
*
pCHandle
,
int
eno
);
static
int32_t
tsdbEndCommit
(
SCommitter
*
pCHandle
,
int
eno
);
static
int
tsdbInitCommitH
(
SCommitH
*
pCommith
,
STsdb
*
pRepo
);
static
void
tsdbSeekCommitIter
(
SCommitH
*
pCommith
,
TSKEY
key
);
static
int
tsdbNextCommitFid
(
SCommitH
*
pCommith
);
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
int
tsdbSetAndOpenCommitFile
(
SCommitH
*
pCommith
,
SDFileSet
*
pSet
,
int
fid
);
static
int
tsdbCommitToTable
(
SCommitH
*
pCommith
,
int
tid
);
static
bool
tsdbCommitIsSameFile
(
SCommitH
*
pCommith
,
int
bidx
);
static
int
tsdbMoveBlkIdx
(
SCommitH
*
pCommith
,
SBlockIdx
*
pIdx
);
static
int
tsdbSetCommitTable
(
SCommitH
*
pCommith
,
STable
*
pTable
);
static
int
tsdbComparKeyBlock
(
const
void
*
arg1
,
const
void
*
arg2
);
static
int
tsdbWriteBlockInfo
(
SCommitH
*
pCommih
);
static
int
tsdbCommitMemData
(
SCommitH
*
pCommith
,
SCommitIter
*
pIter
,
TSKEY
keyLimit
,
bool
toData
);
static
int
tsdbMergeMemData
(
SCommitH
*
pCommith
,
SCommitIter
*
pIter
,
int
bidx
);
static
int
tsdbMoveBlock
(
SCommitH
*
pCommith
,
int
bidx
);
static
int
tsdbCommitAddBlock
(
SCommitH
*
pCommith
,
const
SBlock
*
pSupBlock
,
const
SBlock
*
pSubBlocks
,
int
nSubBlocks
);
static
int
tsdbMergeBlockData
(
SCommitH
*
pCommith
,
SCommitIter
*
pIter
,
SDataCols
*
pDataCols
,
TSKEY
keyLimit
,
bool
isLastOneBlock
);
static
void
tsdbResetCommitTable
(
SCommitH
*
pCommith
);
static
void
tsdbCloseCommitFile
(
SCommitH
*
pCommith
,
bool
hasError
);
static
bool
tsdbCanAddSubBlock
(
SCommitH
*
pCommith
,
SBlock
*
pBlock
,
SMergeInfo
*
pInfo
);
static
void
tsdbLoadAndMergeFromCache
(
STsdb
*
pTsdb
,
SDataCols
*
pDataCols
,
int
*
iter
,
SCommitIter
*
pCommitIter
,
SDataCols
*
pTarget
,
TSKEY
maxKey
,
int
maxRows
,
int8_t
update
);
static
int
tsdbWriteBlockIdx
(
SDFile
*
pHeadf
,
SArray
*
pIdxA
,
void
**
ppBuf
);
static
int
tsdbApplyRtnOnFSet
(
STsdb
*
pRepo
,
SDFileSet
*
pSet
,
SRtn
*
pRtn
);
static
int
tsdbLoadDataFromCache
(
STsdb
*
pTsdb
,
STable
*
pTable
,
STbDataIter
*
pIter
,
TSKEY
maxKey
,
int
maxRowsToRead
,
SDataCols
*
pCols
,
TKEY
*
filterKeys
,
int
nFilterKeys
,
bool
keepDup
,
SMergeInfo
*
pMergeInfo
);
int32_t
tsdbBegin
(
STsdb
*
pTsdb
)
{
int32_t
tsdbBegin
(
STsdb
*
pTsdb
)
{
if
(
!
pTsdb
)
return
0
;
if
(
!
pTsdb
)
return
0
;
...
@@ -111,7 +80,7 @@ int32_t tsdbBegin(STsdb *pTsdb) {
...
@@ -111,7 +80,7 @@ int32_t tsdbBegin(STsdb *pTsdb) {
int32_t
tsdbCommit
(
STsdb
*
pTsdb
)
{
int32_t
tsdbCommit
(
STsdb
*
pTsdb
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCommit
H
commith
=
{
0
};
SCommit
ter
commith
=
{
0
};
SDFileSet
*
pSet
=
NULL
;
SDFileSet
*
pSet
=
NULL
;
int
fid
;
int
fid
;
...
@@ -154,7 +123,39 @@ _err:
...
@@ -154,7 +123,39 @@ _err:
return
code
;
return
code
;
}
}
static
int32_t
tsdbCommitData
(
SCommitH
*
pCommith
)
{
// STATIC METHODS =========================================================================================
static
int
tsdbInitCommitH
(
SCommitter
*
pCommith
,
STsdb
*
pRepo
);
static
void
tsdbSeekCommitIter
(
SCommitter
*
pCommith
,
TSKEY
key
);
static
int
tsdbNextCommitFid
(
SCommitter
*
pCommith
);
static
void
tsdbDestroyCommitH
(
SCommitter
*
pCommith
);
static
int32_t
tsdbCreateCommitIters
(
SCommitter
*
pCommith
);
static
void
tsdbDestroyCommitIters
(
SCommitter
*
pCommith
);
static
int
tsdbCommitToFile
(
SCommitter
*
pCommith
,
SDFileSet
*
pSet
,
int
fid
);
static
int
tsdbSetAndOpenCommitFile
(
SCommitter
*
pCommith
,
SDFileSet
*
pSet
,
int
fid
);
static
int
tsdbCommitToTable
(
SCommitter
*
pCommith
,
int
tid
);
static
bool
tsdbCommitIsSameFile
(
SCommitter
*
pCommith
,
int
bidx
);
static
int
tsdbMoveBlkIdx
(
SCommitter
*
pCommith
,
SBlockIdx
*
pIdx
);
static
int
tsdbSetCommitTable
(
SCommitter
*
pCommith
,
STable
*
pTable
);
static
int
tsdbComparKeyBlock
(
const
void
*
arg1
,
const
void
*
arg2
);
static
int
tsdbWriteBlockInfo
(
SCommitter
*
pCommih
);
static
int
tsdbCommitMemData
(
SCommitter
*
pCommith
,
SCommitIter
*
pIter
,
TSKEY
keyLimit
,
bool
toData
);
static
int
tsdbMergeMemData
(
SCommitter
*
pCommith
,
SCommitIter
*
pIter
,
int
bidx
);
static
int
tsdbMoveBlock
(
SCommitter
*
pCommith
,
int
bidx
);
static
int
tsdbCommitAddBlock
(
SCommitter
*
pCommith
,
const
SBlock
*
pSupBlock
,
const
SBlock
*
pSubBlocks
,
int
nSubBlocks
);
static
int
tsdbMergeBlockData
(
SCommitter
*
pCommith
,
SCommitIter
*
pIter
,
SDataCols
*
pDataCols
,
TSKEY
keyLimit
,
bool
isLastOneBlock
);
static
void
tsdbResetCommitTable
(
SCommitter
*
pCommith
);
static
void
tsdbCloseCommitFile
(
SCommitter
*
pCommith
,
bool
hasError
);
static
bool
tsdbCanAddSubBlock
(
SCommitter
*
pCommith
,
SBlock
*
pBlock
,
SMergeInfo
*
pInfo
);
static
void
tsdbLoadAndMergeFromCache
(
STsdb
*
pTsdb
,
SDataCols
*
pDataCols
,
int
*
iter
,
SCommitIter
*
pCommitIter
,
SDataCols
*
pTarget
,
TSKEY
maxKey
,
int
maxRows
,
int8_t
update
);
static
int
tsdbWriteBlockIdx
(
SDFile
*
pHeadf
,
SArray
*
pIdxA
,
void
**
ppBuf
);
static
int
tsdbApplyRtnOnFSet
(
STsdb
*
pRepo
,
SDFileSet
*
pSet
,
SRtn
*
pRtn
);
static
int
tsdbLoadDataFromCache
(
STsdb
*
pTsdb
,
STable
*
pTable
,
STbDataIter
*
pIter
,
TSKEY
maxKey
,
int
maxRowsToRead
,
SDataCols
*
pCols
,
TKEY
*
filterKeys
,
int
nFilterKeys
,
bool
keepDup
,
SMergeInfo
*
pMergeInfo
);
static
int32_t
tsdbCommitData
(
SCommitter
*
pCommith
)
{
int32_t
fid
;
int32_t
fid
;
SDFileSet
*
pSet
=
NULL
;
SDFileSet
*
pSet
=
NULL
;
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -214,13 +215,13 @@ static int32_t tsdbCommitData(SCommitH *pCommith) {
...
@@ -214,13 +215,13 @@ static int32_t tsdbCommitData(SCommitH *pCommith) {
return
code
;
return
code
;
}
}
static
int32_t
tsdbCommitDel
(
SCommit
H
*
pCommith
)
{
static
int32_t
tsdbCommitDel
(
SCommit
ter
*
pCommith
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
// TODO
// TODO
return
code
;
return
code
;
}
}
static
int32_t
tsdbCommitCache
(
SCommit
H
*
pCommith
)
{
static
int32_t
tsdbCommitCache
(
SCommit
ter
*
pCommith
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
// TODO
// TODO
return
code
;
return
code
;
...
@@ -284,7 +285,7 @@ void tsdbGetRtnSnap(STsdb *pRepo, SRtn *pRtn) {
...
@@ -284,7 +285,7 @@ void tsdbGetRtnSnap(STsdb *pRepo, SRtn *pRtn) {
pRtn
->
minFid
,
pRtn
->
midFid
,
pRtn
->
maxFid
);
pRtn
->
minFid
,
pRtn
->
midFid
,
pRtn
->
maxFid
);
}
}
static
int32_t
tsdbStartCommit
(
STsdb
*
pTsdb
,
SCommit
H
*
pCHandle
)
{
static
int32_t
tsdbStartCommit
(
STsdb
*
pTsdb
,
SCommit
ter
*
pCHandle
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
tsdbInfo
(
"vgId:%d, start to commit"
,
REPO_ID
(
pTsdb
));
tsdbInfo
(
"vgId:%d, start to commit"
,
REPO_ID
(
pTsdb
));
...
@@ -298,7 +299,7 @@ static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitH *pCHandle) {
...
@@ -298,7 +299,7 @@ static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitH *pCHandle) {
return
code
;
return
code
;
}
}
static
int32_t
tsdbEndCommit
(
SCommit
H
*
pCHandle
,
int
eno
)
{
static
int32_t
tsdbEndCommit
(
SCommit
ter
*
pCHandle
,
int
eno
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
STsdb
*
pTsdb
=
TSDB_COMMIT_REPO
(
pCHandle
);
STsdb
*
pTsdb
=
TSDB_COMMIT_REPO
(
pCHandle
);
...
@@ -312,7 +313,7 @@ static int32_t tsdbEndCommit(SCommitH *pCHandle, int eno) {
...
@@ -312,7 +313,7 @@ static int32_t tsdbEndCommit(SCommitH *pCHandle, int eno) {
return
code
;
return
code
;
}
}
static
int
tsdbInitCommitH
(
SCommit
H
*
pCommith
,
STsdb
*
pRepo
)
{
static
int
tsdbInitCommitH
(
SCommit
ter
*
pCommith
,
STsdb
*
pRepo
)
{
STsdbCfg
*
pCfg
=
REPO_CFG
(
pRepo
);
STsdbCfg
*
pCfg
=
REPO_CFG
(
pRepo
);
memset
(
pCommith
,
0
,
sizeof
(
*
pCommith
));
memset
(
pCommith
,
0
,
sizeof
(
*
pCommith
));
...
@@ -365,7 +366,7 @@ static int tsdbInitCommitH(SCommitH *pCommith, STsdb *pRepo) {
...
@@ -365,7 +366,7 @@ static int tsdbInitCommitH(SCommitH *pCommith, STsdb *pRepo) {
}
}
// Skip all keys until key (not included)
// Skip all keys until key (not included)
static
void
tsdbSeekCommitIter
(
SCommit
H
*
pCommith
,
TSKEY
key
)
{
static
void
tsdbSeekCommitIter
(
SCommit
ter
*
pCommith
,
TSKEY
key
)
{
for
(
int
i
=
0
;
i
<
pCommith
->
niters
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pCommith
->
niters
;
i
++
)
{
SCommitIter
*
pIter
=
pCommith
->
iters
+
i
;
SCommitIter
*
pIter
=
pCommith
->
iters
+
i
;
if
(
pIter
->
pTable
==
NULL
||
pIter
->
pIter
==
NULL
)
continue
;
if
(
pIter
->
pTable
==
NULL
||
pIter
->
pIter
==
NULL
)
continue
;
...
@@ -375,7 +376,7 @@ static void tsdbSeekCommitIter(SCommitH *pCommith, TSKEY key) {
...
@@ -375,7 +376,7 @@ static void tsdbSeekCommitIter(SCommitH *pCommith, TSKEY key) {
}
}
}
}
static
int
tsdbNextCommitFid
(
SCommit
H
*
pCommith
)
{
static
int
tsdbNextCommitFid
(
SCommit
ter
*
pCommith
)
{
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
STsdbKeepCfg
*
pCfg
=
REPO_KEEP_CFG
(
pRepo
);
STsdbKeepCfg
*
pCfg
=
REPO_KEEP_CFG
(
pRepo
);
int
fid
=
TSDB_IVLD_FID
;
int
fid
=
TSDB_IVLD_FID
;
...
@@ -398,7 +399,7 @@ static int tsdbNextCommitFid(SCommitH *pCommith) {
...
@@ -398,7 +399,7 @@ static int tsdbNextCommitFid(SCommitH *pCommith) {
return
fid
;
return
fid
;
}
}
static
void
tsdbDestroyCommitH
(
SCommit
H
*
pCommith
)
{
static
void
tsdbDestroyCommitH
(
SCommit
ter
*
pCommith
)
{
pCommith
->
pDataCols
=
tdFreeDataCols
(
pCommith
->
pDataCols
);
pCommith
->
pDataCols
=
tdFreeDataCols
(
pCommith
->
pDataCols
);
pCommith
->
aSubBlk
=
taosArrayDestroy
(
pCommith
->
aSubBlk
);
pCommith
->
aSubBlk
=
taosArrayDestroy
(
pCommith
->
aSubBlk
);
pCommith
->
aSupBlk
=
taosArrayDestroy
(
pCommith
->
aSupBlk
);
pCommith
->
aSupBlk
=
taosArrayDestroy
(
pCommith
->
aSupBlk
);
...
@@ -408,7 +409,7 @@ static void tsdbDestroyCommitH(SCommitH *pCommith) {
...
@@ -408,7 +409,7 @@ static void tsdbDestroyCommitH(SCommitH *pCommith) {
tsdbCloseDFileSet
(
TSDB_COMMIT_WRITE_FSET
(
pCommith
));
tsdbCloseDFileSet
(
TSDB_COMMIT_WRITE_FSET
(
pCommith
));
}
}
static
int32_t
tsdbCommitToFileStart
(
SCommit
H
*
pCHandle
,
SDFileSet
*
pSet
,
int32_t
fid
)
{
static
int32_t
tsdbCommitToFileStart
(
SCommit
ter
*
pCHandle
,
SDFileSet
*
pSet
,
int32_t
fid
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCHandle
);
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCHandle
);
STsdbKeepCfg
*
pCfg
=
REPO_KEEP_CFG
(
pRepo
);
STsdbKeepCfg
*
pCfg
=
REPO_KEEP_CFG
(
pRepo
);
...
@@ -428,12 +429,12 @@ static int32_t tsdbCommitToFileStart(SCommitH *pCHandle, SDFileSet *pSet, int32_
...
@@ -428,12 +429,12 @@ static int32_t tsdbCommitToFileStart(SCommitH *pCHandle, SDFileSet *pSet, int32_
return
code
;
return
code
;
}
}
static
int32_t
tsdbCommitToFileImpl
(
SCommit
H
*
pCHandle
)
{
static
int32_t
tsdbCommitToFileImpl
(
SCommit
ter
*
pCHandle
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
// TODO
// TODO
return
code
;
return
code
;
}
}
static
int32_t
tsdbCommitToFileEnd
(
SCommit
H
*
pCommith
)
{
static
int32_t
tsdbCommitToFileEnd
(
SCommit
ter
*
pCommith
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
...
@@ -464,7 +465,7 @@ static int32_t tsdbCommitToFileEnd(SCommitH *pCommith) {
...
@@ -464,7 +465,7 @@ static int32_t tsdbCommitToFileEnd(SCommitH *pCommith) {
return
code
;
return
code
;
}
}
static
int32_t
tsdbCommitToFile
(
SCommit
H
*
pCommith
,
SDFileSet
*
pSet
,
int
fid
)
{
static
int32_t
tsdbCommitToFile
(
SCommit
ter
*
pCommith
,
SDFileSet
*
pSet
,
int
fid
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
STsdbKeepCfg
*
pCfg
=
REPO_KEEP_CFG
(
pRepo
);
STsdbKeepCfg
*
pCfg
=
REPO_KEEP_CFG
(
pRepo
);
...
@@ -531,7 +532,7 @@ _err:
...
@@ -531,7 +532,7 @@ _err:
return
code
;
return
code
;
}
}
static
int32_t
tsdbCreateCommitIters
(
SCommit
H
*
pCommith
)
{
static
int32_t
tsdbCreateCommitIters
(
SCommit
ter
*
pCommith
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
SMemTable
*
pMem
=
pRepo
->
imem
;
SMemTable
*
pMem
=
pRepo
->
imem
;
...
@@ -568,7 +569,7 @@ _err:
...
@@ -568,7 +569,7 @@ _err:
return
code
;
return
code
;
}
}
static
void
tsdbDestroyCommitIters
(
SCommit
H
*
pCommith
)
{
static
void
tsdbDestroyCommitIters
(
SCommit
ter
*
pCommith
)
{
if
(
pCommith
->
iters
==
NULL
)
return
;
if
(
pCommith
->
iters
==
NULL
)
return
;
for
(
int
i
=
1
;
i
<
pCommith
->
niters
;
i
++
)
{
for
(
int
i
=
1
;
i
<
pCommith
->
niters
;
i
++
)
{
...
@@ -585,7 +586,7 @@ static void tsdbDestroyCommitIters(SCommitH *pCommith) {
...
@@ -585,7 +586,7 @@ static void tsdbDestroyCommitIters(SCommitH *pCommith) {
pCommith
->
niters
=
0
;
pCommith
->
niters
=
0
;
}
}
static
int
tsdbSetAndOpenCommitFile
(
SCommit
H
*
pCommith
,
SDFileSet
*
pSet
,
int
fid
)
{
static
int
tsdbSetAndOpenCommitFile
(
SCommit
ter
*
pCommith
,
SDFileSet
*
pSet
,
int
fid
)
{
SDiskID
did
;
SDiskID
did
;
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
SDFileSet
*
pWSet
=
TSDB_COMMIT_WRITE_FSET
(
pCommith
);
SDFileSet
*
pWSet
=
TSDB_COMMIT_WRITE_FSET
(
pCommith
);
...
@@ -884,7 +885,7 @@ static int tsdbWriteBlockIdx(SDFile *pHeadf, SArray *pIdxA, void **ppBuf) {
...
@@ -884,7 +885,7 @@ static int tsdbWriteBlockIdx(SDFile *pHeadf, SArray *pIdxA, void **ppBuf) {
}
}
// =================== Commit Time-Series Data
// =================== Commit Time-Series Data
static
int
tsdbCommitToTable
(
SCommit
H
*
pCommith
,
int
tid
)
{
static
int
tsdbCommitToTable
(
SCommit
ter
*
pCommith
,
int
tid
)
{
SCommitIter
*
pIter
=
pCommith
->
iters
+
tid
;
SCommitIter
*
pIter
=
pCommith
->
iters
+
tid
;
TSKEY
nextKey
=
tsdbNextIterKey
(
pIter
->
pIter
);
TSKEY
nextKey
=
tsdbNextIterKey
(
pIter
->
pIter
);
...
@@ -973,7 +974,7 @@ static int tsdbCommitToTable(SCommitH *pCommith, int tid) {
...
@@ -973,7 +974,7 @@ static int tsdbCommitToTable(SCommitH *pCommith, int tid) {
return
0
;
return
0
;
}
}
static
int
tsdbMoveBlkIdx
(
SCommit
H
*
pCommith
,
SBlockIdx
*
pIdx
)
{
static
int
tsdbMoveBlkIdx
(
SCommit
ter
*
pCommith
,
SBlockIdx
*
pIdx
)
{
SReadH
*
pReadh
=
&
pCommith
->
readh
;
SReadH
*
pReadh
=
&
pCommith
->
readh
;
STsdb
*
pTsdb
=
TSDB_READ_REPO
(
pReadh
);
STsdb
*
pTsdb
=
TSDB_READ_REPO
(
pReadh
);
STSchema
*
pTSchema
=
NULL
;
STSchema
*
pTSchema
=
NULL
;
...
@@ -1027,7 +1028,7 @@ static int tsdbMoveBlkIdx(SCommitH *pCommith, SBlockIdx *pIdx) {
...
@@ -1027,7 +1028,7 @@ static int tsdbMoveBlkIdx(SCommitH *pCommith, SBlockIdx *pIdx) {
return
0
;
return
0
;
}
}
static
int
tsdbSetCommitTable
(
SCommit
H
*
pCommith
,
STable
*
pTable
)
{
static
int
tsdbSetCommitTable
(
SCommit
ter
*
pCommith
,
STable
*
pTable
)
{
STSchema
*
pSchema
=
tsdbGetTableSchemaImpl
(
TSDB_COMMIT_REPO
(
pCommith
),
pTable
,
false
,
false
,
-
1
);
STSchema
*
pSchema
=
tsdbGetTableSchemaImpl
(
TSDB_COMMIT_REPO
(
pCommith
),
pTable
,
false
,
false
,
-
1
);
pCommith
->
pTable
=
pTable
;
pCommith
->
pTable
=
pTable
;
...
@@ -1295,7 +1296,7 @@ static int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFi
...
@@ -1295,7 +1296,7 @@ static int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFi
return
0
;
return
0
;
}
}
static
int
tsdbWriteBlock
(
SCommit
H
*
pCommith
,
SDFile
*
pDFile
,
SDataCols
*
pDataCols
,
SBlock
*
pBlock
,
bool
isLast
,
static
int
tsdbWriteBlock
(
SCommit
ter
*
pCommith
,
SDFile
*
pDFile
,
SDataCols
*
pDataCols
,
SBlock
*
pBlock
,
bool
isLast
,
bool
isSuper
)
{
bool
isSuper
)
{
return
tsdbWriteBlockImpl
(
TSDB_COMMIT_REPO
(
pCommith
),
TSDB_COMMIT_TABLE
(
pCommith
),
pDFile
,
return
tsdbWriteBlockImpl
(
TSDB_COMMIT_REPO
(
pCommith
),
TSDB_COMMIT_TABLE
(
pCommith
),
pDFile
,
isLast
?
TSDB_COMMIT_SMAL_FILE
(
pCommith
)
:
TSDB_COMMIT_SMAD_FILE
(
pCommith
),
pDataCols
,
isLast
?
TSDB_COMMIT_SMAL_FILE
(
pCommith
)
:
TSDB_COMMIT_SMAD_FILE
(
pCommith
),
pDataCols
,
...
@@ -1303,7 +1304,7 @@ static int tsdbWriteBlock(SCommitH *pCommith, SDFile *pDFile, SDataCols *pDataCo
...
@@ -1303,7 +1304,7 @@ static int tsdbWriteBlock(SCommitH *pCommith, SDFile *pDFile, SDataCols *pDataCo
(
void
**
)(
&
(
TSDB_COMMIT_COMP_BUF
(
pCommith
))),
(
void
**
)(
&
(
TSDB_COMMIT_EXBUF
(
pCommith
))));
(
void
**
)(
&
(
TSDB_COMMIT_COMP_BUF
(
pCommith
))),
(
void
**
)(
&
(
TSDB_COMMIT_EXBUF
(
pCommith
))));
}
}
static
int
tsdbWriteBlockInfo
(
SCommit
H
*
pCommih
)
{
static
int
tsdbWriteBlockInfo
(
SCommit
ter
*
pCommih
)
{
SDFile
*
pHeadf
=
TSDB_COMMIT_HEAD_FILE
(
pCommih
);
SDFile
*
pHeadf
=
TSDB_COMMIT_HEAD_FILE
(
pCommih
);
SBlockIdx
blkIdx
;
SBlockIdx
blkIdx
;
STable
*
pTable
=
TSDB_COMMIT_TABLE
(
pCommih
);
STable
*
pTable
=
TSDB_COMMIT_TABLE
(
pCommih
);
...
@@ -1325,7 +1326,7 @@ static int tsdbWriteBlockInfo(SCommitH *pCommih) {
...
@@ -1325,7 +1326,7 @@ static int tsdbWriteBlockInfo(SCommitH *pCommih) {
return
0
;
return
0
;
}
}
static
int
tsdbCommitMemData
(
SCommit
H
*
pCommith
,
SCommitIter
*
pIter
,
TSKEY
keyLimit
,
bool
toData
)
{
static
int
tsdbCommitMemData
(
SCommit
ter
*
pCommith
,
SCommitIter
*
pIter
,
TSKEY
keyLimit
,
bool
toData
)
{
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
STsdbCfg
*
pCfg
=
REPO_CFG
(
pRepo
);
STsdbCfg
*
pCfg
=
REPO_CFG
(
pRepo
);
SMergeInfo
mInfo
;
SMergeInfo
mInfo
;
...
@@ -1358,7 +1359,7 @@ static int tsdbCommitMemData(SCommitH *pCommith, SCommitIter *pIter, TSKEY keyLi
...
@@ -1358,7 +1359,7 @@ static int tsdbCommitMemData(SCommitH *pCommith, SCommitIter *pIter, TSKEY keyLi
return
0
;
return
0
;
}
}
static
int
tsdbMergeMemData
(
SCommit
H
*
pCommith
,
SCommitIter
*
pIter
,
int
bidx
)
{
static
int
tsdbMergeMemData
(
SCommit
ter
*
pCommith
,
SCommitIter
*
pIter
,
int
bidx
)
{
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
STsdbCfg
*
pCfg
=
REPO_CFG
(
pRepo
);
STsdbCfg
*
pCfg
=
REPO_CFG
(
pRepo
);
int
nBlocks
=
pCommith
->
readh
.
pBlkIdx
->
numOfBlocks
;
int
nBlocks
=
pCommith
->
readh
.
pBlkIdx
->
numOfBlocks
;
...
@@ -1430,7 +1431,7 @@ static int tsdbMergeMemData(SCommitH *pCommith, SCommitIter *pIter, int bidx) {
...
@@ -1430,7 +1431,7 @@ static int tsdbMergeMemData(SCommitH *pCommith, SCommitIter *pIter, int bidx) {
return
0
;
return
0
;
}
}
static
bool
tsdbCommitIsSameFile
(
SCommit
H
*
pCommith
,
int
bidx
)
{
static
bool
tsdbCommitIsSameFile
(
SCommit
ter
*
pCommith
,
int
bidx
)
{
SBlock
*
pBlock
=
pCommith
->
readh
.
pBlkInfo
->
blocks
+
bidx
;
SBlock
*
pBlock
=
pCommith
->
readh
.
pBlkInfo
->
blocks
+
bidx
;
if
(
pBlock
->
last
)
{
if
(
pBlock
->
last
)
{
return
pCommith
->
isLFileSame
;
return
pCommith
->
isLFileSame
;
...
@@ -1438,7 +1439,7 @@ static bool tsdbCommitIsSameFile(SCommitH *pCommith, int bidx) {
...
@@ -1438,7 +1439,7 @@ static bool tsdbCommitIsSameFile(SCommitH *pCommith, int bidx) {
return
pCommith
->
isDFileSame
;
return
pCommith
->
isDFileSame
;
}
}
static
int
tsdbMoveBlock
(
SCommit
H
*
pCommith
,
int
bidx
)
{
static
int
tsdbMoveBlock
(
SCommit
ter
*
pCommith
,
int
bidx
)
{
SBlock
*
pBlock
=
pCommith
->
readh
.
pBlkInfo
->
blocks
+
bidx
;
SBlock
*
pBlock
=
pCommith
->
readh
.
pBlkInfo
->
blocks
+
bidx
;
SDFile
*
pDFile
;
SDFile
*
pDFile
;
SBlock
block
;
SBlock
block
;
...
@@ -1477,7 +1478,7 @@ static int tsdbMoveBlock(SCommitH *pCommith, int bidx) {
...
@@ -1477,7 +1478,7 @@ static int tsdbMoveBlock(SCommitH *pCommith, int bidx) {
return
0
;
return
0
;
}
}
static
int
tsdbCommitAddBlock
(
SCommit
H
*
pCommith
,
const
SBlock
*
pSupBlock
,
const
SBlock
*
pSubBlocks
,
int
nSubBlocks
)
{
static
int
tsdbCommitAddBlock
(
SCommit
ter
*
pCommith
,
const
SBlock
*
pSupBlock
,
const
SBlock
*
pSubBlocks
,
int
nSubBlocks
)
{
if
(
taosArrayPush
(
pCommith
->
aSupBlk
,
pSupBlock
)
==
NULL
)
{
if
(
taosArrayPush
(
pCommith
->
aSupBlk
,
pSupBlock
)
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
...
@@ -1491,7 +1492,7 @@ static int tsdbCommitAddBlock(SCommitH *pCommith, const SBlock *pSupBlock, const
...
@@ -1491,7 +1492,7 @@ static int tsdbCommitAddBlock(SCommitH *pCommith, const SBlock *pSupBlock, const
return
0
;
return
0
;
}
}
static
int
tsdbMergeBlockData
(
SCommit
H
*
pCommith
,
SCommitIter
*
pIter
,
SDataCols
*
pDataCols
,
TSKEY
keyLimit
,
static
int
tsdbMergeBlockData
(
SCommit
ter
*
pCommith
,
SCommitIter
*
pIter
,
SDataCols
*
pDataCols
,
TSKEY
keyLimit
,
bool
isLastOneBlock
)
{
bool
isLastOneBlock
)
{
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
STsdbCfg
*
pCfg
=
REPO_CFG
(
pRepo
);
STsdbCfg
*
pCfg
=
REPO_CFG
(
pRepo
);
...
@@ -1628,13 +1629,13 @@ static void tsdbLoadAndMergeFromCache(STsdb *pTsdb, SDataCols *pDataCols, int *i
...
@@ -1628,13 +1629,13 @@ static void tsdbLoadAndMergeFromCache(STsdb *pTsdb, SDataCols *pDataCols, int *i
}
}
}
}
static
void
tsdbResetCommitTable
(
SCommit
H
*
pCommith
)
{
static
void
tsdbResetCommitTable
(
SCommit
ter
*
pCommith
)
{
taosArrayClear
(
pCommith
->
aSubBlk
);
taosArrayClear
(
pCommith
->
aSubBlk
);
taosArrayClear
(
pCommith
->
aSupBlk
);
taosArrayClear
(
pCommith
->
aSupBlk
);
pCommith
->
pTable
=
NULL
;
pCommith
->
pTable
=
NULL
;
}
}
static
void
tsdbCloseCommitFile
(
SCommit
H
*
pCommith
,
bool
hasError
)
{
static
void
tsdbCloseCommitFile
(
SCommit
ter
*
pCommith
,
bool
hasError
)
{
if
(
pCommith
->
isRFileSet
)
{
if
(
pCommith
->
isRFileSet
)
{
tsdbCloseAndUnsetFSet
(
&
(
pCommith
->
readh
));
tsdbCloseAndUnsetFSet
(
&
(
pCommith
->
readh
));
}
}
...
@@ -1645,7 +1646,7 @@ static void tsdbCloseCommitFile(SCommitH *pCommith, bool hasError) {
...
@@ -1645,7 +1646,7 @@ static void tsdbCloseCommitFile(SCommitH *pCommith, bool hasError) {
tsdbCloseDFileSet
(
TSDB_COMMIT_WRITE_FSET
(
pCommith
));
tsdbCloseDFileSet
(
TSDB_COMMIT_WRITE_FSET
(
pCommith
));
}
}
static
bool
tsdbCanAddSubBlock
(
SCommit
H
*
pCommith
,
SBlock
*
pBlock
,
SMergeInfo
*
pInfo
)
{
static
bool
tsdbCanAddSubBlock
(
SCommit
ter
*
pCommith
,
SBlock
*
pBlock
,
SMergeInfo
*
pInfo
)
{
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
STsdbCfg
*
pCfg
=
REPO_CFG
(
pRepo
);
STsdbCfg
*
pCfg
=
REPO_CFG
(
pRepo
);
int
mergeRows
=
pBlock
->
numOfRows
+
pInfo
->
rowsInserted
-
pInfo
->
rowsDeleteSucceed
;
int
mergeRows
=
pBlock
->
numOfRows
+
pInfo
->
rowsInserted
-
pInfo
->
rowsDeleteSucceed
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录