Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
23e82ff6
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看板
提交
23e82ff6
编写于
8月 23, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
bc9f53dd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
59 addition
and
90 deletion
+59
-90
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+1
-0
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+42
-90
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+16
-0
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
23e82ff6
...
...
@@ -172,6 +172,7 @@ int32_t tGetDelData(uint8_t *p, void *ph);
void
tMapDataReset
(
SMapData
*
pMapData
);
void
tMapDataClear
(
SMapData
*
pMapData
);
int32_t
tMapDataPutItem
(
SMapData
*
pMapData
,
void
*
pItem
,
int32_t
(
*
tPutItemFn
)(
uint8_t
*
,
void
*
));
int32_t
tMapDataCopy
(
SMapData
*
pFrom
,
SMapData
*
pTo
);
void
tMapDataGetItemByIdx
(
SMapData
*
pMapData
,
int32_t
idx
,
void
*
pItem
,
int32_t
(
*
tGetItemFn
)(
uint8_t
*
,
void
*
));
int32_t
tMapDataSearch
(
SMapData
*
pMapData
,
void
*
pSearchItem
,
int32_t
(
*
tGetItemFn
)(
uint8_t
*
,
void
*
),
int32_t
(
*
tItemCmprFn
)(
const
void
*
,
const
void
*
),
void
*
pItem
);
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
23e82ff6
...
...
@@ -591,7 +591,7 @@ _err:
return
code
;
}
static
int32_t
tsdbMergeCommitData
(
SCommitter
*
pCommitter
,
STbDataIter
*
pIter
,
SBlock
*
pBlock
)
{
static
int32_t
tsdbMergeCommitData
Block
(
SCommitter
*
pCommitter
,
STbDataIter
*
pIter
,
SBlock
*
pBlock
)
{
int32_t
code
=
0
;
STbData
*
pTbData
=
pIter
->
pTbData
;
SBlockData
*
pBlockDataR
=
&
pCommitter
->
dReader
.
bData
;
...
...
@@ -941,25 +941,9 @@ _err:
return
code
;
}
static
int32_t
tsdb
CommitTableData
(
SCommitter
*
pCommitter
,
STbData
*
pTbData
)
{
static
int32_t
tsdb
MergeCommitData
(
SCommitter
*
pCommitter
,
STbDataIter
*
pIter
)
{
int32_t
code
=
0
;
ASSERT
(
pCommitter
->
dReader
.
pBlockIdx
==
NULL
||
tTABLEIDCmprFn
(
pCommitter
->
dReader
.
pBlockIdx
,
pTbData
)
>=
0
);
ASSERT
(
pCommitter
->
dReader
.
pRowInfo
==
NULL
||
tTABLEIDCmprFn
(
pCommitter
->
dReader
.
pRowInfo
,
pTbData
)
>=
0
);
// merge commit table data
STbDataIter
iter
=
{
0
};
STbDataIter
*
pIter
=
&
iter
;
TSDBROW
*
pRow
;
tsdbTbDataIterOpen
(
pTbData
,
&
(
TSDBKEY
){.
ts
=
pCommitter
->
minKey
,
.
version
=
VERSION_MIN
},
0
,
pIter
);
pRow
=
tsdbTbDataIterGet
(
pIter
);
if
(
pRow
&&
TSDBROW_TS
(
pRow
)
>
pCommitter
->
maxKey
)
{
pRow
=
NULL
;
}
if
(
pRow
==
NULL
)
goto
_exit
;
int32_t
iBlock
=
0
;
SBlock
block
;
SBlock
*
pBlock
=
&
block
;
...
...
@@ -1010,7 +994,7 @@ static int32_t tsdbCommitTableData(SCommitter *pCommitter, STbData *pTbData) {
code
=
tsdbMergeAsSubBlock
(
pCommitter
,
pIter
,
pBlock
);
if
(
code
)
goto
_err
;
}
else
{
code
=
tsdbMergeCommitData
(
pCommitter
,
pIter
,
pBlock
);
code
=
tsdbMergeCommitData
Block
(
pCommitter
,
pIter
,
pBlock
);
if
(
code
)
goto
_err
;
}
...
...
@@ -1041,11 +1025,46 @@ static int32_t tsdbCommitTableData(SCommitter *pCommitter, STbData *pTbData) {
}
}
// .data append and .last merge
code
=
tsdbMergeCommitLast
(
pCommitter
,
pIter
);
_exit:
return
code
;
_err:
return
code
;
}
static
int32_t
tsdbCommitTableData
(
SCommitter
*
pCommitter
,
STbData
*
pTbData
)
{
int32_t
code
=
0
;
ASSERT
(
pCommitter
->
dReader
.
pBlockIdx
==
NULL
||
tTABLEIDCmprFn
(
pCommitter
->
dReader
.
pBlockIdx
,
pTbData
)
>=
0
);
// merge commit table data
STbDataIter
iter
=
{
0
};
TSDBROW
*
pRow
;
tsdbTbDataIterOpen
(
pTbData
,
&
(
TSDBKEY
){.
ts
=
pCommitter
->
minKey
,
.
version
=
VERSION_MIN
},
0
,
&
iter
);
pRow
=
tsdbTbDataIterGet
(
&
iter
);
if
(
pRow
&&
TSDBROW_TS
(
pRow
)
>
pCommitter
->
maxKey
)
{
pRow
=
NULL
;
}
if
(
pRow
==
NULL
)
{
if
(
pCommitter
->
dReader
.
pBlockIdx
&&
tTABLEIDCmprFn
(
pCommitter
->
dReader
.
pBlockIdx
,
pTbData
)
==
0
)
{
code
=
tMapDataCopy
(
&
pCommitter
->
dReader
.
mBlock
,
&
pCommitter
->
dWriter
.
mBlock
);
if
(
code
)
goto
_err
;
}
goto
_exit
;
}
// commit data
code
=
tsdbMergeCommitData
(
pCommitter
,
&
iter
);
if
(
code
)
goto
_err
;
// end
// commit last
code
=
tsdbMergeCommitLast
(
pCommitter
,
&
iter
);
if
(
code
)
goto
_err
;
_exit:
if
(
pCommitter
->
dWriter
.
mBlock
.
nItem
>
0
)
{
SBlockIdx
blockIdx
=
{.
suid
=
pTbData
->
suid
,
.
uid
=
pTbData
->
uid
};
code
=
tsdbWriteBlock
(
pCommitter
->
dWriter
.
pWriter
,
&
pCommitter
->
dWriter
.
mBlock
,
&
blockIdx
);
...
...
@@ -1056,9 +1075,7 @@ static int32_t tsdbCommitTableData(SCommitter *pCommitter, STbData *pTbData) {
goto
_err
;
}
}
_exit:
pRow
=
tsdbTbDataIterGet
(
pIter
);
pRow
=
tsdbTbDataIterGet
(
&
iter
);
if
(
pRow
)
{
pCommitter
->
nextKey
=
TMIN
(
pCommitter
->
nextKey
,
TSDBROW_TS
(
pRow
));
}
...
...
@@ -1126,71 +1143,6 @@ static int32_t tsdbMoveCommitData(SCommitter *pCommitter, TABLEID toTable) {
if
(
code
)
goto
_err
;
}
// .last
while
(
true
)
{
if
(
pCommitter
->
dReader
.
pRowInfo
==
NULL
||
tTABLEIDCmprFn
(
pCommitter
->
dReader
.
pRowInfo
,
&
toTable
)
>=
0
)
break
;
SBlockData
*
pBlockDataR
=
&
pCommitter
->
dReader
.
bDatal
;
SBlockData
*
pBlockDataW
=
&
pCommitter
->
dWriter
.
bDatal
;
tb_uid_t
suid
=
pCommitter
->
dReader
.
pRowInfo
->
suid
;
tb_uid_t
uid
=
pCommitter
->
dReader
.
pRowInfo
->
uid
;
ASSERT
((
pBlockDataR
->
suid
&&
!
pBlockDataR
->
uid
)
||
(
!
pBlockDataR
->
suid
&&
pBlockDataR
->
uid
));
ASSERT
(
pBlockDataR
->
nRow
>
0
);
// commit and reset block data schema if need
if
(
pBlockDataW
->
suid
||
pBlockDataW
->
uid
)
{
if
(
pBlockDataW
->
suid
!=
suid
||
pBlockDataW
->
suid
==
0
)
{
if
(
pBlockDataW
->
nRow
>
0
)
{
code
=
tsdbCommitLastBlock
(
pCommitter
);
if
(
code
)
goto
_err
;
}
tBlockDataReset
(
pBlockDataW
);
}
}
// set block data schema if need
if
(
pBlockDataW
->
suid
==
0
&&
pBlockDataW
->
uid
==
0
)
{
code
=
tsdbCommitterUpdateTableSchema
(
pCommitter
,
suid
,
uid
);
if
(
code
)
goto
_err
;
code
=
tBlockDataInit
(
pBlockDataW
,
suid
,
suid
?
0
:
uid
,
pCommitter
->
skmTable
.
pTSchema
);
if
(
code
)
goto
_err
;
}
// check if it can make sure that one table data in one block
int32_t
nRow
=
0
;
if
(
pBlockDataR
->
suid
)
{
int32_t
iRow
=
pCommitter
->
dReader
.
iRow
;
while
((
iRow
<
pBlockDataR
->
nRow
)
&&
(
pBlockDataR
->
aUid
[
iRow
]
==
uid
))
{
nRow
++
;
iRow
++
;
}
}
else
{
ASSERT
(
pCommitter
->
dReader
.
iRow
==
0
);
nRow
=
pBlockDataR
->
nRow
;
}
ASSERT
(
nRow
>
0
&&
nRow
<
pCommitter
->
minRow
);
if
(
pBlockDataW
->
nRow
+
nRow
>
pCommitter
->
maxRow
)
{
ASSERT
(
pBlockDataW
->
nRow
>
0
);
code
=
tsdbCommitLastBlock
(
pCommitter
);
if
(
code
)
goto
_err
;
}
while
(
nRow
>
0
)
{
code
=
tBlockDataAppendRow
(
pBlockDataW
,
&
pCommitter
->
dReader
.
pRowInfo
->
row
,
NULL
,
uid
);
if
(
code
)
goto
_err
;
code
=
tsdbCommitterNextLastRow
(
pCommitter
);
if
(
code
)
goto
_err
;
nRow
--
;
}
}
return
code
;
_err:
...
...
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
23e82ff6
...
...
@@ -51,6 +51,22 @@ _exit:
return
code
;
}
int32_t
tMapDataCopy
(
SMapData
*
pFrom
,
SMapData
*
pTo
)
{
int32_t
code
=
0
;
pTo
->
nItem
=
pFrom
->
nItem
;
pTo
->
nData
=
pFrom
->
nData
;
code
=
tRealloc
((
uint8_t
**
)
&
pTo
->
aOffset
,
sizeof
(
int32_t
)
*
pFrom
->
nItem
);
if
(
code
)
goto
_exit
;
code
=
tRealloc
(
&
pTo
->
pData
,
pFrom
->
nData
);
if
(
code
)
goto
_exit
;
memcpy
(
pTo
->
aOffset
,
pFrom
->
aOffset
,
sizeof
(
int32_t
)
*
pFrom
->
nItem
);
memcpy
(
pTo
->
pData
,
pFrom
->
pData
,
pFrom
->
nData
);
_exit:
return
code
;
}
int32_t
tMapDataSearch
(
SMapData
*
pMapData
,
void
*
pSearchItem
,
int32_t
(
*
tGetItemFn
)(
uint8_t
*
,
void
*
),
int32_t
(
*
tItemCmprFn
)(
const
void
*
,
const
void
*
),
void
*
pItem
)
{
int32_t
code
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录