Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8f08aedc
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1181
Star
22014
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,发现更多精彩内容 >>
提交
8f08aedc
编写于
6月 13, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more work
上级
03f9012a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
120 addition
and
33 deletion
+120
-33
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
+112
-32
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
+0
-1
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+7
-0
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
8f08aedc
...
...
@@ -158,6 +158,7 @@ int32_t tPutDelIdx(uint8_t *p, SDelIdx *pDelIdx);
int32_t
tGetDelIdx
(
uint8_t
*
p
,
SDelIdx
*
pDelIdx
);
// SDelData
int32_t
tDelDataClear
(
SDelData
*
pDelData
);
int32_t
tDelDataPutItem
(
SDelData
*
pDelData
,
SDelDataItem
*
pItem
);
int32_t
tDelDataGetItemByIdx
(
SDelData
*
pDelData
,
SDelDataItem
*
pItem
,
int32_t
idx
);
int32_t
tDelDataGetItem
(
SDelData
*
pDelData
,
SDelDataItem
*
pItem
,
int64_t
version
);
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
8f08aedc
...
...
@@ -37,13 +37,14 @@ struct SCommitter {
SArray
*
aOBlockIdx
;
SArray
*
aBlockIdx
;
// commit table data
STbData
*
pTbData
;
SBlockIdx
*
pBlockIdx
;
/* commit del */
SDelFReader
*
pDelFReader
;
SDelFWriter
*
pDelFWriter
;
SDelIdx
delIdxOld
;
SDelIdx
delIdxNew
;
STbData
*
pTbData
;
SDelIdxItem
*
pDelIdxItem
;
SDelData
delDataOld
;
SDelData
delDataNew
;
SDelIdxItem
delIdxItem
;
...
...
@@ -207,30 +208,59 @@ _err:
static
int32_t
tsdbCommitTableDel
(
SCommitter
*
pCommitter
);
static
int32_t
tsdbCommitDelImpl
(
SCommitter
*
pCommitter
)
{
int32_t
code
=
0
;
STsdb
*
pTsdb
=
pCommitter
->
pTsdb
;
SMemTable
*
pMemTable
=
pTsdb
->
imem
;
int32_t
iTbData
=
0
;
int32_t
nTbData
=
taosArrayGetSize
(
pMemTable
->
aTbData
);
int32_t
iDelIdx
=
0
;
int32_t
nDelIdx
=
0
;
// TODO
STbData
*
pTbData
=
NULL
;
SDelIdx
*
pDelIdx
=
NULL
;
SDelIdx
delIdx
;
// if (iTbData < nTbData) {
// pTbData = (STbData *)taosArrayGetP(pMemTable->aTbData, iTbData);
// }
// if (iDelIdx < nDelIdx) {
// // tIMapGet();
// pDelIdx = &delIdx;
// }
while
(
iTbData
<
nTbData
||
iDelIdx
<
nDelIdx
)
{
if
(
pTbData
&&
pDelIdx
)
{
int32_t
code
=
0
;
STsdb
*
pTsdb
=
pCommitter
->
pTsdb
;
SMemTable
*
pMemTable
=
pTsdb
->
imem
;
int32_t
c
;
int32_t
iTbData
=
0
;
int32_t
nTbData
=
taosArrayGetSize
(
pMemTable
->
aTbData
);
int32_t
iDelIdxItem
=
0
;
int32_t
nDelIdxItem
=
pCommitter
->
delIdxOld
.
offset
.
nOffset
;
STbData
*
pTbData
=
NULL
;
SDelIdxItem
*
pDelIdxItem
=
NULL
;
SDelIdxItem
item
;
while
(
iTbData
<
nTbData
||
iDelIdxItem
<
nDelIdxItem
)
{
pTbData
=
NULL
;
pDelIdxItem
=
NULL
;
if
(
iTbData
<
nTbData
)
{
pTbData
=
(
STbData
*
)
taosArrayGetP
(
pMemTable
->
aTbData
,
iTbData
);
}
if
(
iDelIdxItem
<
nDelIdxItem
)
{
tDelIdxGetItemByIdx
(
&
pCommitter
->
delIdxOld
,
&
item
,
iDelIdxItem
);
pDelIdxItem
=
&
item
;
}
if
(
pTbData
&&
pDelIdxItem
)
{
c
=
tTABLEIDCmprFn
(
pTbData
,
pDelIdxItem
);
if
(
c
==
0
)
{
iTbData
++
;
iDelIdxItem
++
;
}
else
if
(
c
<
0
)
{
iTbData
++
;
pDelIdxItem
=
NULL
;
}
else
{
iDelIdxItem
++
;
pTbData
=
NULL
;
}
}
else
{
if
(
pTbData
)
{
iTbData
++
;
}
if
(
pDelIdxItem
)
{
iDelIdxItem
++
;
}
}
if
(
pTbData
&&
pTbData
->
pHead
==
NULL
)
{
pTbData
=
NULL
;
}
if
(
pTbData
==
NULL
&&
pDelIdxItem
==
NULL
)
continue
;
// do merge
pCommitter
->
pTbData
=
pTbData
;
pCommitter
->
pDelIdxItem
=
pDelIdxItem
;
code
=
tsdbCommitTableDel
(
pCommitter
);
if
(
code
)
goto
_err
;
}
...
...
@@ -542,17 +572,41 @@ static int32_t tsdbCommitTableDataEnd(SCommitter *pCommitter) {
}
static
int32_t
tsdbCommitTableDelStart
(
SCommitter
*
pCommitter
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
tb_uid_t
suid
;
tb_uid_t
uid
;
if
(
pCommitter
->
pTbData
)
{
suid
=
pCommitter
->
pTbData
->
suid
;
uid
=
pCommitter
->
pTbData
->
uid
;
}
// load old
pCommitter
->
delDataOld
=
(
SDelData
){
0
};
if
(
0
)
{
code
=
tsdbReadDelData
(
pCommitter
->
pDelFReader
,
NULL
/*TODO*/
,
&
pCommitter
->
delDataOld
,
&
pCommitter
->
pBuf4
);
if
(
pCommitter
->
pDelIdxItem
)
{
suid
=
pCommitter
->
pDelIdxItem
->
suid
;
uid
=
pCommitter
->
pDelIdxItem
->
uid
;
code
=
tsdbReadDelData
(
pCommitter
->
pDelFReader
,
pCommitter
->
pDelIdxItem
,
&
pCommitter
->
delDataOld
,
&
pCommitter
->
pBuf5
);
if
(
code
)
goto
_err
;
}
// prepare new
pCommitter
->
delDataNew
=
(
SDelData
){
0
};
pCommitter
->
delDataNew
.
suid
=
suid
;
pCommitter
->
delDataNew
.
uid
=
uid
;
pCommitter
->
delDataNew
.
offset
.
flag
=
0
;
pCommitter
->
delDataNew
.
offset
.
nOffset
=
0
;
pCommitter
->
delDataNew
.
nData
=
0
;
pCommitter
->
delIdxItem
=
(
SDelIdxItem
){
.
suid
=
suid
,
.
uid
=
uid
,
.
minKey
=
TSKEY_MAX
,
.
maxKey
=
TSKEY_MIN
,
.
minVersion
=
INT64_MAX
,
.
maxVersion
=
INT64_MIN
,
.
offset
=
-
1
,
.
size
=
-
1
,
};
return
code
;
...
...
@@ -562,14 +616,40 @@ _err:
}
static
int32_t
tsdbCommitTableDelImpl
(
SCommitter
*
pCommitter
)
{
int32_t
code
=
0
;
SDelOp
*
pDelOp
=
NULL
;
int32_t
code
=
0
;
SDelDataItem
item
;
// old
if
(
pCommitter
->
pDelIdxItem
)
{
for
(
int32_t
iDelIdxItem
=
0
;
iDelIdxItem
<
pCommitter
->
delDataOld
.
offset
.
nOffset
;
iDelIdxItem
++
)
{
code
=
tDelDataGetItemByIdx
(
&
pCommitter
->
delDataOld
,
&
item
,
iDelIdxItem
);
if
(
code
)
goto
_err
;
code
=
tDelDataPutItem
(
&
pCommitter
->
delDataNew
,
&
item
);
if
(
code
)
goto
_err
;
// update index
if
(
item
.
version
<
pCommitter
->
delIdxItem
.
minVersion
)
pCommitter
->
delIdxItem
.
minVersion
=
item
.
version
;
if
(
item
.
version
>
pCommitter
->
delIdxItem
.
maxVersion
)
pCommitter
->
delIdxItem
.
maxVersion
=
item
.
version
;
if
(
item
.
sKey
<
pCommitter
->
delIdxItem
.
minKey
)
pCommitter
->
delIdxItem
.
minKey
=
item
.
sKey
;
if
(
item
.
eKey
>
pCommitter
->
delIdxItem
.
maxKey
)
pCommitter
->
delIdxItem
.
maxKey
=
item
.
eKey
;
}
}
for
(;
pDelOp
;
pDelOp
=
pDelOp
->
pNext
)
{
SDelDataItem
item
=
{.
version
=
pDelOp
->
version
,
.
sKey
=
pDelOp
->
sKey
,
.
eKey
=
pDelOp
->
eKey
};
// new
if
(
pCommitter
->
pTbData
)
{
for
(
SDelOp
*
pDelOp
=
pCommitter
->
pTbData
->
pHead
;
pDelOp
;
pDelOp
=
pDelOp
->
pNext
)
{
item
=
(
SDelDataItem
){.
version
=
pDelOp
->
version
,
.
sKey
=
pDelOp
->
sKey
,
.
eKey
=
pDelOp
->
eKey
};
code
=
tDelDataPutItem
(
&
pCommitter
->
delDataNew
,
&
item
);
if
(
code
)
goto
_err
;
code
=
tDelDataPutItem
(
&
pCommitter
->
delDataNew
,
&
item
);
if
(
code
)
goto
_err
;
// update index
if
(
item
.
version
<
pCommitter
->
delIdxItem
.
minVersion
)
pCommitter
->
delIdxItem
.
minVersion
=
item
.
version
;
if
(
item
.
version
>
pCommitter
->
delIdxItem
.
maxVersion
)
pCommitter
->
delIdxItem
.
maxVersion
=
item
.
version
;
if
(
item
.
sKey
<
pCommitter
->
delIdxItem
.
minKey
)
pCommitter
->
delIdxItem
.
minKey
=
item
.
sKey
;
if
(
item
.
eKey
>
pCommitter
->
delIdxItem
.
maxKey
)
pCommitter
->
delIdxItem
.
maxKey
=
item
.
eKey
;
}
}
return
code
;
...
...
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
浏览文件 @
8f08aedc
...
...
@@ -147,7 +147,6 @@ int32_t tsdbWriteDelData(SDelFWriter *pWriter, SDelData *pDelData, uint8_t **ppB
// prepare
pDelData
->
delimiter
=
TSDB_FILE_DLMT
;
// todo
// alloc
if
(
!
ppBuf
)
ppBuf
=
&
pBuf
;
...
...
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
8f08aedc
...
...
@@ -350,6 +350,13 @@ static FORCE_INLINE int32_t tGetDelDataItem(uint8_t *p, SDelDataItem *pItem) {
}
// SDelData ======================================================
int32_t
tDelDataClear
(
SDelData
*
pDelData
)
{
int32_t
code
=
0
;
tsdbFree
(
pDelData
->
offset
.
pOffset
);
tsdbFree
(
pDelData
->
pData
);
return
code
;
}
int32_t
tDelDataPutItem
(
SDelData
*
pDelData
,
SDelDataItem
*
pItem
)
{
int32_t
code
=
0
;
uint32_t
offset
=
pDelData
->
nData
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录