Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d8e0d02e
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看板
提交
d8e0d02e
编写于
4月 30, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: do some internal refactor.
上级
05d416f3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
64 addition
and
45 deletion
+64
-45
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+64
-45
未找到文件。
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
d8e0d02e
...
...
@@ -3395,6 +3395,11 @@ static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) {
STableUidList
*
pUidList
=
&
pStatus
->
uidList
;
while
(
1
)
{
if
(
pReader
->
flag
==
READER_STATUS_SHOULD_STOP
)
{
tsdbWarn
(
"tsdb reader is stopped ASAP, %s"
,
pReader
->
idStr
);
return
TSDB_CODE_SUCCESS
;
}
STableBlockScanInfo
**
pBlockScanInfo
=
pStatus
->
pTableIter
;
initMemDataIterator
(
*
pBlockScanInfo
,
pReader
);
...
...
@@ -3474,45 +3479,67 @@ static bool fileBlockPartiallyRead(SFileBlockDumpInfo* pDumpInfo, bool asc) {
((
pDumpInfo
->
rowIndex
>
0
&&
asc
)
||
(
pDumpInfo
->
rowIndex
<
(
pDumpInfo
->
totalRows
-
1
)
&&
(
!
asc
)));
}
static
int32_t
buildBlockFromFiles
(
STsdbReader
*
pReader
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
bool
asc
=
ASCENDING_TRAVERSE
(
pReader
->
order
);
typedef
enum
{
TSDB_READ_RETURN
=
0x1
,
TSDB_READ_CONTINUE
=
0x2
,
}
ERetrieveType
;
static
ERetrieveType
doReadDataFromLastFiles
(
STsdbReader
*
pReader
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
SSDataBlock
*
pResBlock
=
pReader
->
resBlockInfo
.
pResBlock
;
SDataBlockIter
*
pBlockIter
=
&
pReader
->
status
.
blockIter
;
if
(
pBlockIter
->
numOfBlocks
==
0
)
{
_begin:
while
(
1
)
{
terrno
=
0
;
code
=
doLoadLastBlockSequentially
(
pReader
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
if
(
code
!=
TSDB_CODE_SUCCESS
||
pReader
->
flag
==
READER_STATUS_SHOULD_STOP
)
{
terrno
=
code
;
return
TSDB_READ_RETURN
;
}
if
(
pRe
ader
->
resBlockInfo
.
pRe
sBlock
->
info
.
rows
>
0
)
{
return
TSDB_
CODE_SUCCESS
;
if
(
pResBlock
->
info
.
rows
>
0
)
{
return
TSDB_
READ_RETURN
;
}
// all data blocks are checked in this last block file, now let's try the next file
if
(
pReader
->
status
.
pTableIter
==
NULL
)
{
code
=
initForFirstBlockInFile
(
pReader
,
pBlockIter
);
ASSERT
(
pReader
->
status
.
pTableIter
==
NULL
);
code
=
initForFirstBlockInFile
(
pReader
,
pBlockIter
);
// error happens or all the data files are completely checked
if
((
code
!=
TSDB_CODE_SUCCESS
)
||
(
pReader
->
status
.
loadFromFile
==
false
))
{
return
code
;
}
// error happens or all the data files are completely checked
if
((
code
!=
TSDB_CODE_SUCCESS
)
||
(
pReader
->
status
.
loadFromFile
==
false
)
||
pReader
->
flag
==
READER_STATUS_SHOULD_STOP
)
{
terrno
=
code
;
return
TSDB_READ_RETURN
;
}
// this file does not have data files, let's start check the last block file if exists
if
(
pBlockIter
->
numOfBlocks
==
0
)
{
resetTableListIndex
(
&
pReader
->
status
);
goto
_begin
;
}
if
(
pBlockIter
->
numOfBlocks
>
0
)
{
// there are data blocks existed.
return
TSDB_READ_CONTINUE
;
}
else
{
// all blocks in data file are checked, let's check the data in last files
resetTableListIndex
(
&
pReader
->
status
);
}
}
}
static
int32_t
buildBlockFromFiles
(
STsdbReader
*
pReader
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
bool
asc
=
ASCENDING_TRAVERSE
(
pReader
->
order
);
SDataBlockIter
*
pBlockIter
=
&
pReader
->
status
.
blockIter
;
SSDataBlock
*
pResBlock
=
pReader
->
resBlockInfo
.
pResBlock
;
if
(
pBlockIter
->
numOfBlocks
==
0
)
{
ERetrieveType
type
=
doReadDataFromLastFiles
(
pReader
);
if
(
type
!=
TSDB_READ_RETURN
)
{
return
terrno
;
}
code
=
doBuildDataBlock
(
pReader
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
||
pReader
->
flag
==
READER_STATUS_SHOULD_STOP
)
{
return
code
;
}
if
(
pRe
ader
->
resBlockInfo
.
pRe
sBlock
->
info
.
rows
>
0
)
{
if
(
pResBlock
->
info
.
rows
>
0
)
{
return
TSDB_CODE_SUCCESS
;
}
}
...
...
@@ -3530,30 +3557,22 @@ static int32_t buildBlockFromFiles(STsdbReader* pReader) {
if
(
hasNext
)
{
// check for the next block in the block accessed order list
initBlockDumpInfo
(
pReader
,
pBlockIter
);
}
else
{
if
(
pReader
->
status
.
pCurrentFileset
->
nSttF
>
0
)
{
// data blocks in current file are exhausted, let's try the next file now
SBlockData
*
pBlockData
=
&
pReader
->
status
.
fileBlockData
;
if
(
pBlockData
->
uid
!=
0
)
{
tBlockDataClear
(
pBlockData
);
}
// all data blocks in files are checked, let's check the data in last files.
ASSERT
(
pReader
->
status
.
pCurrentFileset
->
nSttF
>
0
);
tBlockDataReset
(
pBlockData
);
resetDataBlockIterator
(
pBlockIter
,
pReader
->
order
);
resetTableListIndex
(
&
pReader
->
status
);
goto
_begin
;
}
else
{
code
=
initForFirstBlockInFile
(
pReader
,
pBlockIter
);
// data blocks in current file are exhausted, let's try the next file now
SBlockData
*
pBlockData
=
&
pReader
->
status
.
fileBlockData
;
if
(
pBlockData
->
uid
!=
0
)
{
tBlockDataClear
(
pBlockData
);
}
// error happens or all the data files are completely checked
if
((
code
!=
TSDB_CODE_SUCCESS
)
||
(
pReader
->
status
.
loadFromFile
==
false
))
{
return
code
;
}
tBlockDataReset
(
pBlockData
);
resetDataBlockIterator
(
pBlockIter
,
pReader
->
order
);
resetTableListIndex
(
&
pReader
->
status
);
// this file does not have blocks, let's start check the last block file
if
(
pBlockIter
->
numOfBlocks
==
0
)
{
resetTableListIndex
(
&
pReader
->
status
);
goto
_begin
;
}
ERetrieveType
type
=
doReadDataFromLastFiles
(
pReader
);
if
(
type
!=
TSDB_READ_RETURN
)
{
return
terrno
;
}
}
}
...
...
@@ -3561,11 +3580,11 @@ static int32_t buildBlockFromFiles(STsdbReader* pReader) {
code
=
doBuildDataBlock
(
pReader
);
}
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
||
pReader
->
flag
==
READER_STATUS_SHOULD_STOP
)
{
return
code
;
}
if
(
pRe
ader
->
resBlockInfo
.
pRe
sBlock
->
info
.
rows
>
0
)
{
if
(
pResBlock
->
info
.
rows
>
0
)
{
return
TSDB_CODE_SUCCESS
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录