Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
db6c660b
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看板
提交
db6c660b
编写于
7月 27, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of
https://github.com/taosdata/TDengine
into fix/hzcheng_3.0
上级
cace6bfc
089f0458
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
37 addition
and
25 deletion
+37
-25
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+25
-18
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+4
-0
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+3
-4
source/libs/executor/src/projectoperator.c
source/libs/executor/src/projectoperator.c
+3
-1
tests/script/tsim/parser/lastrow_query.sim
tests/script/tsim/parser/lastrow_query.sim
+2
-2
未找到文件。
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
db6c660b
...
@@ -431,6 +431,12 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
...
@@ -431,6 +431,12 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
pSup
->
tsColAgg
.
colId
=
PRIMARYKEY_TIMESTAMP_COL_ID
;
pSup
->
tsColAgg
.
colId
=
PRIMARYKEY_TIMESTAMP_COL_ID
;
code
=
tBlockDataInit
(
&
pReader
->
status
.
fileBlockData
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
goto
_end
;
}
pReader
->
pResBlock
=
createResBlock
(
pCond
,
pReader
->
capacity
);
pReader
->
pResBlock
=
createResBlock
(
pCond
,
pReader
->
capacity
);
if
(
pReader
->
pResBlock
==
NULL
)
{
if
(
pReader
->
pResBlock
==
NULL
)
{
code
=
terrno
;
code
=
terrno
;
...
@@ -1200,8 +1206,9 @@ static int32_t buildDataBlockFromBuf(STsdbReader* pReader, STableBlockScanInfo*
...
@@ -1200,8 +1206,9 @@ static int32_t buildDataBlockFromBuf(STsdbReader* pReader, STableBlockScanInfo*
}
}
static
int32_t
doMergeBufAndFileRows
(
STsdbReader
*
pReader
,
STableBlockScanInfo
*
pBlockScanInfo
,
TSDBROW
*
pRow
,
static
int32_t
doMergeBufAndFileRows
(
STsdbReader
*
pReader
,
STableBlockScanInfo
*
pBlockScanInfo
,
TSDBROW
*
pRow
,
S
TSRow
*
pTSRow
,
S
IterInfo
*
pIter
,
int64_t
key
)
{
SIterInfo
*
pIter
,
int64_t
key
)
{
SRowMerger
merge
=
{
0
};
SRowMerger
merge
=
{
0
};
STSRow
*
pTSRow
=
NULL
;
SBlockData
*
pBlockData
=
&
pReader
->
status
.
fileBlockData
;
SBlockData
*
pBlockData
=
&
pReader
->
status
.
fileBlockData
;
SFileBlockDumpInfo
*
pDumpInfo
=
&
pReader
->
status
.
fBlockDumpInfo
;
SFileBlockDumpInfo
*
pDumpInfo
=
&
pReader
->
status
.
fBlockDumpInfo
;
...
@@ -1250,6 +1257,8 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
...
@@ -1250,6 +1257,8 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
tRowMergerClear
(
&
merge
);
tRowMergerClear
(
&
merge
);
doAppendOneRow
(
pReader
->
pResBlock
,
pReader
,
pTSRow
);
doAppendOneRow
(
pReader
->
pResBlock
,
pReader
,
pTSRow
);
taosMemoryFree
(
pTSRow
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1411,8 +1420,6 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI
...
@@ -1411,8 +1420,6 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI
SFileBlockDumpInfo
*
pDumpInfo
=
&
pReader
->
status
.
fBlockDumpInfo
;
SFileBlockDumpInfo
*
pDumpInfo
=
&
pReader
->
status
.
fBlockDumpInfo
;
SBlockData
*
pBlockData
=
&
pReader
->
status
.
fileBlockData
;
SBlockData
*
pBlockData
=
&
pReader
->
status
.
fileBlockData
;
STSRow
*
pTSRow
=
NULL
;
int64_t
key
=
pBlockData
->
aTSKEY
[
pDumpInfo
->
rowIndex
];
int64_t
key
=
pBlockData
->
aTSKEY
[
pDumpInfo
->
rowIndex
];
TSDBROW
*
pRow
=
getValidRow
(
&
pBlockScanInfo
->
iter
,
pBlockScanInfo
->
delSkyline
,
pReader
);
TSDBROW
*
pRow
=
getValidRow
(
&
pBlockScanInfo
->
iter
,
pBlockScanInfo
->
delSkyline
,
pReader
);
TSDBROW
*
piRow
=
getValidRow
(
&
pBlockScanInfo
->
iiter
,
pBlockScanInfo
->
delSkyline
,
pReader
);
TSDBROW
*
piRow
=
getValidRow
(
&
pBlockScanInfo
->
iiter
,
pBlockScanInfo
->
delSkyline
,
pReader
);
...
@@ -1422,23 +1429,27 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI
...
@@ -1422,23 +1429,27 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI
}
else
{
}
else
{
// imem + file
// imem + file
if
(
pBlockScanInfo
->
iiter
.
hasVal
)
{
if
(
pBlockScanInfo
->
iiter
.
hasVal
)
{
return
doMergeBufAndFileRows
(
pReader
,
pBlockScanInfo
,
piRow
,
pTSRow
,
&
pBlockScanInfo
->
iiter
,
key
);
return
doMergeBufAndFileRows
(
pReader
,
pBlockScanInfo
,
piRow
,
&
pBlockScanInfo
->
iiter
,
key
);
}
}
// mem + file
// mem + file
if
(
pBlockScanInfo
->
iter
.
hasVal
)
{
if
(
pBlockScanInfo
->
iter
.
hasVal
)
{
return
doMergeBufAndFileRows
(
pReader
,
pBlockScanInfo
,
pRow
,
pTSRow
,
&
pBlockScanInfo
->
iter
,
key
);
return
doMergeBufAndFileRows
(
pReader
,
pBlockScanInfo
,
pRow
,
&
pBlockScanInfo
->
iter
,
key
);
}
}
// imem & mem are all empty, only file exist
// imem & mem are all empty, only file exist
TSDBROW
fRow
=
tsdbRowFromBlockData
(
pBlockData
,
pDumpInfo
->
rowIndex
);
TSDBROW
fRow
=
tsdbRowFromBlockData
(
pBlockData
,
pDumpInfo
->
rowIndex
);
STSRow
*
pTSRow
=
NULL
;
SRowMerger
merge
=
{
0
};
SRowMerger
merge
=
{
0
};
tRowMergerInit
(
&
merge
,
&
fRow
,
pReader
->
pSchema
);
tRowMergerInit
(
&
merge
,
&
fRow
,
pReader
->
pSchema
);
doMergeRowsInFileBlocks
(
pBlockData
,
pBlockScanInfo
,
pReader
,
&
merge
);
doMergeRowsInFileBlocks
(
pBlockData
,
pBlockScanInfo
,
pReader
,
&
merge
);
tRowMergerGetRow
(
&
merge
,
&
pTSRow
);
tRowMergerGetRow
(
&
merge
,
&
pTSRow
);
doAppendOneRow
(
pReader
->
pResBlock
,
pReader
,
pTSRow
);
doAppendOneRow
(
pReader
->
pResBlock
,
pReader
,
pTSRow
);
taosMemoryFree
(
pTSRow
);
tRowMergerClear
(
&
merge
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
}
}
...
@@ -1716,7 +1727,8 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
...
@@ -1716,7 +1727,8 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
TSDBKEY
key
=
getCurrentKeyInBuf
(
pBlockIter
,
pReader
);
TSDBKEY
key
=
getCurrentKeyInBuf
(
pBlockIter
,
pReader
);
if
(
fileBlockShouldLoad
(
pReader
,
pFBlock
,
pBlock
,
pScanInfo
,
key
))
{
if
(
fileBlockShouldLoad
(
pReader
,
pFBlock
,
pBlock
,
pScanInfo
,
key
))
{
tBlockDataInit
(
&
pStatus
->
fileBlockData
);
tBlockDataReset
(
&
pStatus
->
fileBlockData
);
tBlockDataClearData
(
&
pStatus
->
fileBlockData
);
code
=
doLoadFileBlockData
(
pReader
,
pBlockIter
,
pScanInfo
,
&
pStatus
->
fileBlockData
);
code
=
doLoadFileBlockData
(
pReader
,
pBlockIter
,
pScanInfo
,
&
pStatus
->
fileBlockData
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
...
@@ -2160,6 +2172,8 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn
...
@@ -2160,6 +2172,8 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn
setFileBlockActiveInBlockIter
(
pBlockIter
,
neighborIndex
,
step
);
setFileBlockActiveInBlockIter
(
pBlockIter
,
neighborIndex
,
step
);
// 3. load the neighbor block, and set it to be the currently accessed file data block
// 3. load the neighbor block, and set it to be the currently accessed file data block
tBlockDataReset
(
&
pStatus
->
fileBlockData
);
tBlockDataClearData
(
&
pStatus
->
fileBlockData
);
int32_t
code
=
doLoadFileBlockData
(
pReader
,
pBlockIter
,
pScanInfo
,
&
pStatus
->
fileBlockData
);
int32_t
code
=
doLoadFileBlockData
(
pReader
,
pBlockIter
,
pScanInfo
,
&
pStatus
->
fileBlockData
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
...
@@ -2563,6 +2577,7 @@ void tsdbReaderClose(STsdbReader* pReader) {
...
@@ -2563,6 +2577,7 @@ void tsdbReaderClose(STsdbReader* pReader) {
}
}
}
}
taosMemoryFree
(
pSupInfo
->
buildBuf
);
taosMemoryFree
(
pSupInfo
->
buildBuf
);
tBlockDataClear
(
&
pReader
->
status
.
fileBlockData
,
true
);
cleanupDataBlockIterator
(
&
pReader
->
status
.
blockIter
);
cleanupDataBlockIterator
(
&
pReader
->
status
.
blockIter
);
...
@@ -2760,13 +2775,9 @@ static SArray* doRetrieveDataBlock(STsdbReader* pReader) {
...
@@ -2760,13 +2775,9 @@ static SArray* doRetrieveDataBlock(STsdbReader* pReader) {
SFileDataBlockInfo
*
pFBlock
=
getCurrentBlockInfo
(
&
pStatus
->
blockIter
);
SFileDataBlockInfo
*
pFBlock
=
getCurrentBlockInfo
(
&
pStatus
->
blockIter
);
STableBlockScanInfo
*
pBlockScanInfo
=
taosHashGet
(
pStatus
->
pTableMap
,
&
pFBlock
->
uid
,
sizeof
(
pFBlock
->
uid
));
STableBlockScanInfo
*
pBlockScanInfo
=
taosHashGet
(
pStatus
->
pTableMap
,
&
pFBlock
->
uid
,
sizeof
(
pFBlock
->
uid
));
int32_t
code
=
tBlockDataInit
(
&
pStatus
->
fileBlockData
);
tBlockDataReset
(
&
pStatus
->
fileBlockData
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tBlockDataClearData
(
&
pStatus
->
fileBlockData
);
terrno
=
code
;
int32_t
code
=
doLoadFileBlockData
(
pReader
,
&
pStatus
->
blockIter
,
pBlockScanInfo
,
&
pStatus
->
fileBlockData
);
return
NULL
;
}
code
=
doLoadFileBlockData
(
pReader
,
&
pStatus
->
blockIter
,
pBlockScanInfo
,
&
pStatus
->
fileBlockData
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tBlockDataClear
(
&
pStatus
->
fileBlockData
,
1
);
tBlockDataClear
(
&
pStatus
->
fileBlockData
,
1
);
...
@@ -2775,7 +2786,6 @@ static SArray* doRetrieveDataBlock(STsdbReader* pReader) {
...
@@ -2775,7 +2786,6 @@ static SArray* doRetrieveDataBlock(STsdbReader* pReader) {
}
}
copyBlockDataToSDataBlock
(
pReader
,
pBlockScanInfo
);
copyBlockDataToSDataBlock
(
pReader
,
pBlockScanInfo
);
tBlockDataClear
(
&
pStatus
->
fileBlockData
,
1
);
return
pReader
->
pResBlock
->
pDataBlock
;
return
pReader
->
pResBlock
->
pDataBlock
;
}
}
...
@@ -2872,9 +2882,7 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
...
@@ -2872,9 +2882,7 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
while
(
true
)
{
while
(
true
)
{
if
(
hasNext
)
{
if
(
hasNext
)
{
SFileDataBlockInfo
*
pFBlock
=
getCurrentBlockInfo
(
pBlockIter
);
SBlock
*
pBlock
=
getCurrentBlock
(
pBlockIter
);
STableBlockScanInfo
*
pScanInfo
=
taosHashGet
(
pStatus
->
pTableMap
,
&
pFBlock
->
uid
,
sizeof
(
pFBlock
->
uid
));
SBlock
*
pBlock
=
taosArrayGet
(
pScanInfo
->
pBlockList
,
pFBlock
->
tbBlockIdx
);
int32_t
numOfRows
=
pBlock
->
nRow
;
int32_t
numOfRows
=
pBlock
->
nRow
;
pTableBlockInfo
->
totalRows
+=
numOfRows
;
pTableBlockInfo
->
totalRows
+=
numOfRows
;
...
@@ -2895,7 +2903,6 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
...
@@ -2895,7 +2903,6 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
pTableBlockInfo
->
blockRowsHisto
[
bucketIndex
]
++
;
pTableBlockInfo
->
blockRowsHisto
[
bucketIndex
]
++
;
hasNext
=
blockIteratorNext
(
&
pStatus
->
blockIter
);
hasNext
=
blockIteratorNext
(
&
pStatus
->
blockIter
);
}
else
{
}
else
{
code
=
initForFirstBlockInFile
(
pReader
,
pBlockIter
);
code
=
initForFirstBlockInFile
(
pReader
,
pBlockIter
);
if
((
code
!=
TSDB_CODE_SUCCESS
)
||
(
pReader
->
status
.
loadFromFile
==
false
))
{
if
((
code
!=
TSDB_CODE_SUCCESS
)
||
(
pReader
->
status
.
loadFromFile
==
false
))
{
...
...
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
db6c660b
...
@@ -1022,6 +1022,10 @@ void tBlockDataClear(SBlockData *pBlockData, int8_t deepClear) {
...
@@ -1022,6 +1022,10 @@ void tBlockDataClear(SBlockData *pBlockData, int8_t deepClear) {
tFree
((
uint8_t
*
)
pBlockData
->
aTSKEY
);
tFree
((
uint8_t
*
)
pBlockData
->
aTSKEY
);
taosArrayDestroy
(
pBlockData
->
aIdx
);
taosArrayDestroy
(
pBlockData
->
aIdx
);
taosArrayDestroyEx
(
pBlockData
->
aColData
,
deepClear
?
tColDataClear
:
NULL
);
taosArrayDestroyEx
(
pBlockData
->
aColData
,
deepClear
?
tColDataClear
:
NULL
);
pBlockData
->
aColData
=
NULL
;
pBlockData
->
aIdx
=
NULL
;
pBlockData
->
aTSKEY
=
NULL
;
pBlockData
->
aVersion
=
NULL
;
}
}
int32_t
tBlockDataSetSchema
(
SBlockData
*
pBlockData
,
STSchema
*
pTSchema
)
{
int32_t
tBlockDataSetSchema
(
SBlockData
*
pBlockData
,
STSchema
*
pTSchema
)
{
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
db6c660b
...
@@ -3209,9 +3209,8 @@ static void doHandleRemainBlockFromNewGroup(SFillOperatorInfo* pInfo, SResultInf
...
@@ -3209,9 +3209,8 @@ static void doHandleRemainBlockFromNewGroup(SFillOperatorInfo* pInfo, SResultInf
if
(
taosFillHasMoreResults
(
pInfo
->
pFillInfo
))
{
if
(
taosFillHasMoreResults
(
pInfo
->
pFillInfo
))
{
int32_t
numOfResultRows
=
pResultInfo
->
capacity
-
pInfo
->
pRes
->
info
.
rows
;
int32_t
numOfResultRows
=
pResultInfo
->
capacity
-
pInfo
->
pRes
->
info
.
rows
;
taosFillResultDataBlock
(
pInfo
->
pFillInfo
,
pInfo
->
pRes
,
numOfResultRows
);
taosFillResultDataBlock
(
pInfo
->
pFillInfo
,
pInfo
->
pRes
,
numOfResultRows
);
if
(
pInfo
->
pRes
->
info
.
rows
>
pResultInfo
->
threshold
)
{
pInfo
->
pRes
->
info
.
groupId
=
pInfo
->
curGroupId
;
return
;
return
;
}
}
}
// handle the cached new group data block
// handle the cached new group data block
...
@@ -3230,7 +3229,7 @@ static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) {
...
@@ -3230,7 +3229,7 @@ static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) {
blockDataCleanup
(
pResBlock
);
blockDataCleanup
(
pResBlock
);
doHandleRemainBlockFromNewGroup
(
pInfo
,
pResultInfo
,
pTaskInfo
);
doHandleRemainBlockFromNewGroup
(
pInfo
,
pResultInfo
,
pTaskInfo
);
if
(
pResBlock
->
info
.
rows
>
pResultInfo
->
threshold
||
pResBlock
->
info
.
rows
>
0
)
{
if
(
pResBlock
->
info
.
rows
>
0
)
{
pResBlock
->
info
.
groupId
=
pInfo
->
curGroupId
;
pResBlock
->
info
.
groupId
=
pInfo
->
curGroupId
;
return
pResBlock
;
return
pResBlock
;
}
}
...
...
source/libs/executor/src/projectoperator.c
浏览文件 @
db6c660b
...
@@ -292,7 +292,9 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
...
@@ -292,7 +292,9 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
// do apply filter
// do apply filter
doFilter
(
pProjectInfo
->
pFilterNode
,
pFinalRes
,
NULL
);
doFilter
(
pProjectInfo
->
pFilterNode
,
pFinalRes
,
NULL
);
if
(
pFinalRes
->
info
.
rows
>
0
||
pRes
->
info
.
rows
==
0
)
{
// when apply the limit/offset for each group, pRes->info.rows may be 0, due to limit constraint.
if
(
pFinalRes
->
info
.
rows
>
0
||
(
pOperator
->
status
==
OP_EXEC_DONE
))
{
break
;
break
;
}
}
}
else
{
}
else
{
...
...
tests/script/tsim/parser/lastrow_query.sim
浏览文件 @
db6c660b
...
@@ -131,7 +131,7 @@ if $rows != 172798 then
...
@@ -131,7 +131,7 @@ if $rows != 172798 then
endi
endi
sql select t1,t1,count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by tbname, t1 interval(1s) fill(NULL) slimit 1 soffset 0 limit 250000 offset 1
sql select t1,t1,count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by tbname, t1 interval(1s) fill(NULL) slimit 1 soffset 0 limit 250000 offset 1
if $rows != 8
5648
then
if $rows != 8
6399
then
return -1
return -1
endi
endi
...
@@ -146,7 +146,7 @@ if $rows != 4 then
...
@@ -146,7 +146,7 @@ if $rows != 4 then
endi
endi
sql select t1,t1,count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by tbname, t1 interval(1s) fill(NULL) slimit 1 soffset 1 limit 250000 offset 1
sql select t1,t1,count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by tbname, t1 interval(1s) fill(NULL) slimit 1 soffset 1 limit 250000 offset 1
if $rows != 8
7150
then
if $rows != 8
6399
then
return -1
return -1
endi
endi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录