Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e0b0ce23
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看板
提交
e0b0ce23
编写于
1月 29, 2023
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact more code
上级
792add53
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
86 addition
and
21 deletion
+86
-21
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
+86
-21
未找到文件。
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
浏览文件 @
e0b0ce23
...
...
@@ -29,12 +29,19 @@ extern int32_t tsdbWriteSttBlock(SDataFWriter* pWriter, SBlockData* pBlockData,
typedef
struct
STsdbDataIter2
STsdbDataIter2
;
typedef
struct
STsdbFilterInfo
STsdbFilterInfo
;
typedef
struct
{
int64_t
suid
;
int64_t
uid
;
SDelData
delData
;
}
SDelInfo
;
struct
STsdbDataIter2
{
STsdbDataIter2
*
next
;
SRBTreeNode
rbtn
;
int32_t
type
;
SRowInfo
rowInfo
;
SDelInfo
delInfo
;
union
{
// TSDB_MEM_TABLE_DATA_ITER
struct
{
...
...
@@ -391,6 +398,54 @@ _exit:
return
code
;
}
static
int32_t
tsdbTombFileDataIterNext
(
STsdbDataIter2
*
pIter
,
STsdbFilterInfo
*
pFilterInfo
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
for
(;;)
{
while
(
pIter
->
tIter
.
iDelData
<
taosArrayGetSize
(
pIter
->
tIter
.
aDelData
))
{
SDelData
*
pDelData
=
taosArrayGet
(
pIter
->
tIter
.
aDelData
,
pIter
->
tIter
.
iDelData
);
if
(
pFilterInfo
)
{
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_VERSION
)
{
if
(
pFilterInfo
->
sver
>
pDelData
->
version
||
pFilterInfo
->
ever
<
pDelData
->
version
)
{
pIter
->
tIter
.
iDelData
++
;
continue
;
}
}
}
pIter
->
delInfo
.
delData
=
*
pDelData
;
pIter
->
tIter
.
iDelData
++
;
goto
_exit
;
}
for
(;;)
{
if
(
pIter
->
tIter
.
iDelIdx
<
taosArrayGetSize
(
pIter
->
tIter
.
aDelIdx
))
{
SDelIdx
*
pDelIdx
=
taosArrayGet
(
pIter
->
tIter
.
aDelIdx
,
pIter
->
tIter
.
iDelIdx
);
code
=
tsdbReadDelData
(
pIter
->
tIter
.
pReader
,
pDelIdx
,
pIter
->
tIter
.
aDelData
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
pIter
->
delInfo
.
suid
=
pDelIdx
->
suid
;
pIter
->
delInfo
.
uid
=
pDelIdx
->
uid
;
pIter
->
tIter
.
iDelData
=
0
;
pIter
->
tIter
.
iDelIdx
++
;
break
;
}
else
{
pIter
->
delInfo
=
(
SDelInfo
){
0
};
goto
_exit
;
}
}
}
_exit:
if
(
code
)
{
tsdbError
(
"%s failed at line %d since %s"
,
__func__
,
lino
,
tstrerror
(
code
));
}
return
code
;
}
static
int32_t
tsdbDataIterNext2
(
STsdbDataIter2
*
pIter
,
STsdbFilterInfo
*
pFilterInfo
)
{
int32_t
code
=
0
;
...
...
@@ -401,6 +456,8 @@ static int32_t tsdbDataIterNext2(STsdbDataIter2* pIter, STsdbFilterInfo* pFilter
return
tsdbDataFileDataIterNext
(
pIter
,
pFilterInfo
);
}
else
if
(
pIter
->
type
==
TSDB_STT_FILE_DATA_ITER
)
{
return
tsdbSttFileDataIterNext
(
pIter
,
pFilterInfo
);
}
else
if
(
pIter
->
type
==
TSDB_TOMB_FILE_DATA_ITER
)
{
return
tsdbTombFileDataIterNext
(
pIter
,
pFilterInfo
);
}
else
{
ASSERT
(
0
);
return
code
;
...
...
@@ -725,23 +782,27 @@ _exit:
return
code
;
}
static
int32_t
tsdbSnapReadGetTombData
(
STsdbSnapReader
*
pReader
,
void
*
pDelInfo
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
ASSERT
(
0
);
// TODO
_exit:
if
(
code
)
{
tsdbError
(
"vgId:%d %s failed at line %d since %s"
,
TD_VID
(
pReader
->
pTsdb
->
pVnode
),
__func__
,
lino
,
tstrerror
(
code
));
static
void
tsdbSnapReadGetTombData
(
STsdbSnapReader
*
pReader
,
SDelInfo
**
ppDelInfo
)
{
if
(
pReader
->
pTIter
==
NULL
||
(
pReader
->
pTIter
->
delInfo
.
suid
==
0
&&
pReader
->
pTIter
->
delInfo
.
uid
==
0
))
{
*
ppDelInfo
=
NULL
;
}
else
{
*
ppDelInfo
=
&
pReader
->
pTIter
->
delInfo
;
}
return
code
;
}
static
int32_t
tsdbSnapReadNextTombData
(
STsdbSnapReader
*
pReader
,
void
*
pDelInfo
)
{
static
int32_t
tsdbSnapReadNextTombData
(
STsdbSnapReader
*
pReader
,
SDelInfo
**
p
pDelInfo
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
// TODO
code
=
tsdbDataIterNext2
(
pReader
->
pTIter
,
&
(
STsdbFilterInfo
){.
flag
=
TSDB_FILTER_FLAG_BY_VERSION
,
.
sver
=
pReader
->
sver
,
.
ever
=
pReader
->
ever
});
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
ppDelInfo
)
{
tsdbSnapReadGetTombData
(
pReader
,
ppDelInfo
);
}
_exit:
if
(
code
)
{
tsdbError
(
"vgId:%d %s failed at line %d since %s"
,
TD_VID
(
pReader
->
pTsdb
->
pVnode
),
__func__
,
lino
,
tstrerror
(
code
));
...
...
@@ -755,6 +816,7 @@ static int32_t tsdbSnapReadTombData(STsdbSnapReader* pReader, uint8_t** ppData)
STsdb
*
pTsdb
=
pReader
->
pTsdb
;
// open tombstone data iter if need
if
(
pReader
->
pDelFReader
==
NULL
)
{
if
(
pReader
->
fs
.
pDelFile
==
NULL
)
goto
_exit
;
...
...
@@ -764,15 +826,16 @@ static int32_t tsdbSnapReadTombData(STsdbSnapReader* pReader, uint8_t** ppData)
code
=
tsdbOpenTombFileDataIter
(
pReader
->
pDelFReader
,
&
pReader
->
pTIter
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
pReader
->
pTIter
)
{
code
=
tsdbSnapReadNextTombData
(
pReader
,
NULL
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
}
struct
{
int64_t
suid
;
int64_t
uid
;
SDelData
dData
;
}
*
pDelInfo
;
code
=
tsdbSnapReadGetTombData
(
pReader
,
&
pDelInfo
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
// loop to get tombstone data
SDelInfo
*
pDelInfo
;
tsdbSnapReadGetTombData
(
pReader
,
&
pDelInfo
);
if
(
pDelInfo
==
NULL
)
goto
_exit
;
...
...
@@ -786,7 +849,7 @@ static int32_t tsdbSnapReadTombData(STsdbSnapReader* pReader, uint8_t** ppData)
}
while
(
pDelInfo
&&
pDelInfo
->
suid
==
pReader
->
tbid
.
suid
&&
pDelInfo
->
uid
==
pReader
->
tbid
.
uid
)
{
if
(
taosArrayPush
(
pReader
->
aDelData
,
&
pDelInfo
->
dData
)
<
0
)
{
if
(
taosArrayPush
(
pReader
->
aDelData
,
&
pDelInfo
->
d
el
Data
)
<
0
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
...
...
@@ -795,6 +858,7 @@ static int32_t tsdbSnapReadTombData(STsdbSnapReader* pReader, uint8_t** ppData)
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
// encode tombstone data
if
(
taosArrayGetSize
(
pReader
->
aDelData
)
>
0
)
{
code
=
tsdbSnapCmprTombData
(
pReader
,
ppData
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
...
...
@@ -870,9 +934,9 @@ int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader) {
if
(
pReader
->
pDelFReader
)
{
tsdbDelFReaderClose
(
&
pReader
->
pDelFReader
);
}
taosArrayDestroy
(
pReader
->
aDelData
);
// timeseries
tBlockDataDestroy
(
&
pReader
->
bData
,
1
);
while
(
pReader
->
iterList
)
{
STsdbDataIter2
*
pIter
=
pReader
->
iterList
;
pReader
->
iterList
=
pIter
->
next
;
...
...
@@ -881,6 +945,7 @@ int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader) {
if
(
pReader
->
pDataFReader
)
{
tsdbDataFReaderClose
(
&
pReader
->
pDataFReader
);
}
tBlockDataDestroy
(
&
pReader
->
bData
,
1
);
// other
tDestroyTSchema
(
pReader
->
skmTable
.
pTSchema
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录