Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1edf1e17
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看板
提交
1edf1e17
编写于
12月 23, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: do some internal refactor.
上级
224f5a72
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
54 addition
and
66 deletion
+54
-66
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+54
-66
未找到文件。
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
1edf1e17
...
...
@@ -396,7 +396,6 @@ static void destroyAllBlockScanInfo(SHashObj* pTableMap) {
}
static
bool
isEmptyQueryTimeWindow
(
STimeWindow
*
pWindow
)
{
ASSERT
(
pWindow
!=
NULL
);
return
pWindow
->
skey
>
pWindow
->
ekey
;
}
...
...
@@ -1447,7 +1446,6 @@ static int32_t findFileBlockInfoIndex(SDataBlockIter* pBlockIter, SFileDataBlock
index
+=
step
;
}
ASSERT
(
0
);
return
-
1
;
}
...
...
@@ -2421,6 +2419,46 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI
}
}
static
int32_t
loadNeighborIfOverlap
(
SFileDataBlockInfo
*
pBlockInfo
,
STableBlockScanInfo
*
pBlockScanInfo
,
STsdbReader
*
pReader
,
bool
*
loadNeighbor
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
step
=
ASCENDING_TRAVERSE
(
pReader
->
order
)
?
1
:
-
1
;
int32_t
nextIndex
=
-
1
;
SBlockIndex
nxtBIndex
=
{
0
};
*
loadNeighbor
=
false
;
SDataBlk
*
pBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
bool
hasNeighbor
=
getNeighborBlockOfSameTable
(
pBlockInfo
,
pBlockScanInfo
,
&
nextIndex
,
pReader
->
order
,
&
nxtBIndex
);
if
(
!
hasNeighbor
)
{
// do nothing
return
code
;
}
if
(
overlapWithNeighborBlock
(
pBlock
,
&
nxtBIndex
,
pReader
->
order
))
{
// load next block
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
SDataBlockIter
*
pBlockIter
=
&
pStatus
->
blockIter
;
// 1. find the next neighbor block in the scan block list
SFileDataBlockInfo
fb
=
{.
uid
=
pBlockInfo
->
uid
,
.
tbBlockIdx
=
nextIndex
};
int32_t
neighborIndex
=
findFileBlockInfoIndex
(
pBlockIter
,
&
fb
);
// 2. remove it from the scan block list
setFileBlockActiveInBlockIter
(
pBlockIter
,
neighborIndex
,
step
);
// 3. load the neighbor block, and set it to be the currently accessed file data block
code
=
doLoadFileBlockData
(
pReader
,
pBlockIter
,
&
pStatus
->
fileBlockData
,
pBlockInfo
->
uid
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
// 4. check the data values
initBlockDumpInfo
(
pReader
,
pBlockIter
);
*
loadNeighbor
=
true
;
}
return
code
;
}
static
int32_t
buildComposedDataBlock
(
STsdbReader
*
pReader
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
...
@@ -2479,38 +2517,13 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
SDataBlk
*
pBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
if
(
pDumpInfo
->
rowIndex
>=
pBlock
->
nRow
||
pDumpInfo
->
rowIndex
<
0
)
{
int32_t
nextIndex
=
-
1
;
SBlockIndex
bIndex
=
{
0
};
pBlockInfo
=
getCurrentBlockInfo
(
&
pReader
->
status
.
blockIter
);
// NOTE: get the new block info
bool
hasNeighbor
=
getNeighborBlockOfSameTable
(
pBlockInfo
,
pBlockScanInfo
,
&
nextIndex
,
pReader
->
order
,
&
bIndex
);
if
(
!
hasNeighbor
)
{
// do nothing
setBlockAllDumped
(
pDumpInfo
,
pBlock
->
maxKey
.
ts
,
pReader
->
order
);
break
;
}
if
(
overlapWithNeighborBlock
(
pBlock
,
&
bIndex
,
pReader
->
order
))
{
// load next block
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
SDataBlockIter
*
pBlockIter
=
&
pStatus
->
blockIter
;
// 1. find the next neighbor block in the scan block list
SFileDataBlockInfo
fb
=
{.
uid
=
pBlockInfo
->
uid
,
.
tbBlockIdx
=
nextIndex
};
int32_t
neighborIndex
=
findFileBlockInfoIndex
(
pBlockIter
,
&
fb
);
// 2. remove it from the scan block list
setFileBlockActiveInBlockIter
(
pBlockIter
,
neighborIndex
,
step
);
// 3. load the neighbor block, and set it to be the currently accessed file data block
code
=
doLoadFileBlockData
(
pReader
,
pBlockIter
,
&
pStatus
->
fileBlockData
,
pBlockInfo
->
uid
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
setBlockAllDumped
(
pDumpInfo
,
pBlock
->
maxKey
.
ts
,
pReader
->
order
);
break
;
}
// 4. check the data values
initBlockDumpInfo
(
pReader
,
pBlockIter
);
}
else
{
// continue check for the next file block if the last ts in the current block
// is overlapped with the next neighbor block
bool
loadNeighbor
=
false
;
code
=
loadNeighborIfOverlap
(
pBlockInfo
,
pBlockScanInfo
,
pReader
,
&
loadNeighbor
);
if
((
!
loadNeighbor
)
||
(
code
!=
0
))
{
setBlockAllDumped
(
pDumpInfo
,
pBlock
->
maxKey
.
ts
,
pReader
->
order
);
break
;
}
...
...
@@ -2777,7 +2790,10 @@ static bool moveToNextTable(SUidOrderCheckInfo* pOrderedCheckInfo, SReaderStatus
uint64_t
uid
=
pOrderedCheckInfo
->
tableUidList
[
pOrderedCheckInfo
->
currentIndex
];
pStatus
->
pTableIter
=
taosHashGet
(
pStatus
->
pTableMap
,
&
uid
,
sizeof
(
uid
));
ASSERT
(
pStatus
->
pTableIter
!=
NULL
);
if
(
pStatus
->
pTableIter
==
NULL
)
{
return
false
;
}
return
true
;
}
...
...
@@ -3117,10 +3133,10 @@ SVersionRange getQueryVerRange(SVnode* pVnode, SQueryTableDataCond* pCond, int8_
}
bool
hasBeenDropped
(
const
SArray
*
pDelList
,
int32_t
*
index
,
TSDBKEY
*
pKey
,
int32_t
order
,
SVersionRange
*
pVerRange
)
{
ASSERT
(
pKey
!=
NULL
);
if
(
pDelList
==
NULL
)
{
return
false
;
}
size_t
num
=
taosArrayGetSize
(
pDelList
);
bool
asc
=
ASCENDING_TRAVERSE
(
order
);
int32_t
step
=
asc
?
1
:
-
1
;
...
...
@@ -3318,35 +3334,10 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn
*
state
=
CHECK_FILEBLOCK_QUIT
;
int32_t
step
=
ASCENDING_TRAVERSE
(
pReader
->
order
)
?
1
:
-
1
;
int32_t
nextIndex
=
-
1
;
SBlockIndex
bIndex
=
{
0
};
bool
hasNeighbor
=
getNeighborBlockOfSameTable
(
pFBlock
,
pScanInfo
,
&
nextIndex
,
pReader
->
order
,
&
bIndex
);
if
(
!
hasNeighbor
)
{
// do nothing
return
0
;
}
bool
overlap
=
overlapWithNeighborBlock
(
pBlock
,
&
bIndex
,
pReader
->
order
);
if
(
overlap
)
{
// load next block
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
SDataBlockIter
*
pBlockIter
=
&
pStatus
->
blockIter
;
// 1. find the next neighbor block in the scan block list
SFileDataBlockInfo
fb
=
{.
uid
=
pFBlock
->
uid
,
.
tbBlockIdx
=
nextIndex
};
int32_t
neighborIndex
=
findFileBlockInfoIndex
(
pBlockIter
,
&
fb
);
// 2. remove it from the scan block list
setFileBlockActiveInBlockIter
(
pBlockIter
,
neighborIndex
,
step
);
// 3. load the neighbor block, and set it to be the currently accessed file data block
int32_t
code
=
doLoadFileBlockData
(
pReader
,
pBlockIter
,
&
pStatus
->
fileBlockData
,
pFBlock
->
uid
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
// 4. check the data values
initBlockDumpInfo
(
pReader
,
pBlockIter
);
bool
loadNeighbor
=
true
;
int32_t
code
=
loadNeighborIfOverlap
(
pFBlock
,
pScanInfo
,
pReader
,
&
loadNeighbor
);
if
(
loadNeighbor
&&
(
code
==
TSDB_CODE_SUCCESS
))
{
pDumpInfo
->
rowIndex
=
doMergeRowsInFileBlockImpl
(
pBlockData
,
pDumpInfo
->
rowIndex
,
key
,
pMerger
,
&
pReader
->
verRange
,
step
);
if
(
pDumpInfo
->
rowIndex
>=
pDumpInfo
->
totalRows
)
{
...
...
@@ -3354,7 +3345,7 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn
}
}
return
TSDB_CODE_SUCCESS
;
return
code
;
}
int32_t
doMergeRowsInFileBlocks
(
SBlockData
*
pBlockData
,
STableBlockScanInfo
*
pScanInfo
,
STsdbReader
*
pReader
,
...
...
@@ -3709,13 +3700,11 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e
}
}
while
(
1
);
ASSERT
(
pBlock
->
info
.
rows
<=
capacity
);
return
TSDB_CODE_SUCCESS
;
}
// TODO refactor: with createDataBlockScanInfo
int32_t
tsdbSetTableList
(
STsdbReader
*
pReader
,
const
void
*
pTableList
,
int32_t
num
)
{
ASSERT
(
pReader
!=
NULL
);
int32_t
size
=
taosHashGetSize
(
pReader
->
status
.
pTableMap
);
STableBlockScanInfo
**
p
=
NULL
;
...
...
@@ -4079,7 +4068,6 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
}
static
void
setBlockInfo
(
const
STsdbReader
*
pReader
,
int32_t
*
rows
,
uint64_t
*
uid
,
STimeWindow
*
pWindow
)
{
ASSERT
(
pReader
!=
NULL
);
*
rows
=
pReader
->
pResBlock
->
info
.
rows
;
*
uid
=
pReader
->
pResBlock
->
info
.
id
.
uid
;
*
pWindow
=
pReader
->
pResBlock
->
info
.
window
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录