Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
407a3453
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
407a3453
编写于
10月 28, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): set fetch block info.
上级
2c896012
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
61 addition
and
31 deletion
+61
-31
source/libs/executor/inc/executil.h
source/libs/executor/inc/executil.h
+7
-4
source/libs/executor/src/cachescanoperator.c
source/libs/executor/src/cachescanoperator.c
+2
-2
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+15
-6
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+14
-10
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+22
-9
source/libs/executor/src/sortoperator.c
source/libs/executor/src/sortoperator.c
+1
-0
未找到文件。
source/libs/executor/inc/executil.h
浏览文件 @
407a3453
...
...
@@ -95,17 +95,20 @@ typedef struct SColMatchInfo {
int32_t
matchType
;
// determinate the source according to col id or slot id
}
SColMatchInfo
;
// If the numOfOutputGroups is 1, the data blocks that belongs to different groups will be provided randomly
// The numOfOutputGroups is specified by physical plan. and will not be affect by numOfGroups
typedef
struct
STableListInfo
{
bool
oneTableForEachGroup
;
int32_t
numOf
Groups
;
int32_t
*
groupOffset
;
// keep the offset value for each group in the tableList
int32_t
numOf
OuputGroups
;
// the data block will be generated one by one
int32_t
*
groupOffset
;
// keep the offset value for each group in the tableList
SArray
*
pTableList
;
SHashObj
*
map
;
// speedup acquire the tableQueryInfo by table uid
SHashObj
*
map
;
// speedup acquire the tableQueryInfo by table uid
uint64_t
suid
;
}
STableListInfo
;
void
destroyTableList
(
STableListInfo
*
pTableList
);
int32_t
getNumOfGroups
(
const
STableListInfo
*
pTableList
);
int32_t
getNumOfOutputGroups
(
const
STableListInfo
*
pTableList
);
bool
oneTableForEachGroup
(
const
STableListInfo
*
pTableList
);
uint64_t
getTableGroupId
(
const
STableListInfo
*
pTableList
,
uint64_t
tableUid
);
int32_t
addTableIntoTableList
(
STableListInfo
*
pTableList
,
uint64_t
uid
,
uint64_t
gid
);
int32_t
getTablesOfGroup
(
const
STableListInfo
*
pTableList
,
int32_t
ordinalIndex
,
STableKeyInfo
**
pKeyInfo
,
int32_t
*
num
);
...
...
source/libs/executor/src/cachescanoperator.c
浏览文件 @
407a3453
...
...
@@ -62,7 +62,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
pInfo
->
pUidList
=
taosArrayInit
(
4
,
sizeof
(
int64_t
));
// partition by tbname, todo opt perf
if
(
getNumOfGroups
(
pTableList
)
==
getTotalTables
(
pTableList
))
{
if
(
oneTableForEachGroup
(
pTableList
))
{
pInfo
->
retrieveType
=
CACHESCAN_RETRIEVE_TYPE_ALL
|
(
pScanNode
->
ignoreNull
?
CACHESCAN_RETRIEVE_LAST
:
CACHESCAN_RETRIEVE_LAST_ROW
);
...
...
@@ -189,7 +189,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
return
NULL
;
}
}
else
{
size_t
totalGroups
=
getNumOfGroups
(
pTableList
);
size_t
totalGroups
=
getNumOf
Output
Groups
(
pTableList
);
while
(
pInfo
->
currentGroupIndex
<
totalGroups
)
{
...
...
source/libs/executor/src/executil.c
浏览文件 @
407a3453
...
...
@@ -1665,6 +1665,11 @@ uint64_t getTotalTables(const STableListInfo* pTableList) {
}
uint64_t
getTableGroupId
(
const
STableListInfo
*
pTableList
,
uint64_t
tableUid
)
{
if
(
pTableList
->
oneTableForEachGroup
)
{
ASSERT
(
pTableList
->
map
==
NULL
);
return
tableUid
;
}
uint64_t
*
groupId
=
taosHashGet
(
pTableList
->
map
,
&
tableUid
,
sizeof
(
tableUid
));
if
(
groupId
!=
NULL
)
{
return
*
groupId
;
...
...
@@ -1677,25 +1682,25 @@ int32_t addTableIntoTableList(STableListInfo* pTableList, uint64_t uid, uint64_t
STableKeyInfo
keyInfo
=
{.
uid
=
uid
,
.
groupId
=
gid
};
taosArrayPush
(
pTableList
->
pTableList
,
&
keyInfo
);
if
(
pTableList
->
oneTableForEachGroup
||
pTableList
->
numOfGroups
>
1
)
{
if
(
pTableList
->
oneTableForEachGroup
||
pTableList
->
numOf
Ouput
Groups
>
1
)
{
taosHashPut
(
pTableList
->
map
,
&
uid
,
sizeof
(
uid
),
&
keyInfo
.
groupId
,
sizeof
(
keyInfo
.
groupId
));
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
getTablesOfGroup
(
const
STableListInfo
*
pTableList
,
int32_t
ordinalGroupIndex
,
STableKeyInfo
**
pKeyInfo
,
int32_t
*
size
)
{
int32_t
total
=
getNumOfGroups
(
pTableList
);
int32_t
total
=
getNumOf
Output
Groups
(
pTableList
);
if
(
ordinalGroupIndex
<
0
||
ordinalGroupIndex
>=
total
)
{
return
TSDB_CODE_INVALID_PARA
;
}
// here handle two special cases:
// 1. only one group exists, and 2. one table exists for each group.
if
(
pTableList
->
numOfGroups
==
1
)
{
if
(
total
==
1
)
{
*
size
=
getTotalTables
(
pTableList
);
*
pKeyInfo
=
taosArrayGet
(
pTableList
->
pTableList
,
0
);
return
TSDB_CODE_SUCCESS
;
}
else
if
(
pTableList
->
numOfGroups
==
getTotalTables
(
pTableList
))
{
}
else
if
(
total
==
getTotalTables
(
pTableList
))
{
*
size
=
1
;
*
pKeyInfo
=
taosArrayGet
(
pTableList
->
pTableList
,
ordinalGroupIndex
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -1712,8 +1717,12 @@ int32_t getTablesOfGroup(const STableListInfo* pTableList, int32_t ordinalGroupI
return
TSDB_CODE_SUCCESS
;
}
int32_t
getNumOfGroups
(
const
STableListInfo
*
pTableList
)
{
return
pTableList
->
numOfGroups
;
int32_t
getNumOfOutputGroups
(
const
STableListInfo
*
pTableList
)
{
return
pTableList
->
numOfOuputGroups
;
}
bool
oneTableForEachGroup
(
const
STableListInfo
*
pTableList
)
{
return
pTableList
->
oneTableForEachGroup
;
}
void
destroyTableList
(
STableListInfo
*
pTableqinfoList
)
{
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
407a3453
...
...
@@ -3397,9 +3397,9 @@ static int32_t sortTableGroup(STableListInfo* pTableListInfo) {
}
}
pTableListInfo
->
numOfGroups
=
taosArrayGetSize
(
pList
);
pTableListInfo
->
groupOffset
=
taosMemoryMalloc
(
sizeof
(
int32_t
)
*
pTableListInfo
->
numOfGroups
);
memcpy
(
pTableListInfo
->
groupOffset
,
taosArrayGet
(
pList
,
0
),
sizeof
(
int32_t
)
*
pTableListInfo
->
numOfGroups
);
pTableListInfo
->
numOf
Ouput
Groups
=
taosArrayGetSize
(
pList
);
pTableListInfo
->
groupOffset
=
taosMemoryMalloc
(
sizeof
(
int32_t
)
*
pTableListInfo
->
numOf
Ouput
Groups
);
memcpy
(
pTableListInfo
->
groupOffset
,
taosArrayGet
(
pList
,
0
),
sizeof
(
int32_t
)
*
pTableListInfo
->
numOf
Ouput
Groups
);
taosArrayDestroy
(
pList
);
# if 0
...
...
@@ -3490,13 +3490,15 @@ bool groupbyTbname(SNodeList* pGroupList) {
}
int32_t
generateGroupIdMap
(
STableListInfo
*
pTableListInfo
,
SReadHandle
*
pHandle
,
SNodeList
*
group
,
bool
groupSort
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
group
==
NULL
)
{
return
TDB_CODE_SUCCESS
;
return
code
;
}
pTableListInfo
->
map
=
taosHashInit
(
32
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_ENTRY_LOCK
);
if
(
pTableListInfo
->
map
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
return
code
;
}
bool
assignUid
=
groupbyTbname
(
group
);
...
...
@@ -3508,21 +3510,23 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
info
->
groupId
=
info
->
uid
;
taosHashPut
(
pTableListInfo
->
map
,
&
(
info
->
uid
),
sizeof
(
uint64_t
),
&
info
->
groupId
,
sizeof
(
uint64_t
));
}
pTableListInfo
->
oneTableForEachGroup
=
true
;
pTableListInfo
->
numOfGroups
=
numOfTables
;
if
(
groupSort
)
{
pTableListInfo
->
numOfOuputGroups
=
numOfTables
;
}
}
else
{
int32_t
code
=
getColInfoResultForGroupby
(
pHandle
->
meta
,
group
,
pTableListInfo
);
code
=
getColInfoResultForGroupby
(
pHandle
->
meta
,
group
,
pTableListInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
if
(
groupSort
)
{
return
sortTableGroup
(
pTableListInfo
);
code
=
sortTableGroup
(
pTableListInfo
);
}
}
qDebug
(
"-------------------, %d"
,
(
int
)
taosHashGetSize
(
pTableListInfo
->
map
));
return
TDB_CODE_SUCCESS
;
return
code
;
}
static
int32_t
initTableblockDistQueryCond
(
uint64_t
uid
,
SQueryTableDataCond
*
pCond
)
{
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
407a3453
...
...
@@ -746,7 +746,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
}
}
else
{
// scan table group by group sequentially
if
(
pInfo
->
currentGroupId
==
-
1
)
{
if
((
++
pInfo
->
currentGroupId
)
>=
getNumOfGroups
(
&
pTaskInfo
->
tableqinfoList
))
{
if
((
++
pInfo
->
currentGroupId
)
>=
getNumOf
Output
Groups
(
&
pTaskInfo
->
tableqinfoList
))
{
doSetOperatorCompleted
(
pOperator
);
return
NULL
;
}
...
...
@@ -768,7 +768,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
return
result
;
}
if
((
++
pInfo
->
currentGroupId
)
>=
getNumOfGroups
(
&
pTaskInfo
->
tableqinfoList
))
{
if
((
++
pInfo
->
currentGroupId
)
>=
getNumOf
Output
Groups
(
&
pTaskInfo
->
tableqinfoList
))
{
doSetOperatorCompleted
(
pOperator
);
return
NULL
;
}
...
...
@@ -1094,7 +1094,9 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU
cond
.
twindows
=
(
STimeWindow
){.
skey
=
startTs
,
.
ekey
=
endTs
};
SExecTaskInfo
*
pTaskInfo
=
pTableScanOp
->
pTaskInfo
;
blockDataCleanup
(
pTableScanInfo
->
pResBlock
);
SSDataBlock
*
pBlock
=
pTableScanInfo
->
pResBlock
;
blockDataCleanup
(
pBlock
);
STsdbReader
*
pReader
=
NULL
;
int32_t
code
=
tsdbReaderOpen
(
pTableScanInfo
->
readHandle
.
vnode
,
&
cond
,
&
tblInfo
,
1
,
(
STsdbReader
**
)
&
pReader
,
...
...
@@ -1106,14 +1108,25 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU
bool
hasBlock
=
tsdbNextDataBlock
(
pReader
);
if
(
hasBlock
)
{
SArray
*
pCols
=
tsdbRetrieveDataBlock
(
pTableScanInfo
->
dataReader
,
NULL
);
relocateColumnData
(
pTableScanInfo
->
pResBlock
,
pTableScanInfo
->
matchInfo
.
pList
,
pCols
,
true
);
doSetTagColumnData
(
pTableScanInfo
,
pTableScanInfo
->
pResBlock
,
pTaskInfo
);
SDataBlockInfo
binfo
=
{
0
};
tsdbRetrieveDataBlockInfo
(
pReader
,
&
binfo
);
SArray
*
pCols
=
tsdbRetrieveDataBlock
(
pReader
,
NULL
);
blockDataEnsureCapacity
(
pBlock
,
binfo
.
rows
);
pBlock
->
info
.
window
=
binfo
.
window
;
pBlock
->
info
.
uid
=
binfo
.
uid
;
pBlock
->
info
.
rows
=
binfo
.
rows
;
relocateColumnData
(
pBlock
,
pTableScanInfo
->
matchInfo
.
pList
,
pCols
,
true
);
doSetTagColumnData
(
pTableScanInfo
,
pBlock
,
pTaskInfo
);
}
tsdbReaderClose
(
pReader
);
qDebug
(
"retrieve prev rows:%d, skey:%"
PRId64
", ekey:%"
PRId64
" uid:%"
PRIu64
", max ver:%"
PRId64
", suid:%"
PRIu64
,
pBlock
->
info
.
rows
,
startTs
,
endTs
,
tbUid
,
maxVersion
,
cond
.
suid
);
return
p
TableScanInfo
->
pResBlock
->
info
.
rows
>
0
?
pTableScanInfo
->
pResBlock
:
NULL
;
return
p
Block
->
info
.
rows
>
0
?
pBlock
:
NULL
;
}
static
uint64_t
getGroupIdByCol
(
SStreamScanInfo
*
pInfo
,
uint64_t
uid
,
TSKEY
ts
,
int64_t
maxVersion
)
{
...
...
@@ -2371,7 +2384,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
// set the extract column id to streamHandle
tqReaderSetColIdList
(
pInfo
->
tqReader
,
pColIds
);
SArray
*
tableIdList
=
extractTableIdList
(
&
pTaskInfo
->
tableqinfoList
);
int32_t
code
=
tqReaderSetTbUidList
(
pInfo
->
tqReader
,
tableIdList
);
code
=
tqReaderSetTbUidList
(
pInfo
->
tqReader
,
tableIdList
);
if
(
code
!=
0
)
{
taosArrayDestroy
(
tableIdList
);
goto
_error
;
...
...
@@ -4152,7 +4165,7 @@ int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags
return
TSDB_CODE_SUCCESS
;
}
pTableListInfo
->
numOfGroups
=
1
;
pTableListInfo
->
numOf
Ouput
Groups
=
1
;
code
=
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
pGroupTags
,
groupSort
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
source/libs/executor/src/sortoperator.c
浏览文件 @
407a3453
...
...
@@ -654,6 +654,7 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData
colDataAssign
(
pDst
,
pSrc
,
p
->
info
.
rows
,
&
pDataBlock
->
info
);
}
pInfo
->
limitInfo
.
numOfOutputRows
+=
p
->
info
.
rows
;
pDataBlock
->
info
.
rows
=
p
->
info
.
rows
;
pDataBlock
->
info
.
groupId
=
pInfo
->
groupId
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录