Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
79020ea4
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看板
提交
79020ea4
编写于
7月 26, 2023
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: stt and data block merge
上级
78bdb043
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
54 addition
and
48 deletion
+54
-48
source/dnode/vnode/src/tsdb/tsdbRead2.c
source/dnode/vnode/src/tsdb/tsdbRead2.c
+54
-48
未找到文件。
source/dnode/vnode/src/tsdb/tsdbRead2.c
浏览文件 @
79020ea4
...
@@ -1729,40 +1729,44 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader
...
@@ -1729,40 +1729,44 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader
// row in last file block
// row in last file block
TSDBROW
fRow
=
tsdbRowFromBlockData
(
pBlockData
,
pDumpInfo
->
rowIndex
);
TSDBROW
fRow
=
tsdbRowFromBlockData
(
pBlockData
,
pDumpInfo
->
rowIndex
);
int64_t
ts
=
getCurrentKeyInLastBlock
(
pLastBlockReader
);
int64_t
tsLast
=
getCurrentKeyInLastBlock
(
pLastBlockReader
);
if
(
ASCENDING_TRAVERSE
(
pReader
->
info
.
order
))
{
if
(
ASCENDING_TRAVERSE
(
pReader
->
info
.
order
))
{
if
(
key
<
ts
)
{
// imem, mem are all empty, file blocks (data blocks and last block) exist
if
(
key
<
ts
Last
)
{
return
mergeRowsInFileBlocks
(
pBlockData
,
pBlockScanInfo
,
key
,
pReader
);
return
mergeRowsInFileBlocks
(
pBlockData
,
pBlockScanInfo
,
key
,
pReader
);
}
else
if
(
key
==
ts
)
{
}
else
if
(
key
>
tsLast
)
{
SRow
*
pTSRow
=
NULL
;
return
doMergeFileBlockAndLastBlock
(
pLastBlockReader
,
pReader
,
pBlockScanInfo
,
NULL
,
false
);
int32_t
code
=
tsdbRowMergerAdd
(
pMerger
,
&
fRow
,
pReader
->
info
.
pSchema
);
}
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
}
else
{
return
code
;
if
(
key
>
tsLast
)
{
}
return
mergeRowsInFileBlocks
(
pBlockData
,
pBlockScanInfo
,
key
,
pReader
);
}
else
if
(
key
<
tsLast
)
{
doMergeRowsInFileBlocks
(
pBlockData
,
pBlockScanInfo
,
pReader
);
return
doMergeFileBlockAndLastBlock
(
pLastBlockReader
,
pReader
,
pBlockScanInfo
,
NULL
,
false
);
}
TSDBROW
*
pRow1
=
tMergeTreeGetRow
(
&
pLastBlockReader
->
mergeTree
);
}
tsdbRowMergerAdd
(
pMerger
,
pRow1
,
NULL
);
if
(
key
==
tsLast
)
{
SRow
*
pTSRow
=
NULL
;
int32_t
code
=
tsdbRowMergerAdd
(
pMerger
,
&
fRow
,
pReader
->
info
.
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
ts
,
pMerger
,
&
pReader
->
info
.
verRange
,
pReader
->
idSt
r
);
doMergeRowsInFileBlocks
(
pBlockData
,
pBlockScanInfo
,
pReade
r
);
code
=
tsdbRowMergerGetRow
(
pMerger
,
&
pTSRow
);
TSDBROW
*
pRow1
=
tMergeTreeGetRow
(
&
pLastBlockReader
->
mergeTree
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tsdbRowMergerAdd
(
pMerger
,
pRow1
,
NULL
);
return
code
;
}
code
=
doAppendRowFromTSRow
(
pReader
->
resBlockInfo
.
pResBlock
,
pReader
,
pTSRow
,
pBlockScanInfo
);
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
tsLast
,
pMerger
,
&
pReader
->
info
.
verRange
,
pReader
->
idStr
);
taosMemoryFree
(
pTSRow
);
code
=
tsdbRowMergerGetRow
(
pMerger
,
&
pTSRow
);
tsdbRowMergerClear
(
pMerger
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
else
{
// key > ts
return
doMergeFileBlockAndLastBlock
(
pLastBlockReader
,
pReader
,
pBlockScanInfo
,
NULL
,
false
);
}
}
}
else
{
// desc order
return
doMergeFileBlockAndLastBlock
(
pLastBlockReader
,
pReader
,
pBlockScanInfo
,
pBlockData
,
true
);
code
=
doAppendRowFromTSRow
(
pReader
->
resBlockInfo
.
pResBlock
,
pReader
,
pTSRow
,
pBlockScanInfo
);
taosMemoryFree
(
pTSRow
);
tsdbRowMergerClear
(
pMerger
);
return
code
;
}
}
}
else
{
// only last block exists
}
else
{
// only last block exists
return
doMergeFileBlockAndLastBlock
(
pLastBlockReader
,
pReader
,
pBlockScanInfo
,
NULL
,
false
);
return
doMergeFileBlockAndLastBlock
(
pLastBlockReader
,
pReader
,
pBlockScanInfo
,
NULL
,
false
);
...
@@ -2190,7 +2194,8 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI
...
@@ -2190,7 +2194,8 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI
SFileBlockDumpInfo
*
pDumpInfo
=
&
pReader
->
status
.
fBlockDumpInfo
;
SFileBlockDumpInfo
*
pDumpInfo
=
&
pReader
->
status
.
fBlockDumpInfo
;
TSDBROW
*
pRow
=
NULL
,
*
piRow
=
NULL
;
TSDBROW
*
pRow
=
NULL
,
*
piRow
=
NULL
;
int64_t
key
=
(
pBlockData
->
nRow
>
0
&&
(
!
pDumpInfo
->
allDumped
))
?
pBlockData
->
aTSKEY
[
pDumpInfo
->
rowIndex
]
:
INT64_MIN
;
int64_t
key
=
(
pBlockData
->
nRow
>
0
&&
(
!
pDumpInfo
->
allDumped
))
?
pBlockData
->
aTSKEY
[
pDumpInfo
->
rowIndex
]
:
(
ASCENDING_TRAVERSE
(
pReader
->
info
.
order
)
?
INT64_MAX
:
INT64_MIN
);
if
(
pBlockScanInfo
->
iter
.
hasVal
)
{
if
(
pBlockScanInfo
->
iter
.
hasVal
)
{
pRow
=
getValidMemRow
(
&
pBlockScanInfo
->
iter
,
pBlockScanInfo
->
delSkyline
,
pReader
);
pRow
=
getValidMemRow
(
&
pBlockScanInfo
->
iter
,
pBlockScanInfo
->
delSkyline
,
pReader
);
}
}
...
@@ -2667,16 +2672,32 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
...
@@ -2667,16 +2672,32 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
(
ASCENDING_TRAVERSE
(
pReader
->
info
.
order
))
?
pBlockInfo
->
record
.
firstKey
:
pBlockInfo
->
record
.
lastKey
;
(
ASCENDING_TRAVERSE
(
pReader
->
info
.
order
))
?
pBlockInfo
->
record
.
firstKey
:
pBlockInfo
->
record
.
lastKey
;
code
=
buildDataBlockFromBuf
(
pReader
,
pScanInfo
,
endKey
);
code
=
buildDataBlockFromBuf
(
pReader
,
pScanInfo
,
endKey
);
}
else
{
}
else
{
if
(
hasDataInLastBlock
(
pLastBlockReader
)
&&
!
ASCENDING_TRAVERSE
(
pReader
->
info
.
order
))
{
bool
bHasDataInLastBlock
=
hasDataInLastBlock
(
pLastBlockReader
);
// only return the rows in last block
int64_t
tsLast
=
bHasDataInLastBlock
?
getCurrentKeyInLastBlock
(
pLastBlockReader
)
:
INT64_MIN
;
int64_t
tsLast
=
getCurrentKeyInLastBlock
(
pLastBlockReader
);
if
(
!
bHasDataInLastBlock
||
((
ASCENDING_TRAVERSE
(
pReader
->
info
.
order
)
&&
pBlockInfo
->
record
.
lastKey
<
tsLast
)
||
ASSERT
(
tsLast
>=
pBlockInfo
->
record
.
lastKey
);
(
!
ASCENDING_TRAVERSE
(
pReader
->
info
.
order
)
&&
pBlockInfo
->
record
.
firstKey
>
tsLast
)))
{
// whole block is required, return it directly
SDataBlockInfo
*
pInfo
=
&
pReader
->
resBlockInfo
.
pResBlock
->
info
;
pInfo
->
rows
=
pBlockInfo
->
record
.
numRow
;
pInfo
->
id
.
uid
=
pScanInfo
->
uid
;
pInfo
->
dataLoad
=
0
;
pInfo
->
window
=
(
STimeWindow
){.
skey
=
pBlockInfo
->
record
.
firstKey
,
.
ekey
=
pBlockInfo
->
record
.
lastKey
};
setComposedBlockFlag
(
pReader
,
false
);
setBlockAllDumped
(
&
pStatus
->
fBlockDumpInfo
,
pBlockInfo
->
record
.
lastKey
,
pReader
->
info
.
order
);
// update the last key for the corresponding table
pScanInfo
->
lastKey
=
ASCENDING_TRAVERSE
(
pReader
->
info
.
order
)
?
pInfo
->
window
.
ekey
:
pInfo
->
window
.
skey
;
tsdbDebug
(
"%p uid:%"
PRIu64
" clean file block retrieved from file, global index:%d, "
"table index:%d, rows:%d, brange:%"
PRId64
"-%"
PRId64
", %s"
,
pReader
,
pScanInfo
->
uid
,
pBlockIter
->
index
,
pBlockInfo
->
tbBlockIdx
,
pBlockInfo
->
record
.
numRow
,
pBlockInfo
->
record
.
firstKey
,
pBlockInfo
->
record
.
lastKey
,
pReader
->
idStr
);
}
else
{
SBlockData
*
pBData
=
&
pReader
->
status
.
fileBlockData
;
SBlockData
*
pBData
=
&
pReader
->
status
.
fileBlockData
;
tBlockDataReset
(
pBData
);
tBlockDataReset
(
pBData
);
SSDataBlock
*
pResBlock
=
pReader
->
resBlockInfo
.
pResBlock
;
SSDataBlock
*
pResBlock
=
pReader
->
resBlockInfo
.
pResBlock
;
tsdbDebug
(
"load data in last block firstly
, due to desc scan data,
%s"
,
pReader
->
idStr
);
tsdbDebug
(
"load data in last block firstly %s"
,
pReader
->
idStr
);
int64_t
st
=
taosGetTimestampUs
();
int64_t
st
=
taosGetTimestampUs
();
...
@@ -2707,23 +2728,8 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
...
@@ -2707,23 +2728,8 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
pReader
,
pResBlock
->
info
.
id
.
uid
,
pResBlock
->
info
.
window
.
skey
,
pResBlock
->
info
.
window
.
ekey
,
pReader
,
pResBlock
->
info
.
id
.
uid
,
pResBlock
->
info
.
window
.
skey
,
pResBlock
->
info
.
window
.
ekey
,
pResBlock
->
info
.
rows
,
el
,
pReader
->
idStr
);
pResBlock
->
info
.
rows
,
el
,
pReader
->
idStr
);
}
}
}
else
{
// whole block is required, return it directly
SDataBlockInfo
*
pInfo
=
&
pReader
->
resBlockInfo
.
pResBlock
->
info
;
pInfo
->
rows
=
pBlockInfo
->
record
.
numRow
;
pInfo
->
id
.
uid
=
pScanInfo
->
uid
;
pInfo
->
dataLoad
=
0
;
pInfo
->
window
=
(
STimeWindow
){.
skey
=
pBlockInfo
->
record
.
firstKey
,
.
ekey
=
pBlockInfo
->
record
.
lastKey
};
setComposedBlockFlag
(
pReader
,
false
);
setBlockAllDumped
(
&
pStatus
->
fBlockDumpInfo
,
pBlockInfo
->
record
.
lastKey
,
pReader
->
info
.
order
);
// update the last key for the corresponding table
pScanInfo
->
lastKey
=
ASCENDING_TRAVERSE
(
pReader
->
info
.
order
)
?
pInfo
->
window
.
ekey
:
pInfo
->
window
.
skey
;
tsdbDebug
(
"%p uid:%"
PRIu64
" clean file block retrieved from file, global index:%d, "
"table index:%d, rows:%d, brange:%"
PRId64
"-%"
PRId64
", %s"
,
pReader
,
pScanInfo
->
uid
,
pBlockIter
->
index
,
pBlockInfo
->
tbBlockIdx
,
pBlockInfo
->
record
.
numRow
,
pBlockInfo
->
record
.
firstKey
,
pBlockInfo
->
record
.
lastKey
,
pReader
->
idStr
);
}
}
}
}
return
(
pReader
->
code
!=
TSDB_CODE_SUCCESS
)
?
pReader
->
code
:
code
;
return
(
pReader
->
code
!=
TSDB_CODE_SUCCESS
)
?
pReader
->
code
:
code
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录