Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f85cf08f
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
f85cf08f
编写于
2月 12, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): set the initial iterator table before check data in buffer.
上级
30981ece
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
38 addition
and
42 deletion
+38
-42
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+38
-42
未找到文件。
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
f85cf08f
...
@@ -133,17 +133,17 @@ typedef struct SFileBlockDumpInfo {
...
@@ -133,17 +133,17 @@ typedef struct SFileBlockDumpInfo {
bool
allDumped
;
bool
allDumped
;
}
SFileBlockDumpInfo
;
}
SFileBlockDumpInfo
;
typedef
struct
S
UidOrdere
dList
{
typedef
struct
S
TableUi
dList
{
uint64_t
*
tableUidList
;
// access table uid list in uid ascending order list
uint64_t
*
tableUidList
;
// access table uid list in uid ascending order list
int32_t
currentIndex
;
// index in table uid list
int32_t
currentIndex
;
// index in table uid list
}
S
UidOrdere
dList
;
}
S
TableUi
dList
;
typedef
struct
SReaderStatus
{
typedef
struct
SReaderStatus
{
bool
loadFromFile
;
// check file stage
bool
loadFromFile
;
// check file stage
bool
composedDataBlock
;
// the returned data block is a composed block or not
bool
composedDataBlock
;
// the returned data block is a composed block or not
SHashObj
*
pTableMap
;
// SHash<STableBlockScanInfo>
SHashObj
*
pTableMap
;
// SHash<STableBlockScanInfo>
STableBlockScanInfo
**
pTableIter
;
// table iterator used in building in-memory buffer data blocks.
STableBlockScanInfo
**
pTableIter
;
// table iterator used in building in-memory buffer data blocks.
S
UidOrderedList
uidCheckInfo
;
// check all table in uid order
S
TableUidList
uidList
;
// check tables in uid order, to avoid the repeatly load of blocks in STT.
SFileBlockDumpInfo
fBlockDumpInfo
;
SFileBlockDumpInfo
fBlockDumpInfo
;
SDFileSet
*
pCurrentFileset
;
// current opened file set
SDFileSet
*
pCurrentFileset
;
// current opened file set
SBlockData
fileBlockData
;
SBlockData
fileBlockData
;
...
@@ -341,7 +341,7 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf
...
@@ -341,7 +341,7 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf
int64_t
st
=
taosGetTimestampUs
();
int64_t
st
=
taosGetTimestampUs
();
initBlockScanInfoBuf
(
pBuf
,
numOfTables
);
initBlockScanInfoBuf
(
pBuf
,
numOfTables
);
S
UidOrderedList
*
pOrderedCheckInfo
=
&
pTsdbReader
->
status
.
uidCheckInfo
;
S
TableUidList
*
pOrderedCheckInfo
=
&
pTsdbReader
->
status
.
uidList
;
pOrderedCheckInfo
->
tableUidList
=
taosMemoryMalloc
(
numOfTables
*
sizeof
(
uint64_t
));
pOrderedCheckInfo
->
tableUidList
=
taosMemoryMalloc
(
numOfTables
*
sizeof
(
uint64_t
));
if
(
pOrderedCheckInfo
->
tableUidList
==
NULL
)
{
if
(
pOrderedCheckInfo
->
tableUidList
==
NULL
)
{
...
@@ -679,7 +679,7 @@ static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFReader* pFileReader,
...
@@ -679,7 +679,7 @@ static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFReader* pFileReader,
int64_t
et1
=
taosGetTimestampUs
();
int64_t
et1
=
taosGetTimestampUs
();
SBlockIdx
*
pBlockIdx
=
NULL
;
SBlockIdx
*
pBlockIdx
=
NULL
;
S
UidOrderedList
*
pList
=
&
pReader
->
status
.
uidCheckInfo
;
S
TableUidList
*
pList
=
&
pReader
->
status
.
uidList
;
int32_t
i
=
0
,
j
=
0
;
int32_t
i
=
0
,
j
=
0
;
while
(
i
<
num
&&
j
<
numOfTables
)
{
while
(
i
<
num
&&
j
<
numOfTables
)
{
...
@@ -2768,27 +2768,15 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) {
...
@@ -2768,27 +2768,15 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
// reset the last del file index
static
void
resetScanBlockLastBlockDelIndex
(
SReaderStatus
*
pStatus
,
int32_t
order
)
{
void
*
p
=
taosHashIterate
(
pStatus
->
pTableMap
,
NULL
);
while
(
p
!=
NULL
)
{
STableBlockScanInfo
*
pScanInfo
=
*
(
STableBlockScanInfo
**
)
p
;
// reset the last del file index
pScanInfo
->
lastBlockDelIndex
=
getInitialDelIndex
(
pScanInfo
->
delSkyline
,
order
);
p
=
taosHashIterate
(
pStatus
->
pTableMap
,
p
);
}
}
static
void
resetTableListIndex
(
SReaderStatus
*
pStatus
)
{
static
void
resetTableListIndex
(
SReaderStatus
*
pStatus
)
{
S
UidOrderedList
*
pList
=
&
pStatus
->
uidCheckInfo
;
S
TableUidList
*
pList
=
&
pStatus
->
uidList
;
pList
->
currentIndex
=
0
;
pList
->
currentIndex
=
0
;
uint64_t
uid
=
pList
->
tableUidList
[
0
];
uint64_t
uid
=
pList
->
tableUidList
[
0
];
pStatus
->
pTableIter
=
taosHashGet
(
pStatus
->
pTableMap
,
&
uid
,
sizeof
(
uid
));
pStatus
->
pTableIter
=
taosHashGet
(
pStatus
->
pTableMap
,
&
uid
,
sizeof
(
uid
));
}
}
static
bool
moveToNextTable
(
S
UidOrdere
dList
*
pOrderedCheckInfo
,
SReaderStatus
*
pStatus
)
{
static
bool
moveToNextTable
(
S
TableUi
dList
*
pOrderedCheckInfo
,
SReaderStatus
*
pStatus
)
{
pOrderedCheckInfo
->
currentIndex
+=
1
;
pOrderedCheckInfo
->
currentIndex
+=
1
;
if
(
pOrderedCheckInfo
->
currentIndex
>=
taosHashGetSize
(
pStatus
->
pTableMap
))
{
if
(
pOrderedCheckInfo
->
currentIndex
>=
taosHashGetSize
(
pStatus
->
pTableMap
))
{
pStatus
->
pTableIter
=
NULL
;
pStatus
->
pTableIter
=
NULL
;
...
@@ -2803,8 +2791,8 @@ static bool moveToNextTable(SUidOrderedList* pOrderedCheckInfo, SReaderStatus* p
...
@@ -2803,8 +2791,8 @@ static bool moveToNextTable(SUidOrderedList* pOrderedCheckInfo, SReaderStatus* p
static
int32_t
doLoadLastBlockSequentially
(
STsdbReader
*
pReader
)
{
static
int32_t
doLoadLastBlockSequentially
(
STsdbReader
*
pReader
)
{
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
SLastBlockReader
*
pLastBlockReader
=
pStatus
->
fileIter
.
pLastBlockReader
;
SLastBlockReader
*
pLastBlockReader
=
pStatus
->
fileIter
.
pLastBlockReader
;
STableUidList
*
pUidList
=
&
pStatus
->
uidList
;
SUidOrderedList
*
pOrderedCheckInfo
=
&
pStatus
->
uidCheckInfo
;
if
(
taosHashGetSize
(
pStatus
->
pTableMap
)
==
0
)
{
if
(
taosHashGetSize
(
pStatus
->
pTableMap
)
==
0
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -2817,7 +2805,7 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
...
@@ -2817,7 +2805,7 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
bool
hasVal
=
initLastBlockReader
(
pLastBlockReader
,
pScanInfo
,
pReader
);
bool
hasVal
=
initLastBlockReader
(
pLastBlockReader
,
pScanInfo
,
pReader
);
if
(
!
hasVal
)
{
if
(
!
hasVal
)
{
bool
hasNexTable
=
moveToNextTable
(
p
OrderedCheckInfo
,
pStatus
);
bool
hasNexTable
=
moveToNextTable
(
p
UidList
,
pStatus
);
if
(
!
hasNexTable
)
{
if
(
!
hasNexTable
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -2852,7 +2840,7 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
...
@@ -2852,7 +2840,7 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
}
}
// current table is exhausted, let's try next table
// current table is exhausted, let's try next table
bool
hasNexTable
=
moveToNextTable
(
p
OrderedCheckInfo
,
pStatus
);
bool
hasNexTable
=
moveToNextTable
(
p
UidList
,
pStatus
);
if
(
!
hasNexTable
)
{
if
(
!
hasNexTable
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -2956,14 +2944,15 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
...
@@ -2956,14 +2944,15 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
static
int32_t
buildBlockFromBufferSequentially
(
STsdbReader
*
pReader
)
{
static
int32_t
buildBlockFromBufferSequentially
(
STsdbReader
*
pReader
)
{
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
STableUidList
*
pUidList
=
&
pStatus
->
uidList
;
while
(
1
)
{
while
(
1
)
{
if
(
pStatus
->
pTableIter
==
NULL
)
{
//
if (pStatus->pTableIter == NULL) {
pStatus
->
pTableIter
=
taosHashIterate
(
pStatus
->
pTableMap
,
NULL
);
//
pStatus->pTableIter = taosHashIterate(pStatus->pTableMap, NULL);
if
(
pStatus
->
pTableIter
==
NULL
)
{
//
if (pStatus->pTableIter == NULL) {
return
TSDB_CODE_SUCCESS
;
//
return TSDB_CODE_SUCCESS;
}
//
}
}
//
}
STableBlockScanInfo
**
pBlockScanInfo
=
pStatus
->
pTableIter
;
STableBlockScanInfo
**
pBlockScanInfo
=
pStatus
->
pTableIter
;
initMemDataIterator
(
*
pBlockScanInfo
,
pReader
);
initMemDataIterator
(
*
pBlockScanInfo
,
pReader
);
...
@@ -2978,9 +2967,9 @@ static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) {
...
@@ -2978,9 +2967,9 @@ static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
// current table is exhausted, let's try
the
next table
// current table is exhausted, let's try next table
pStatus
->
pTableIter
=
taosHashIterate
(
pStatus
->
pTableMap
,
pStatus
->
pTableIter
);
bool
hasNexTable
=
moveToNextTable
(
pUidList
,
pStatus
);
if
(
pStatus
->
pTableIter
==
NULL
)
{
if
(
!
hasNexTable
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
}
}
...
@@ -3001,7 +2990,6 @@ void initBlockDumpInfo(STsdbReader* pReader, SDataBlockIter* pBlockIter) {
...
@@ -3001,7 +2990,6 @@ void initBlockDumpInfo(STsdbReader* pReader, SDataBlockIter* pBlockIter) {
static
int32_t
initForFirstBlockInFile
(
STsdbReader
*
pReader
,
SDataBlockIter
*
pBlockIter
)
{
static
int32_t
initForFirstBlockInFile
(
STsdbReader
*
pReader
,
SDataBlockIter
*
pBlockIter
)
{
SBlockNumber
num
=
{
0
};
SBlockNumber
num
=
{
0
};
int32_t
code
=
moveToNextFile
(
pReader
,
&
num
);
int32_t
code
=
moveToNextFile
(
pReader
,
&
num
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
...
@@ -3767,7 +3755,7 @@ int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t n
...
@@ -3767,7 +3755,7 @@ int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t n
ASSERT
(
size
>=
num
);
ASSERT
(
size
>=
num
);
taosHashClear
(
pReader
->
status
.
pTableMap
);
taosHashClear
(
pReader
->
status
.
pTableMap
);
S
UidOrderedList
*
pUidList
=
&
pReader
->
status
.
uidCheckInfo
;
S
TableUidList
*
pUidList
=
&
pReader
->
status
.
uidList
;
pUidList
->
currentIndex
=
0
;
pUidList
->
currentIndex
=
0
;
STableKeyInfo
*
pList
=
(
STableKeyInfo
*
)
pTableList
;
STableKeyInfo
*
pList
=
(
STableKeyInfo
*
)
pTableList
;
...
@@ -3799,18 +3787,24 @@ void* tsdbGetIvtIdx(SMeta* pMeta) {
...
@@ -3799,18 +3787,24 @@ void* tsdbGetIvtIdx(SMeta* pMeta) {
uint64_t
getReaderMaxVersion
(
STsdbReader
*
pReader
)
{
return
pReader
->
verRange
.
maxVer
;
}
uint64_t
getReaderMaxVersion
(
STsdbReader
*
pReader
)
{
return
pReader
->
verRange
.
maxVer
;
}
static
int32_t
doOpenReaderImpl
(
STsdbReader
*
pReader
)
{
static
int32_t
doOpenReaderImpl
(
STsdbReader
*
pReader
)
{
SDataBlockIter
*
pBlockIter
=
&
pReader
->
status
.
blockIter
;
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
SDataBlockIter
*
pBlockIter
=
&
pStatus
->
blockIter
;
initFilesetIterator
(
&
p
Reader
->
status
.
fileIter
,
pReader
->
pReadSnap
->
fs
.
aDFileSet
,
pReader
);
initFilesetIterator
(
&
p
Status
->
fileIter
,
pReader
->
pReadSnap
->
fs
.
aDFileSet
,
pReader
);
resetDataBlockIterator
(
&
p
Reader
->
status
.
blockIter
,
pReader
->
order
);
resetDataBlockIterator
(
&
p
Status
->
blockIter
,
pReader
->
order
);
// no data in files, let's try buffer in memory
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
pReader
->
status
.
fileIter
.
numOfFiles
==
0
)
{
if
(
pStatus
->
fileIter
.
numOfFiles
==
0
)
{
pReader
->
status
.
loadFromFile
=
false
;
pStatus
->
loadFromFile
=
false
;
return
TSDB_CODE_SUCCESS
;
}
else
{
}
else
{
return
initForFirstBlockInFile
(
pReader
,
pBlockIter
);
code
=
initForFirstBlockInFile
(
pReader
,
pBlockIter
);
}
if
(
!
pStatus
->
loadFromFile
)
{
resetTableListIndex
(
pStatus
);
}
}
return
code
;
}
}
// ====================================== EXPOSED APIs ======================================
// ====================================== EXPOSED APIs ======================================
...
@@ -4012,7 +4006,7 @@ void tsdbReaderClose(STsdbReader* pReader) {
...
@@ -4012,7 +4006,7 @@ void tsdbReaderClose(STsdbReader* pReader) {
tsdbUntakeReadSnap
(
pReader
->
pTsdb
,
pReader
->
pReadSnap
,
pReader
->
idStr
);
tsdbUntakeReadSnap
(
pReader
->
pTsdb
,
pReader
->
pReadSnap
,
pReader
->
idStr
);
taosMemoryFree
(
pReader
->
status
.
uid
CheckInfo
.
tableUidList
);
taosMemoryFree
(
pReader
->
status
.
uid
List
.
tableUidList
);
SIOCostSummary
*
pCost
=
&
pReader
->
cost
;
SIOCostSummary
*
pCost
=
&
pReader
->
cost
;
SFilesetIter
*
pFilesetIter
=
&
pReader
->
status
.
fileIter
;
SFilesetIter
*
pFilesetIter
=
&
pReader
->
status
.
fileIter
;
...
@@ -4066,6 +4060,7 @@ static bool doTsdbNextDataBlock(STsdbReader* pReader) {
...
@@ -4066,6 +4060,7 @@ static bool doTsdbNextDataBlock(STsdbReader* pReader) {
if
(
pBlock
->
info
.
rows
>
0
)
{
if
(
pBlock
->
info
.
rows
>
0
)
{
return
true
;
return
true
;
}
else
{
}
else
{
resetTableListIndex
(
&
pReader
->
status
);
buildBlockFromBufferSequentially
(
pReader
);
buildBlockFromBufferSequentially
(
pReader
);
return
pBlock
->
info
.
rows
>
0
;
return
pBlock
->
info
.
rows
>
0
;
}
}
...
@@ -4309,6 +4304,7 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
...
@@ -4309,6 +4304,7 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
// no data in files, let's try buffer in memory
// no data in files, let's try buffer in memory
if
(
pStatus
->
fileIter
.
numOfFiles
==
0
)
{
if
(
pStatus
->
fileIter
.
numOfFiles
==
0
)
{
pStatus
->
loadFromFile
=
false
;
pStatus
->
loadFromFile
=
false
;
resetTableListIndex
(
pStatus
);
}
else
{
}
else
{
code
=
initForFirstBlockInFile
(
pReader
,
pBlockIter
);
code
=
initForFirstBlockInFile
(
pReader
,
pBlockIter
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录